From 70c9e4fb3d6811ed3e8574768c13e2f2e70f3aad Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 11 Feb 2010 16:43:45 -0600 Subject: [PATCH] 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 a533aca8067..4d36de27f6e 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 75dc8c607c7..8e26eb18db9 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 */ };