gdiplus: Allow excluding from infinite regions.

Vincent Povirk madewokherd at gmail.com
Fri Nov 15 12:53:20 CST 2013


-------------- next part --------------
From 06ffd4b32854ea9fa801a73f9a0d829cc4c94d49 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 30 Oct 2013 11:46:30 -0500
Subject: [PATCH 1/3] gdiplus: Allow excluding from infinite regions.

---
 dlls/gdiplus/region.c       |  8 +++----
 dlls/gdiplus/tests/region.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index 5d95fcd..9d95629 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -987,8 +987,8 @@ static GpStatus get_region_hrgn(struct region_element *element, GpGraphics *grap
                     case CombineModeIntersect:
                         return get_region_hrgn(element->elementdata.combine.right, graphics, hrgn);
                     case CombineModeXor: case CombineModeExclude:
-                        FIXME("cannot exclude from an infinite region\n");
-                        /* fall-through */
+                        left = CreateRectRgn(-4194304, -4194304, 4194304, 4194304);
+                        break;
                     case CombineModeUnion: case CombineModeComplement:
                         *hrgn = NULL;
                         return Ok;
@@ -1012,8 +1012,8 @@ static GpStatus get_region_hrgn(struct region_element *element, GpGraphics *grap
                         *hrgn = left;
                         return Ok;
                     case CombineModeXor: case CombineModeComplement:
-                        FIXME("cannot exclude from an infinite region\n");
-                        /* fall-through */
+                        right = CreateRectRgn(-4194304, -4194304, 4194304, 4194304);
+                        break;
                     case CombineModeUnion: case CombineModeExclude:
                         DeleteObject(left);
                         *hrgn = NULL;
diff --git a/dlls/gdiplus/tests/region.c b/dlls/gdiplus/tests/region.c
index 66d950a..5632e4d 100644
--- a/dlls/gdiplus/tests/region.c
+++ b/dlls/gdiplus/tests/region.c
@@ -2082,6 +2082,56 @@ static void test_isvisiblerect(void)
     ReleaseDC(0, hdc);
 }
 
+static void test_excludeinfinite(void)
+{
+    GpStatus status;
+    GpRegion *region;
+    UINT count=0xdeadbeef;
+    GpRectF scans[4];
+    GpMatrix *identity;
+    static const RectF rect_exclude = {0.0, 0.0, 1.0, 1.0};
+
+    status = GdipCreateMatrix(&identity);
+    expect(Ok, status);
+
+    status = GdipCreateRegion(&region);
+    expect(Ok, status);
+
+    status = GdipCombineRegionRect(region, &rect_exclude, CombineModeExclude);
+    expect(Ok, status);
+
+    status = GdipGetRegionScansCount(region, &count, identity);
+    expect(Ok, status);
+    expect(4, count);
+
+    count = 4;
+    status = GdipGetRegionScans(region, scans, (INT*)&count, identity);
+    expect(Ok, status);
+
+    expectf(-4194304.0, scans[0].X);
+    expectf(-4194304.0, scans[0].Y);
+    expectf(8388608.0, scans[0].Width);
+    expectf(4194304.0, scans[0].Height);
+
+    expectf(-4194304.0, scans[1].X);
+    expectf(0.0, scans[1].Y);
+    expectf(4194304.0, scans[1].Width);
+    expectf(1.0, scans[1].Height);
+
+    expectf(1.0, scans[2].X);
+    expectf(0.0, scans[2].Y);
+    expectf(4194303.0, scans[2].Width);
+    expectf(1.0, scans[2].Height);
+
+    expectf(-4194304.0, scans[3].X);
+    expectf(1.0, scans[3].Y);
+    expectf(8388608.0, scans[3].Width);
+    expectf(4194303.0, scans[3].Height);
+
+    GdipDeleteRegion(region);
+    GdipDeleteMatrix(identity);
+}
+
 START_TEST(region)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -2107,6 +2157,7 @@ START_TEST(region)
     test_getbounds();
     test_isvisiblepoint();
     test_isvisiblerect();
+    test_excludeinfinite();
 
     GdiplusShutdown(gdiplusToken);
 }
-- 
1.8.1.2


More information about the wine-patches mailing list