Vincent Povirk : gdiplus: Store an image in texture brushes, and use it when cloning.

Alexandre Julliard julliard at winehq.org
Mon Feb 15 10:06:11 CST 2010


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu Feb 11 16:43:45 2010 -0600

gdiplus: Store an image in texture brushes, and use it when cloning.

---

 dlls/gdiplus/brush.c           |   25 ++++++++++++++++++-------
 dlls/gdiplus/gdiplus_private.h |    1 +
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index a533aca..4d36de2 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -160,13 +160,23 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
             break;
         }
         case BrushTypeTextureFill:
-            *clone = GdipAlloc(sizeof(GpTexture));
-            if(!*clone)    return OutOfMemory;
+        {
+            GpStatus stat;
+            GpTexture *texture = (GpTexture*)brush;
+            GpTexture *new_texture;
 
-            memcpy(*clone, brush, sizeof(GpTexture));
+            stat = GdipCreateTexture(texture->image, texture->wrap, &new_texture);
 
-            (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
-            break;
+            if (stat == Ok)
+            {
+                memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix));
+                *clone = (GpBrush*)new_texture;
+            }
+            else
+                *clone = NULL;
+
+            return stat;
+        }
         default:
             ERR("not implemented for brush type %d\n", brush->bt);
             return NotImplemented;
@@ -829,10 +839,9 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
     (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
     (*texture)->brush.bt = BrushTypeTextureFill;
     (*texture)->wrap = imageattr->wrap;
+    (*texture)->image = new_image;
 
 exit:
-    GdipDisposeImage(new_image);
-
     if (status == Ok)
     {
         TRACE("<-- %p\n", *texture);
@@ -845,6 +854,7 @@ exit:
             GdipFree(*texture);
             *texture = NULL;
         }
+        GdipDisposeImage(new_image);
         TRACE("<-- error %u\n", status);
     }
 
@@ -946,6 +956,7 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
             break;
         case BrushTypeTextureFill:
             GdipDeleteMatrix(((GpTexture*)brush)->transform);
+            GdipDisposeImage(((GpTexture*)brush)->image);
             break;
         default:
             break;
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 75dc8c6..8e26eb1 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -180,6 +180,7 @@ struct GpLineGradient{
 struct GpTexture{
     GpBrush brush;
     GpMatrix *transform;
+    GpImage *image;
     WrapMode wrap;  /* not used yet */
 };
 




More information about the wine-cvs mailing list