Nikolay Sivov : gdiplus: implemeted GdipGetPathGradientBlendCount with test .

Alexandre Julliard julliard at winehq.org
Tue Jul 22 09:35:58 CDT 2008


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

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Mon Jul 21 23:30:39 2008 +0400

gdiplus: implemeted GdipGetPathGradientBlendCount with test.

---

 dlls/gdiplus/brush.c           |   48 ++++++++++++++++++++++++++++++++++++++++
 dlls/gdiplus/gdiplus.spec      |    2 +-
 dlls/gdiplus/gdiplus_private.h |    3 ++
 dlls/gdiplus/tests/brush.c     |   25 ++++++++++++++++++++
 include/gdiplusflat.h          |    1 +
 5 files changed, 78 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index ba7663e..86740fe 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -75,6 +75,24 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
             memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
             memcpy(dest->pathdata.Types, src->pathdata.Types, count);
 
+            /* blending */
+            count = src->blendcount;
+            dest->blendcount = count;
+            dest->blendfac = GdipAlloc(count * sizeof(REAL));
+            dest->blendpos = GdipAlloc(count * sizeof(REAL));
+
+            if(!dest->blendfac || !dest->blendpos){
+                GdipFree(dest->pathdata.Points);
+                GdipFree(dest->pathdata.Types);
+                GdipFree(dest->blendfac);
+                GdipFree(dest->blendpos);
+                GdipFree(dest);
+                return OutOfMemory;
+            }
+
+            memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
+            memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
+
             break;
         }
         case BrushTypeLinearGradient:
@@ -213,6 +231,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
     *grad = GdipAlloc(sizeof(GpPathGradient));
     if (!*grad) return OutOfMemory;
 
+    (*grad)->blendfac = GdipAlloc(sizeof(REAL));
+    if(!(*grad)->blendfac){
+        GdipFree(*grad);
+        return OutOfMemory;
+    }
+    (*grad)->blendfac[0] = 1.0;
+    (*grad)->blendpos    = NULL;
+    (*grad)->blendcount  = 1;
+
     (*grad)->pathdata.Count = count;
     (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
     (*grad)->pathdata.Types = GdipAlloc(count);
@@ -284,6 +311,15 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
     *grad = GdipAlloc(sizeof(GpPathGradient));
     if (!*grad) return OutOfMemory;
 
+    (*grad)->blendfac = GdipAlloc(sizeof(REAL));
+    if(!(*grad)->blendfac){
+        GdipFree(*grad);
+        return OutOfMemory;
+    }
+    (*grad)->blendfac[0] = 1.0;
+    (*grad)->blendpos    = NULL;
+    (*grad)->blendcount  = 1;
+
     (*grad)->pathdata.Count = path->pathdata.Count;
     (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
     (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
@@ -476,6 +512,8 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
         case BrushTypePathGradient:
             GdipFree(((GpPathGradient*) brush)->pathdata.Points);
             GdipFree(((GpPathGradient*) brush)->pathdata.Types);
+            GdipFree(((GpPathGradient*) brush)->blendfac);
+            GdipFree(((GpPathGradient*) brush)->blendpos);
             break;
         case BrushTypeSolidColor:
         case BrushTypeLinearGradient:
@@ -511,6 +549,16 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapm
     return Ok;
 }
 
+GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
+{
+    if(!brush || !count)
+        return InvalidParameter;
+
+    *count = brush->blendcount;
+
+    return Ok;
+}
+
 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
     GpPointF *point)
 {
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 07bd6ed..9d609fa 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -326,7 +326,7 @@
 @ stdcall GdipGetPathData(ptr ptr)
 @ stdcall GdipGetPathFillMode(ptr ptr)
 @ stub GdipGetPathGradientBlend
-@ stub GdipGetPathGradientBlendCount
+@ stdcall GdipGetPathGradientBlendCount(ptr ptr)
 @ stub GdipGetPathGradientCenterColor
 @ stdcall GdipGetPathGradientCenterPoint(ptr ptr)
 @ stdcall GdipGetPathGradientCenterPointI(ptr ptr)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index e7ca874..1b806cd 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -105,6 +105,9 @@ struct GpPathGradient{
     BOOL gamma;
     GpPointF center;
     GpPointF focus;
+    REAL* blendfac;  /* blend factors */
+    REAL* blendpos;  /* blend positions */
+    INT blendcount;
 };
 
 struct GpLineGradient{
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index 70eac03..b8e91fc 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -54,6 +54,30 @@ static void test_type(void)
 
     GdipDeleteBrush((GpBrush*) brush);
 }
+static GpPointF blendcount_ptf[] = {{0.0, 0.0},
+                                    {50.0, 50.0}};
+static void test_gradientblendcount(void)
+{
+    GpStatus status;
+    GpPathGradient *brush;
+    INT count;
+
+    status = GdipCreatePathGradient(blendcount_ptf, 2, WrapModeClamp, &brush);
+    expect(Ok, status);
+
+    status = GdipGetPathGradientBlendCount(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetPathGradientBlendCount(NULL, &count);
+    expect(InvalidParameter, status);
+    status = GdipGetPathGradientBlendCount(brush, NULL);
+    expect(InvalidParameter, status);
+
+    status = GdipGetPathGradientBlendCount(brush, &count);
+    expect(Ok, status);
+    expect(1, count);
+
+    GdipDeleteBrush((GpBrush*) brush);
+}
 
 START_TEST(brush)
 {
@@ -69,6 +93,7 @@ START_TEST(brush)
 
     test_constructor_destructor();
     test_type();
+    test_gradientblendcount();
 
     GdiplusShutdown(gdiplusToken);
 }
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index b2ca34b..98d687a 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -199,6 +199,7 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient*,GpWrapMode*);
 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient*,GpRectF*);
 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient*,GpRect*);
 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient*,ARGB*);
+GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient*,INT*);
 GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient*,ARGB*);
 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient*,GpPointF*);
 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient*,GpPoint*);




More information about the wine-cvs mailing list