[2/2] gdiplus: implement GdipGetPathGradientBlend with basic tests

Nikolay Sivov bunglehead at gmail.com
Mon Jul 21 14:30:50 CDT 2008


Changelog:
    -   Implement GdipGetPathGradientBlend with basic tests

---
 dlls/gdiplus/brush.c       |   17 +++++++++++++++++
 dlls/gdiplus/gdiplus.spec  |    2 +-
 dlls/gdiplus/tests/brush.c |   37 +++++++++++++++++++++++++++++++++++++
 include/gdiplusflat.h      |    1 +
 4 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index f2aba86..b02952e 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -549,6 +549,23 @@ GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapm
     return Ok;
 }
 
+GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
+    REAL *positions, INT count)
+{
+    if(!brush || !blend || !positions || count <= 0)
+        return InvalidParameter;
+
+    if(count < brush->blendcount)
+        return InsufficientBuffer;
+
+    memcpy(blend, brush->blendfac, count*sizeof(REAL));
+    if(brush->blendcount > 1){
+        memcpy(positions, brush->blendpos, count*sizeof(REAL));
+    }
+
+    return Ok;
+}
+
 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
 {
     if(!brush || !count)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 9d609fa..4bfc93a 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -325,7 +325,7 @@
 @ stdcall GdipGetPageUnit(ptr ptr)
 @ stdcall GdipGetPathData(ptr ptr)
 @ stdcall GdipGetPathFillMode(ptr ptr)
-@ stub GdipGetPathGradientBlend
+@ stdcall GdipGetPathGradientBlend(ptr ptr ptr long)
 @ stdcall GdipGetPathGradientBlendCount(ptr ptr)
 @ stub GdipGetPathGradientCenterColor
 @ stdcall GdipGetPathGradientCenterPoint(ptr ptr)
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index b8e91fc..c23d7ff 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -21,8 +21,10 @@
 #include "windows.h"
 #include "gdiplus.h"
 #include "wine/test.h"
+#include <math.h>
 
 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
+#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
 
 static void test_constructor_destructor(void)
 {
@@ -79,6 +81,40 @@ static void test_gradientblendcount(void)
     GdipDeleteBrush((GpBrush*) brush);
 }
 
+static GpPointF getblend_ptf[] = {{0.0, 0.0},
+                                  {50.0, 50.0}};
+static void test_getblend(void)
+{
+    GpStatus status;
+    GpPathGradient *brush;
+    REAL blends[4];
+    REAL pos[4];
+
+    status = GdipCreatePathGradient(getblend_ptf, 2, WrapModeClamp, &brush);
+    expect(Ok, status);
+
+    /* check some invalid parameters combinations */
+    status = GdipGetPathGradientBlend(NULL, NULL,  NULL, -1);
+    expect(InvalidParameter, status);
+    status = GdipGetPathGradientBlend(brush,NULL,  NULL, -1);
+    expect(InvalidParameter, status);
+    status = GdipGetPathGradientBlend(NULL, blends,NULL, -1);
+    expect(InvalidParameter, status);
+    status = GdipGetPathGradientBlend(NULL, NULL,  pos,  -1);
+    expect(InvalidParameter, status);
+    status = GdipGetPathGradientBlend(NULL, NULL,  NULL,  1);
+    expect(InvalidParameter, status);
+    
+    blends[0] = (REAL)0xdeadbeef;
+    pos[0]    = (REAL)0xdeadbeef;
+    status = GdipGetPathGradientBlend(brush, blends, pos, 1);
+    expect(Ok, status);
+    expectf(1.0, blends[0]);
+    expectf((REAL)0xdeadbeef, pos[0]);
+
+    GdipDeleteBrush((GpBrush*) brush);    
+}
+
 START_TEST(brush)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -94,6 +130,7 @@ START_TEST(brush)
     test_constructor_destructor();
     test_type();
     test_gradientblendcount();
+    test_getblend();
 
     GdiplusShutdown(gdiplusToken);
 }
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 98d687a..8a683b7 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 GdipGetPathGradientBlend(GpPathGradient*,REAL*,REAL*,INT);
 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient*,INT*);
 GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient*,ARGB*);
 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient*,GpPointF*);
-- 
1.4.4.4






More information about the wine-patches mailing list