Dmitry Timoshkov : gdiplus: Create GDI bitmap only when needed.

Alexandre Julliard julliard at winehq.org
Mon Mar 12 11:59:55 CDT 2012


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Sun Mar 11 14:58:08 2012 +0800

gdiplus: Create GDI bitmap only when needed.

---

 dlls/gdiplus/brush.c           |   11 -----------
 dlls/gdiplus/gdiplus_private.h |    1 -
 dlls/gdiplus/graphics.c        |    9 +++++----
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index ca4d8eb..0b326ed 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -47,15 +47,9 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
     switch(brush->bt){
         case BrushTypeSolidColor:
         {
-            GpSolidFill *fill;
             *clone = GdipAlloc(sizeof(GpSolidFill));
             if (!*clone) return OutOfMemory;
-
-            fill = (GpSolidFill*)*clone;
-
             memcpy(*clone, brush, sizeof(GpSolidFill));
-
-            fill->bmp = ARGB2BMP(fill->color);
             break;
         }
         case BrushTypeHatchFill:
@@ -654,7 +648,6 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
 
     (*sf)->brush.bt = BrushTypeSolidColor;
     (*sf)->color = color;
-    (*sf)->bmp = ARGB2BMP(color);
 
     TRACE("<-- %p\n", *sf);
 
@@ -899,10 +892,6 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
             GdipFree(((GpPathGradient*) brush)->blendfac);
             GdipFree(((GpPathGradient*) brush)->blendpos);
             break;
-        case BrushTypeSolidColor:
-            if (((GpSolidFill*)brush)->bmp)
-                DeleteObject(((GpSolidFill*)brush)->bmp);
-            break;
         case BrushTypeLinearGradient:
             GdipFree(((GpLineGradient*)brush)->blendfac);
             GdipFree(((GpLineGradient*)brush)->blendpos);
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 2a5fe69..2081290 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -183,7 +183,6 @@ struct GpHatch{
 struct GpSolidFill{
     GpBrush brush;
     ARGB color;
-    HBITMAP bmp;
 };
 
 struct GpPathGradient{
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index d300f59..fee6935 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -847,7 +847,9 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
     case BrushTypeSolidColor:
     {
         GpSolidFill *fill = (GpSolidFill*)brush;
-        if (fill->bmp)
+        HBITMAP bmp = ARGB2BMP(fill->color);
+
+        if (bmp)
         {
             RECT rc;
             /* partially transparent fill */
@@ -856,12 +858,11 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
             if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
             {
                 HDC hdc = CreateCompatibleDC(NULL);
-                HBITMAP oldbmp;
                 BLENDFUNCTION bf;
 
                 if (!hdc) break;
 
-                oldbmp = SelectObject(hdc, fill->bmp);
+                SelectObject(hdc, bmp);
 
                 bf.BlendOp = AC_SRC_OVER;
                 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);
 
-                SelectObject(hdc, oldbmp);
                 DeleteDC(hdc);
             }
 
+            DeleteObject(bmp);
             break;
         }
         /* else fall through */




More information about the wine-cvs mailing list