From 1202e9af56521f7362e8e1183923ad8ec851949e Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 30 Oct 2013 11:46:30 -0500 Subject: [PATCH] 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 832ce69dc9f..4ba86eb73b8 100644 --- a/dlls/gdiplus/region.c +++ b/dlls/gdiplus/region.c @@ -988,8 +988,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; @@ -1013,8 +1013,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 66d950aea28..5632e4d6aaf 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(®ion); + 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); }