[3/8] gdiplus: initial custom line cap implementation

Evan Stade estade at gmail.com
Tue Jul 17 21:31:06 CDT 2007


Hi,

Changelog:
*added GdipCreateCustomLineCap(), GdipDeleteCustomLineCap()
*added necessary types

 dlls/gdiplus/Makefile.in       |    1
 dlls/gdiplus/customlinecap.c   |   81 ++++++++++++++++++++++++++++++++++++++++
 dlls/gdiplus/gdiplus.spec      |    4 +-
 dlls/gdiplus/gdiplus_private.h |    7 +++
 include/gdiplusflat.h          |    4 ++
 include/gdiplusgpstubs.h       |    2 +
 6 files changed, 97 insertions(+), 2 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in
index f4bf072..c47b6a6 100644
--- a/dlls/gdiplus/Makefile.in
+++ b/dlls/gdiplus/Makefile.in
@@ -8,6 +8,7 @@ IMPORTS   = user32 gdi32 advapi32 kernel
 
 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 0000000..20dfaef
--- /dev/null
+++ b/dlls/gdiplus/customlinecap.c
@@ -0,0 +1,81 @@
+/*
+ * 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 <stdarg.h>
+
+#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)
+        return InvalidParameter;
+
+    *customCap = GdipAlloc(sizeof(GpCustomLineCap));
+    if(!*customCap)    return OutOfMemory;
+
+    if(strokePath){
+        (*customCap)->fill = FALSE;
+        pathdata = &strokePath->pathdata;
+    }
+    else if(fillPath){
+        (*customCap)->fill = TRUE;
+        pathdata = &fillPath->pathdata;
+    }
+    else
+        return InvalidParameter;
+
+    (*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 9bc5122..a50d866 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 299806b..5350a19 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 a358a1e..df6ca7c 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -96,6 +96,10 @@ GpStatus WINGDIPAPI GdipPathIterCopyData
 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 7cb1888..ea24033 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 */
 
-- 
1.4.1


More information about the wine-patches mailing list