Vincent Povirk : gdiplus: Implement GdipGetRegionScans.

Alexandre Julliard julliard at winehq.org
Thu Oct 28 12:19:52 CDT 2010


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu Sep 30 15:38:03 2010 -0500

gdiplus: Implement GdipGetRegionScans.

---

 dlls/gdiplus/gdiplus.spec   |    4 +-
 dlls/gdiplus/region.c       |   68 +++++++++++++++++++++++++++++++++++++
 dlls/gdiplus/tests/region.c |   79 +++++++++++++++++++++++++++++++++++++++++++
 include/gdiplusflat.h       |    2 +
 4 files changed, 151 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index b529d0d..6721c01 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -380,9 +380,9 @@
 @ stdcall GdipGetRegionData(ptr ptr long ptr)
 @ stdcall GdipGetRegionDataSize(ptr ptr)
 @ stdcall GdipGetRegionHRgn(ptr ptr ptr)
-@ stub GdipGetRegionScans
+@ stdcall GdipGetRegionScans(ptr ptr ptr ptr)
 @ stdcall GdipGetRegionScansCount(ptr ptr ptr)
-@ stub GdipGetRegionScansI
+@ stdcall GdipGetRegionScansI(ptr ptr ptr ptr)
 @ stdcall GdipGetRenderingOrigin(ptr ptr ptr)
 @ stdcall GdipGetSmoothingMode(ptr ptr)
 @ stdcall GdipGetSolidFillColor(ptr ptr)
diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index 2e895a8..e9f2d9a 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -1441,3 +1441,71 @@ GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMat
 
     return stat;
 }
+
+GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *region, GpRect *scans, INT *count, GpMatrix *matrix)
+{
+    GpStatus stat;
+    INT i;
+    LPRGNDATA data;
+    RECT *rects;
+
+    if (!region || !count || !matrix)
+        return InvalidParameter;
+
+    stat = get_region_scans_data(region, matrix, &data);
+
+    if (stat == Ok)
+    {
+        *count = data->rdh.nCount;
+        rects = (RECT*)&data->Buffer;
+
+        if (scans)
+        {
+            for (i=0; i<data->rdh.nCount; i++)
+            {
+                scans[i].X = rects[i].left;
+                scans[i].Y = rects[i].top;
+                scans[i].Width = rects[i].right - rects[i].left;
+                scans[i].Height = rects[i].bottom - rects[i].top;
+            }
+        }
+
+        GdipFree(data);
+    }
+
+    return Ok;
+}
+
+GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *region, GpRectF *scans, INT *count, GpMatrix *matrix)
+{
+    GpStatus stat;
+    INT i;
+    LPRGNDATA data;
+    RECT *rects;
+
+    if (!region || !count || !matrix)
+        return InvalidParameter;
+
+    stat = get_region_scans_data(region, matrix, &data);
+
+    if (stat == Ok)
+    {
+        *count = data->rdh.nCount;
+        rects = (RECT*)&data->Buffer;
+
+        if (scans)
+        {
+            for (i=0; i<data->rdh.nCount; i++)
+            {
+                scans[i].X = rects[i].left;
+                scans[i].Y = rects[i].top;
+                scans[i].Width = rects[i].right - rects[i].left;
+                scans[i].Height = rects[i].bottom - rects[i].top;
+            }
+        }
+
+        GdipFree(data);
+    }
+
+    return Ok;
+}
diff --git a/dlls/gdiplus/tests/region.c b/dlls/gdiplus/tests/region.c
index 9d48b25..3052f2e 100644
--- a/dlls/gdiplus/tests/region.c
+++ b/dlls/gdiplus/tests/region.c
@@ -22,6 +22,7 @@
 #include "gdiplus.h"
 #include "wingdi.h"
 #include "wine/test.h"
+#include <math.h>
 
 #define RGNDATA_RECT            0x10000000
 #define RGNDATA_PATH            0x10000001
@@ -33,6 +34,9 @@
 
 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 
+#define expectf_(expected, got, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
+#define expectf(expected, got) expectf_(expected, got, 0.0001)
+
 #define expect_magic(value) ok(*value == RGNDATA_MAGIC || *value == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *value)
 
 #define expect_dword(value, expected) ok(*(value) == expected, "expected %08x got %08x\n", expected, *(value))
@@ -1237,6 +1241,9 @@ static void test_scans(void)
     GpRectF rectf;
     GpStatus status;
     ULONG count=80085;
+    INT icount;
+    GpRectF scans[2];
+    GpRect scansi[2];
 
     status = GdipCreateRegion(&region);
     expect(Ok, status);
@@ -1254,11 +1261,44 @@ static void test_scans(void)
     status = GdipGetRegionScansCount(region, &count, NULL);
     expect(InvalidParameter, status);
 
+    status = GdipGetRegionScans(NULL, scans, &icount, matrix);
+    expect(InvalidParameter, status);
+
+    status = GdipGetRegionScans(region, scans, NULL, matrix);
+    expect(InvalidParameter, status);
+
+    status = GdipGetRegionScans(region, scans, &icount, NULL);
+    expect(InvalidParameter, status);
+
     /* infinite */
     status = GdipGetRegionScansCount(region, &count, matrix);
     expect(Ok, status);
     expect(1, count);
 
+    status = GdipGetRegionScans(region, NULL, &icount, matrix);
+    expect(Ok, status);
+    expect(1, icount);
+
+    status = GdipGetRegionScans(region, scans, &icount, matrix);
+    expect(Ok, status);
+    expect(1, icount);
+
+    status = GdipGetRegionScansI(region, scansi, &icount, matrix);
+    expect(Ok, status);
+    expect(1, icount);
+    expect(-0x400000, scansi[0].X);
+    expect(-0x400000, scansi[0].Y);
+    expect(0x800000, scansi[0].Width);
+    expect(0x800000, scansi[0].Height);
+
+    status = GdipGetRegionScans(region, scans, &icount, matrix);
+    expect(Ok, status);
+    expect(1, icount);
+    expectf((double)-0x400000, scans[0].X);
+    expectf((double)-0x400000, scans[0].Y);
+    expectf((double)0x800000, scans[0].Width);
+    expectf((double)0x800000, scans[0].Height);
+
     /* empty */
     status = GdipSetEmpty(region);
     expect(Ok, status);
@@ -1267,6 +1307,10 @@ static void test_scans(void)
     expect(Ok, status);
     expect(0, count);
 
+    status = GdipGetRegionScans(region, scans, &icount, matrix);
+    expect(Ok, status);
+    expect(0, icount);
+
     /* single rectangle */
     rectf.X = rectf.Y = 0.0;
     rectf.Width = rectf.Height = 5.0;
@@ -1277,6 +1321,14 @@ static void test_scans(void)
     expect(Ok, status);
     expect(1, count);
 
+    status = GdipGetRegionScans(region, scans, &icount, matrix);
+    expect(Ok, status);
+    expect(1, icount);
+    expectf(0.0, scans[0].X);
+    expectf(0.0, scans[0].Y);
+    expectf(5.0, scans[0].Width);
+    expectf(5.0, scans[0].Height);
+
     /* two rectangles */
     rectf.X = rectf.Y = 5.0;
     rectf.Width = rectf.Height = 5.0;
@@ -1287,6 +1339,33 @@ static void test_scans(void)
     expect(Ok, status);
     expect(2, count);
 
+    /* Native ignores the initial value of count */
+    scans[1].X = scans[1].Y = scans[1].Width = scans[1].Height = 8.0;
+    icount = 1;
+    status = GdipGetRegionScans(region, scans, &icount, matrix);
+    expect(Ok, status);
+    expect(2, icount);
+    expectf(0.0, scans[0].X);
+    expectf(0.0, scans[0].Y);
+    expectf(5.0, scans[0].Width);
+    expectf(5.0, scans[0].Height);
+    expectf(5.0, scans[1].X);
+    expectf(5.0, scans[1].Y);
+    expectf(5.0, scans[1].Width);
+    expectf(5.0, scans[1].Height);
+
+    status = GdipGetRegionScansI(region, scansi, &icount, matrix);
+    expect(Ok, status);
+    expect(2, icount);
+    expect(0, scansi[0].X);
+    expect(0, scansi[0].Y);
+    expect(5, scansi[0].Width);
+    expect(5, scansi[0].Height);
+    expect(5, scansi[1].X);
+    expect(5, scansi[1].Y);
+    expect(5, scansi[1].Width);
+    expect(5, scansi[1].Height);
+
     status = GdipDeleteRegion(region);
     expect(Ok, status);
     status = GdipDeleteMatrix(matrix);
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 76549e7..1a443f9 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -643,6 +643,8 @@ GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *, GpGraphics *, GpRect *);
 GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *, BYTE *, UINT, UINT *);
 GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *, UINT *);
 GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *, GpGraphics *, HRGN *);
+GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *, GpRectF *, INT *, GpMatrix *);
+GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *, GpRect *, INT *, GpMatrix *);
 GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *, UINT *, GpMatrix *);
 GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *, GpGraphics *, BOOL *);
 GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *, GpRegion *, GpGraphics *, BOOL *);




More information about the wine-cvs mailing list