gdiplus: Create GDI bitmap only when needed.

This commit is contained in:
Dmitry Timoshkov 2012-03-11 14:58:08 +08:00 committed by Alexandre Julliard
parent 495a0cba3d
commit b39425f3cf
3 changed files with 5 additions and 16 deletions

View File

@ -47,15 +47,9 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
switch(brush->bt){ switch(brush->bt){
case BrushTypeSolidColor: case BrushTypeSolidColor:
{ {
GpSolidFill *fill;
*clone = GdipAlloc(sizeof(GpSolidFill)); *clone = GdipAlloc(sizeof(GpSolidFill));
if (!*clone) return OutOfMemory; if (!*clone) return OutOfMemory;
fill = (GpSolidFill*)*clone;
memcpy(*clone, brush, sizeof(GpSolidFill)); memcpy(*clone, brush, sizeof(GpSolidFill));
fill->bmp = ARGB2BMP(fill->color);
break; break;
} }
case BrushTypeHatchFill: case BrushTypeHatchFill:
@ -654,7 +648,6 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
(*sf)->brush.bt = BrushTypeSolidColor; (*sf)->brush.bt = BrushTypeSolidColor;
(*sf)->color = color; (*sf)->color = color;
(*sf)->bmp = ARGB2BMP(color);
TRACE("<-- %p\n", *sf); TRACE("<-- %p\n", *sf);
@ -899,10 +892,6 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
GdipFree(((GpPathGradient*) brush)->blendfac); GdipFree(((GpPathGradient*) brush)->blendfac);
GdipFree(((GpPathGradient*) brush)->blendpos); GdipFree(((GpPathGradient*) brush)->blendpos);
break; break;
case BrushTypeSolidColor:
if (((GpSolidFill*)brush)->bmp)
DeleteObject(((GpSolidFill*)brush)->bmp);
break;
case BrushTypeLinearGradient: case BrushTypeLinearGradient:
GdipFree(((GpLineGradient*)brush)->blendfac); GdipFree(((GpLineGradient*)brush)->blendfac);
GdipFree(((GpLineGradient*)brush)->blendpos); GdipFree(((GpLineGradient*)brush)->blendpos);

View File

@ -183,7 +183,6 @@ struct GpHatch{
struct GpSolidFill{ struct GpSolidFill{
GpBrush brush; GpBrush brush;
ARGB color; ARGB color;
HBITMAP bmp;
}; };
struct GpPathGradient{ struct GpPathGradient{

View File

@ -847,7 +847,9 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
case BrushTypeSolidColor: case BrushTypeSolidColor:
{ {
GpSolidFill *fill = (GpSolidFill*)brush; GpSolidFill *fill = (GpSolidFill*)brush;
if (fill->bmp) HBITMAP bmp = ARGB2BMP(fill->color);
if (bmp)
{ {
RECT rc; RECT rc;
/* partially transparent fill */ /* partially transparent fill */
@ -856,12 +858,11 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
if (GetClipBox(graphics->hdc, &rc) != NULLREGION) if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
{ {
HDC hdc = CreateCompatibleDC(NULL); HDC hdc = CreateCompatibleDC(NULL);
HBITMAP oldbmp;
BLENDFUNCTION bf; BLENDFUNCTION bf;
if (!hdc) break; if (!hdc) break;
oldbmp = SelectObject(hdc, fill->bmp); SelectObject(hdc, bmp);
bf.BlendOp = AC_SRC_OVER; bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0; bf.BlendFlags = 0;
@ -870,10 +871,10 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
GdiAlphaBlend(graphics->hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, 1, 1, bf); GdiAlphaBlend(graphics->hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, 1, 1, bf);
SelectObject(hdc, oldbmp);
DeleteDC(hdc); DeleteDC(hdc);
} }
DeleteObject(bmp);
break; break;
} }
/* else fall through */ /* else fall through */