[try7][Gdiplus 06/10] Implement GdipCombineRegionRect
Adam Petaccia
adam at tpetaccia.com
Mon Aug 4 12:56:49 CDT 2008
Changelog:
(try5):
Shut up a compiler warning about possible uninitialized use
(try4):
Use a new helper function: fuse_region
region->node is no longer a pointer; find a better name for tmp
Update to new naming scheme
---
dlls/gdiplus/region.c | 52 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index 43efc77..1ad6bb4 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -207,6 +207,20 @@ clone_out:
return stat;
}
+/* Common code for CombineRegion*
+ * All the caller has to do is get its format into an element
+ */
+static inline void fuse_region(GpRegion* region, region_element* left,
+ region_element* right, const CombineMode mode)
+{
+ region->node.type = mode;
+ region->node.elementdata.combine.left = left;
+ region->node.elementdata.combine.right = right;
+
+ region->header.size = sizeheader_size + get_element_size(®ion->node);
+ region->header.num_children += 2;
+}
+
/*****************************************************************************
* GdipCloneRegion [GDIPLUS.@]
*
@@ -244,11 +258,41 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
return NotImplemented;
}
-GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region, GDIPCONST GpRectF *rect,
- CombineMode mode)
+GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
+ GDIPCONST GpRectF *rect, CombineMode mode)
{
- FIXME("(%p %p %d): stub\n", region, rect, mode);
- return NotImplemented;
+ GpRegion *rect_region;
+ region_element *left, *right = NULL;
+ GpStatus stat;
+
+ TRACE("%p %p %d\n", region, rect, mode);
+
+ if (!(region && rect))
+ return InvalidParameter;
+
+ stat = GdipCreateRegionRect(rect, &rect_region);
+ if (stat != Ok)
+ return stat;
+
+ left = GdipAlloc(sizeof(region_element));
+ if (!left)
+ goto out;
+ memcpy(left, ®ion->node, sizeof(region_element));
+
+ stat = clone_element(&rect_region->node, &right);
+ if (stat != Ok)
+ goto out;
+
+ fuse_region(region, left, right, mode);
+
+ GdipDeleteRegion(rect_region);
+ return Ok;
+
+out:
+ GdipFree(left);
+ delete_element(right);
+ GdipDeleteRegion(rect_region);
+ return stat;
}
GpStatus WINGDIPAPI GdipCombineRegionRectI(GpRegion *region, GDIPCONST GpRect *rect,
--
1.5.4.3
More information about the wine-patches
mailing list