Nikolay Sivov : gdiplus: Implemented GdipGetPenCustom[Start/End]Cap.

Alexandre Julliard julliard at winehq.org
Fri Aug 1 05:33:58 CDT 2008


Module: wine
Branch: master
Commit: e9bcce6e1dbe813ca47e0a49b6c183fd22e39c1c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e9bcce6e1dbe813ca47e0a49b6c183fd22e39c1c

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Fri Aug  1 13:39:48 2008 +0400

gdiplus: Implemented GdipGetPenCustom[Start/End]Cap.

---

 dlls/gdiplus/gdiplus.spec |    4 +-
 dlls/gdiplus/pen.c        |   34 ++++++++++++++++++++++++++++-
 dlls/gdiplus/tests/pen.c  |   50 +++++++++++++++++++++++++++++++++++++++++++++
 include/gdiplusflat.h     |    2 +
 4 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 48d46a3..5b046a1 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -352,8 +352,8 @@
 @ stdcall GdipGetPenColor(ptr ptr)
 @ stub GdipGetPenCompoundArray
 @ stub GdipGetPenCompoundCount
-@ stub GdipGetPenCustomEndCap
-@ stub GdipGetPenCustomStartCap
+@ stdcall GdipGetPenCustomEndCap(ptr ptr)
+@ stdcall GdipGetPenCustomStartCap(ptr ptr)
 @ stdcall GdipGetPenDashArray(ptr ptr long)
 @ stdcall GdipGetPenDashCap197819(ptr ptr)
 @ stdcall GdipGetPenDashCount(ptr ptr)
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
index 829b191..104d9de 100644
--- a/dlls/gdiplus/pen.c
+++ b/dlls/gdiplus/pen.c
@@ -116,6 +116,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit,
     gp_pen->miterlimit = 10.0;
     gp_pen->dash = DashStyleSolid;
     gp_pen->offset = 0.0;
+    gp_pen->customstart = NULL;
+    gp_pen->customend = NULL;
 
     if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) {
         FIXME("UnitWorld, UnitPixel only supported units\n");
@@ -163,6 +165,32 @@ GpStatus WINGDIPAPI GdipGetPenColor(GpPen *pen, ARGB *argb)
     return GdipGetSolidFillColor(((GpSolidFill*)pen->brush), argb);
 }
 
+GpStatus WINGDIPAPI GdipGetPenCustomEndCap(GpPen *pen, GpCustomLineCap** customCap)
+{
+    if(!pen || !customCap)
+        return InvalidParameter;
+
+    if(!pen->customend){
+        *customCap = NULL;
+        return Ok;
+    }
+
+    return GdipCloneCustomLineCap(pen->customend, customCap);
+}
+
+GpStatus WINGDIPAPI GdipGetPenCustomStartCap(GpPen *pen, GpCustomLineCap** customCap)
+{
+    if(!pen || !customCap)
+        return InvalidParameter;
+
+    if(!pen->customstart){
+        *customCap = NULL;
+        return Ok;
+    }
+
+    return GdipCloneCustomLineCap(pen->customstart, customCap);
+}
+
 GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen *pen, REAL *dash, INT count)
 {
     if(!pen || !dash || count > pen->numdashes)
@@ -312,7 +340,8 @@ GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen *pen, GpCustomLineCap* customCa
     GpCustomLineCap * cap;
     GpStatus ret;
 
-    if(!pen || !customCap) return InvalidParameter;
+    /* native crashes on pen == NULL, customCap != NULL */
+    if(!customCap) return InvalidParameter;
 
     if((ret = GdipCloneCustomLineCap(customCap, &cap)) == Ok){
         GdipDeleteCustomLineCap(pen->customend);
@@ -328,7 +357,8 @@ GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap* custom
     GpCustomLineCap * cap;
     GpStatus ret;
 
-    if(!pen || !customCap) return InvalidParameter;
+    /* native crashes on pen == NULL, customCap != NULL */
+    if(!customCap) return InvalidParameter;
 
     if((ret = GdipCloneCustomLineCap(customCap, &cap)) == Ok){
         GdipDeleteCustomLineCap(pen->customstart);
diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c
index ad484ce..d75e510 100644
--- a/dlls/gdiplus/tests/pen.c
+++ b/dlls/gdiplus/tests/pen.c
@@ -226,6 +226,55 @@ static void test_dasharray(void)
     GdipDeletePen(pen);
 }
 
+static void test_customcap(void)
+{
+    GpPen *pen;
+    GpStatus status;
+    GpCustomLineCap *custom;
+
+    status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
+    expect(Ok, status);
+
+    /* NULL args */
+    status = GdipGetPenCustomStartCap(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetPenCustomStartCap(pen, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetPenCustomStartCap(NULL, &custom);
+    expect(InvalidParameter, status);
+
+    status = GdipGetPenCustomEndCap(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetPenCustomEndCap(pen, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetPenCustomEndCap(NULL, &custom);
+    expect(InvalidParameter, status);
+
+    /* native crashes on pen == NULL, custom != NULL */
+    status = GdipSetPenCustomStartCap(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipSetPenCustomStartCap(pen, NULL);
+    expect(InvalidParameter, status);
+
+    status = GdipSetPenCustomEndCap(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipSetPenCustomEndCap(pen, NULL);
+    expect(InvalidParameter, status);
+
+    /* get without setting previously */
+    custom = (GpCustomLineCap*)0xdeadbeef;
+    status = GdipGetPenCustomEndCap(pen, &custom);
+    expect(Ok, status);
+    ok(custom == NULL,"Expect CustomCap == NULL\n");
+
+    custom = (GpCustomLineCap*)0xdeadbeef;
+    status = GdipGetPenCustomStartCap(pen, &custom);
+    expect(Ok, status);
+    ok(custom == NULL,"Expect CustomCap == NULL\n");
+
+    GdipDeletePen(pen);
+}
+
 START_TEST(pen)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -244,6 +293,7 @@ START_TEST(pen)
     test_constructor_destructor2();
     test_brushfill();
     test_dasharray();
+    test_customcap();
 
     GdiplusShutdown(gdiplusToken);
 }
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 2e0d743..4293f64 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -33,6 +33,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush*,REAL,GpUnit,GpPen**);
 GpStatus WINGDIPAPI GdipDeletePen(GpPen*);
 GpStatus WINGDIPAPI GdipGetPenBrushFill(GpPen*,GpBrush**);
 GpStatus WINGDIPAPI GdipGetPenColor(GpPen*,ARGB*);
+GpStatus WINGDIPAPI GdipGetPenCustomStartCap(GpPen*,GpCustomLineCap**);
+GpStatus WINGDIPAPI GdipGetPenCustomEndCap(GpPen*,GpCustomLineCap**);
 GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen*,REAL*,INT);
 GpStatus WINGDIPAPI GdipGetPenDashCount(GpPen*,INT*);
 GpStatus WINGDIPAPI GdipGetPenDashOffset(GpPen*,REAL*);




More information about the wine-cvs mailing list