From d07088ee8ae7c5d05e511c60f3c4280a47aae050 Mon Sep 17 00:00:00 2001 From: Evan Stade Date: Thu, 19 Jul 2007 18:22:34 -0700 Subject: [PATCH] gdiplus: Initial custom line caps implementation. --- dlls/gdiplus/Makefile.in | 1 + dlls/gdiplus/customlinecap.c | 79 ++++++++++++++++++++++++++++++++++ dlls/gdiplus/gdiplus.spec | 4 +- dlls/gdiplus/gdiplus_private.h | 7 +++ include/gdiplusflat.h | 4 ++ include/gdiplusgpstubs.h | 2 + 6 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 dlls/gdiplus/customlinecap.c diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in index f4bf072b831..c47b6a6e8b6 100644 --- a/dlls/gdiplus/Makefile.in +++ b/dlls/gdiplus/Makefile.in @@ -8,6 +8,7 @@ IMPORTS = user32 gdi32 advapi32 kernel32 ntdll C_SRCS = \ brush.c \ + customlinecap.c \ gdiplus.c \ graphics.c \ graphicspath.c \ diff --git a/dlls/gdiplus/customlinecap.c b/dlls/gdiplus/customlinecap.c new file mode 100644 index 00000000000..2a0cfb25876 --- /dev/null +++ b/dlls/gdiplus/customlinecap.c @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2007 Google (Evan Stade) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#include "windef.h" +#include "winbase.h" + +#include "gdiplus.h" +#include "gdiplus_private.h" + +GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath, + GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap) +{ + GpPathData *pathdata; + + if(!customCap || !(fillPath || strokePath)) + return InvalidParameter; + + *customCap = GdipAlloc(sizeof(GpCustomLineCap)); + if(!*customCap) return OutOfMemory; + + if(strokePath){ + (*customCap)->fill = FALSE; + pathdata = &strokePath->pathdata; + } + else{ + (*customCap)->fill = TRUE; + pathdata = &fillPath->pathdata; + } + + (*customCap)->pathdata.Points = GdipAlloc(pathdata->Count * sizeof(PointF)); + (*customCap)->pathdata.Types = GdipAlloc(pathdata->Count); + + if((!(*customCap)->pathdata.Types || !(*customCap)->pathdata.Points) && + pathdata->Count){ + GdipFree((*customCap)->pathdata.Points); + GdipFree((*customCap)->pathdata.Types); + GdipFree(*customCap); + return OutOfMemory; + } + + memcpy((*customCap)->pathdata.Points, pathdata->Points, pathdata->Count + * sizeof(PointF)); + memcpy((*customCap)->pathdata.Types, pathdata->Types, pathdata->Count); + (*customCap)->pathdata.Count = pathdata->Count; + + (*customCap)->inset = baseInset; + (*customCap)->cap = baseCap; + + return Ok; +} + +GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap) +{ + if(!customCap) + return InvalidParameter; + + GdipFree(customCap->pathdata.Points); + GdipFree(customCap->pathdata.Types); + GdipFree(customCap); + + return Ok; +} diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 308c05ef5a2..d80784eb731 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -74,7 +74,7 @@ @ stub GdipCreateBitmapFromStream @ stub GdipCreateBitmapFromStreamICM @ stub GdipCreateCachedBitmap -@ stub GdipCreateCustomLineCap +@ stdcall GdipCreateCustomLineCap(ptr ptr long long ptr) @ stub GdipCreateFont @ stub GdipCreateFontFamilyFromName @ stub GdipCreateFontFromDC @@ -129,7 +129,7 @@ @ stub GdipCreateTextureIAI @ stdcall GdipDeleteBrush(ptr) @ stub GdipDeleteCachedBitmap -@ stub GdipDeleteCustomLineCap +@ stdcall GdipDeleteCustomLineCap(ptr) @ stub GdipDeleteFont @ stub GdipDeleteFontFamily @ stdcall GdipDeleteGraphics(ptr) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 299806b613f..5350a19a4ad 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -91,4 +91,11 @@ struct GpPathIterator{ INT pathtype_pos; /* for NextPathType methods */ }; +struct GpCustomLineCap{ + GpPathData pathdata; + BOOL fill; /* TRUE for fill, FALSE for stroke */ + GpLineCap cap; /* as far as I can tell, this value is ignored */ + REAL inset; /* how much to adjust the end of the line */ +}; + #endif diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 11d36f5b421..136f4695f74 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -101,6 +101,10 @@ GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator*,INT*,GpPointF*,BYTE*, GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator*,INT*,INT*,INT*,BOOL*); GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator*); +GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath*,GpPath*,GpLineCap,REAL, + GpCustomLineCap**); +GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap*); + #ifdef __cplusplus } #endif diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h index 8bb5bb68343..0e431c5edee 100644 --- a/include/gdiplusgpstubs.h +++ b/include/gdiplusgpstubs.h @@ -28,6 +28,7 @@ class GpSolidFill {}; class GpPath {}; class GpMatrix {}; class GpPathIterator {}; +class GpCustomLineCap {}; #else /* end of c++ declarations */ @@ -38,6 +39,7 @@ typedef struct GpSolidFill GpSolidFill; typedef struct GpPath GpPath; typedef struct GpMatrix GpMatrix; typedef struct GpPathIterator GpPathIterator; +typedef struct GpCustomLineCap GpCustomLineCap; #endif /* end of c declarations */