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

This commit is contained in:
Vincent Povirk 2010-02-11 16:43:45 -06:00 committed by Alexandre Julliard
parent 53e326a77c
commit 70c9e4fb3d
2 changed files with 19 additions and 7 deletions

View File

@ -160,13 +160,23 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
break; break;
} }
case BrushTypeTextureFill: 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); if (stat == Ok)
break; {
memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix));
*clone = (GpBrush*)new_texture;
}
else
*clone = NULL;
return stat;
}
default: default:
ERR("not implemented for brush type %d\n", brush->bt); ERR("not implemented for brush type %d\n", brush->bt);
return NotImplemented; return NotImplemented;
@ -829,10 +839,9 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
(*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb); (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
(*texture)->brush.bt = BrushTypeTextureFill; (*texture)->brush.bt = BrushTypeTextureFill;
(*texture)->wrap = imageattr->wrap; (*texture)->wrap = imageattr->wrap;
(*texture)->image = new_image;
exit: exit:
GdipDisposeImage(new_image);
if (status == Ok) if (status == Ok)
{ {
TRACE("<-- %p\n", *texture); TRACE("<-- %p\n", *texture);
@ -845,6 +854,7 @@ exit:
GdipFree(*texture); GdipFree(*texture);
*texture = NULL; *texture = NULL;
} }
GdipDisposeImage(new_image);
TRACE("<-- error %u\n", status); TRACE("<-- error %u\n", status);
} }
@ -946,6 +956,7 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
break; break;
case BrushTypeTextureFill: case BrushTypeTextureFill:
GdipDeleteMatrix(((GpTexture*)brush)->transform); GdipDeleteMatrix(((GpTexture*)brush)->transform);
GdipDisposeImage(((GpTexture*)brush)->image);
break; break;
default: default:
break; break;

View File

@ -180,6 +180,7 @@ struct GpLineGradient{
struct GpTexture{ struct GpTexture{
GpBrush brush; GpBrush brush;
GpMatrix *transform; GpMatrix *transform;
GpImage *image;
WrapMode wrap; /* not used yet */ WrapMode wrap; /* not used yet */
}; };