[PATCH 2/2] gdiplus: Preserve temp DC state for bitmap backed graphics objects.

Shawn M. Chapla schapla at codeweavers.com
Fri Jun 19 12:21:17 CDT 2020


Signed-off-by: Shawn M. Chapla <schapla at codeweavers.com>
---
 dlls/gdiplus/graphics.c       | 18 +++++++++++++++---
 dlls/gdiplus/tests/graphics.c |  2 +-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 6619be9b58..aab4fa0604 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -2536,6 +2536,12 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
             return stat;
     }
 
+    if (graphics->temp_hdc)
+    {
+        DeleteDC(graphics->temp_hdc);
+        graphics->temp_hdc = NULL;
+    }
+
     if(graphics->owndc)
         ReleaseDC(graphics->hwnd, graphics->hdc);
 
@@ -6662,7 +6668,15 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
         if (!hbitmap)
             return GenericError;
 
-        temp_hdc = CreateCompatibleDC(0);
+        if (!graphics->temp_hdc)
+        {
+            temp_hdc = CreateCompatibleDC(0);
+        }
+        else
+        {
+            temp_hdc = graphics->temp_hdc;
+        }
+
         if (!temp_hdc)
         {
             DeleteObject(hbitmap);
@@ -6723,9 +6737,7 @@ GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
             graphics->temp_hbitmap_width * 4, PixelFormat32bppARGB);
 
         /* Clean up. */
-        DeleteDC(graphics->temp_hdc);
         DeleteObject(graphics->temp_hbitmap);
-        graphics->temp_hdc = NULL;
         graphics->temp_hbitmap = NULL;
     }
     else if (hdc != graphics->hdc)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 7040327e67..da15392732 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -6870,7 +6870,7 @@ static void test_gdi_interop(void)
 
     stat = GdipBitmapGetPixel(bitmap, 26, 26, &color);
     expect(Ok, stat);
-    todo_wine expect(0xff0000ff, color);
+    expect(0xff0000ff, color);
 
     stat = GdipBitmapGetPixel(bitmap, 86, 86, &color);
     expect(Ok, stat);
-- 
2.27.0




More information about the wine-devel mailing list