Adam Petaccia : gdiplus: Implement GdipCloneRegion.

Alexandre Julliard julliard at winehq.org
Tue Aug 5 07:26:23 CDT 2008


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

Author: Adam Petaccia <adam at tpetaccia.com>
Date:   Mon Aug  4 13:56:45 2008 -0400

gdiplus: Implement GdipCloneRegion.

---

 dlls/gdiplus/region.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index fb658fd..26b166e 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -162,15 +162,78 @@ static inline void delete_element(region_element* element)
     }
 }
 
+static inline GpStatus clone_element(const region_element* element,
+        region_element** element2)
+{
+    GpStatus stat;
+
+    *element2 = GdipAlloc(sizeof(region_element));
+    if (!*element2)
+        return OutOfMemory;
+
+    (*element2)->type = element->type;
+
+    switch (element->type)
+    {
+        case RegionDataRect:
+            (*element2)->elementdata.rect = element->elementdata.rect;
+            break;
+        case RegionDataEmptyRect:
+        case RegionDataInfiniteRect:
+            break;
+        case RegionDataPath:
+            (*element2)->elementdata.pathdata.pathheader = element->elementdata.pathdata.pathheader;
+            stat = GdipClonePath(element->elementdata.pathdata.path,
+                    &(*element2)->elementdata.pathdata.path);
+            if (stat != Ok) goto clone_out;
+            break;
+        default:
+            stat = clone_element(element->elementdata.combine.left,
+                    &(*element2)->elementdata.combine.left);
+            if (stat != Ok) goto clone_out;
+            stat = clone_element(element->elementdata.combine.right,
+                    &(*element2)->elementdata.combine.right);
+            if (stat != Ok) goto clone_out;
+            break;
+    }
+
+    return Ok;
+
+clone_out:
+    delete_element(*element2);
+    *element2 = NULL;
+    return stat;
+}
+
 /*****************************************************************************
  * GdipCloneRegion [GDIPLUS.@]
+ *
+ * Creates a deep copy of the region
+ *
+ * PARAMS
+ *  region  [I] source region
+ *  clone   [O] resulting clone
+ *
+ * RETURNS
+ *  SUCCESS: Ok
+ *  FAILURE: InvalidParameter or OutOfMemory
  */
 GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
 {
-    FIXME("(%p %p): stub\n", region, clone);
+    region_element *element;
 
-    *clone = NULL;
-    return NotImplemented;
+    TRACE("%p %p\n", region, clone);
+
+    if (!(region && clone))
+        return InvalidParameter;
+
+    *clone = GdipAlloc(sizeof(GpRegion));
+    if (!*clone)
+        return OutOfMemory;
+    element = &(*clone)->node;
+
+    (*clone)->header = region->header;
+    return clone_element(&region->node, &element);
 }
 
 GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, CombineMode mode)




More information about the wine-cvs mailing list