Commit fb62d061 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Fix for CombineModeReplace with some tests.

parent b8711acb
...@@ -242,6 +242,13 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin ...@@ -242,6 +242,13 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
if (stat != Ok) if (stat != Ok)
return stat; return stat;
/* simply replace region data */
if(mode == CombineModeReplace){
delete_element(&region->node);
memcpy(region, path_region, sizeof(GpRegion));
return Ok;
}
left = GdipAlloc(sizeof(region_element)); left = GdipAlloc(sizeof(region_element));
if (!left) if (!left)
goto out; goto out;
...@@ -279,6 +286,13 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region, ...@@ -279,6 +286,13 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
if (stat != Ok) if (stat != Ok)
return stat; return stat;
/* simply replace region data */
if(mode == CombineModeReplace){
delete_element(&region->node);
memcpy(region, rect_region, sizeof(GpRegion));
return Ok;
}
left = GdipAlloc(sizeof(region_element)); left = GdipAlloc(sizeof(region_element));
if (!left) if (!left)
goto out; goto out;
...@@ -323,12 +337,23 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1, ...@@ -323,12 +337,23 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
{ {
region_element *left, *right = NULL; region_element *left, *right = NULL;
GpStatus stat; GpStatus stat;
GpRegion *reg2copy;
TRACE("%p %p %d\n", region1, region2, mode); TRACE("%p %p %d\n", region1, region2, mode);
if(!(region1 && region2)) if(!(region1 && region2))
return InvalidParameter; return InvalidParameter;
/* simply replace region data */
if(mode == CombineModeReplace){
stat = GdipCloneRegion(region2, &reg2copy);
if(stat != Ok) return stat;
delete_element(&region1->node);
memcpy(region1, reg2copy, sizeof(GpRegion));
return Ok;
}
left = GdipAlloc(sizeof(region_element)); left = GdipAlloc(sizeof(region_element));
if (!left) if (!left)
return OutOfMemory; return OutOfMemory;
......
...@@ -553,10 +553,11 @@ static void test_isempty(void) ...@@ -553,10 +553,11 @@ static void test_isempty(void)
static void test_combinereplace(void) static void test_combinereplace(void)
{ {
GpStatus status; GpStatus status;
GpRegion *region; GpRegion *region, *region2;
GpPath *path;
GpRectF rectf; GpRectF rectf;
UINT needed; UINT needed;
DWORD buf[10]; DWORD buf[50];
rectf.X = rectf.Y = 0.0; rectf.X = rectf.Y = 0.0;
rectf.Width = rectf.Height = 100.0; rectf.Width = rectf.Height = 100.0;
...@@ -570,15 +571,82 @@ static void test_combinereplace(void) ...@@ -570,15 +571,82 @@ static void test_combinereplace(void)
status = GdipGetRegionDataSize(region, &needed); status = GdipGetRegionDataSize(region, &needed);
expect(Ok, status); expect(Ok, status);
todo_wine expect(36, needed); expect(36, needed);
status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
expect(Ok, status);
expect(36, needed);
expect_dword(buf, 28);
trace("buf[1] = %08x\n", buf[1]);
expect_magic((DWORD*)(buf + 2));
expect_dword(buf + 3, 0);
expect_dword(buf + 4, RGNDATA_RECT);
/* replace with path */
status = GdipCreatePath(FillModeAlternate, &path);
expect(Ok, status);
status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
expect(Ok, status);
status = GdipCombineRegionPath(region, path, CombineModeReplace);
expect(Ok, status);
status = GdipGetRegionDataSize(region, &needed);
expect(Ok, status);
expect(156, needed);
status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
expect(Ok, status);
expect(156, needed);
expect_dword(buf, 148);
trace("buf[1] = %08x\n", buf[1]);
expect_magic((DWORD*)(buf + 2));
expect_dword(buf + 3, 0);
expect_dword(buf + 4, RGNDATA_PATH);
GdipDeletePath(path);
/* replace with infinite rect */
status = GdipCreateRegion(&region2);
expect(Ok, status);
status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
expect(Ok, status);
status = GdipGetRegionDataSize(region, &needed);
expect(Ok, status);
expect(20, needed);
status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
expect(Ok, status);
expect(20, needed);
expect_dword(buf, 12);
trace("buf[1] = %08x\n", buf[1]);
expect_magic((DWORD*)(buf + 2));
expect_dword(buf + 3, 0);
expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
GdipDeletePath(path);
GdipDeleteRegion(region2);
/* more complex case : replace with a combined region */
status = GdipCreateRegionRect(&rectf, &region2);
expect(Ok, status);
status = GdipCreatePath(FillModeAlternate, &path);
expect(Ok, status);
status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
expect(Ok, status);
status = GdipCombineRegionPath(region2, path, CombineModeUnion);
expect(Ok, status);
GdipDeletePath(path);
status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
expect(Ok, status);
GdipDeleteRegion(region2);
status = GdipGetRegionDataSize(region, &needed);
expect(Ok, status);
expect(180, needed);
status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed); status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
expect(Ok, status); expect(Ok, status);
todo_wine expect(36, needed); expect(180, needed);
todo_wine expect_dword(buf, 28); expect_dword(buf, 172);
trace("buf[1] = %08x\n", buf[1]); trace("buf[1] = %08x\n", buf[1]);
expect_magic((DWORD*)(buf + 2)); expect_magic((DWORD*)(buf + 2));
todo_wine expect_dword(buf + 3, 0); expect_dword(buf + 3, 2);
todo_wine expect_dword(buf + 4, RGNDATA_RECT); expect_dword(buf + 4, CombineModeUnion);
GdipDeleteRegion(region); GdipDeleteRegion(region);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment