Signed-off-by: Shawn M. Chapla schapla@codeweavers.com --- dlls/gdiplus/tests/graphics.c | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index f2ff589ab5..7040327e67 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -6792,6 +6792,97 @@ static void test_hdc_caching(void) DeleteObject(hbm); }
+static void test_gdi_interop(void) +{ + GpBitmap *bitmap; + GpGraphics *graphics; + GpMatrix *transform; + GpBrush *brush; + GpStatus stat; + HDC hdc; + HBRUSH hbrush, holdbrush; + ARGB color; + + stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap); + expect(Ok, stat); + + stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, stat); + + stat = GdipCreateMatrix(&transform); + expect(Ok, stat); + + stat = GdipSetMatrixElements(transform, 1.0, 0.0, 0.0, 1.0, 50.0, 50.0); + expect(Ok, stat); + + /* GDI+: Set world transform. Should not matter to GDI. */ + stat = GdipSetWorldTransform(graphics, transform); + expect(Ok, stat); + + stat = GdipGetDC(graphics, &hdc); + expect(Ok, stat); + + hbrush = CreateSolidBrush(0xff0000); + + holdbrush = SelectObject(hdc, hbrush); + + /* GDI: Draw a rectangle at physical coords (5, 5) to (12, 10). */ + Rectangle(hdc, 5, 5, 12, 10); + + holdbrush = SelectObject(hdc, holdbrush); + + /* GDI: Set view port origin. Should not matter to GDI+. */ + SetViewportOrgEx(hdc, 20, 20, NULL); + + GdipReleaseDC(graphics, hdc); + + stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush); + expect(Ok, stat); + + /* GDI+: Draw a rectangle at physical coords (85, 85) to (88, 95). */ + stat = GdipFillRectangleI(graphics, brush, 35, 35, 3, 10); + expect(Ok, stat); + + stat = GdipDeleteBrush(brush); + expect(Ok, stat); + + stat = GdipGetDC(graphics, &hdc); + expect(Ok, stat); + + holdbrush = SelectObject(hdc, hbrush); + + /* GDI: Draw a rectangle at physical coords (25, 25) to (30, 34). + Updated view port origin should still be in effect. */ + Rectangle(hdc, 5, 5, 10, 14); + + SelectObject(hdc, holdbrush); + + DeleteObject(hbrush); + stat = GdipReleaseDC(graphics, hdc); + expect(Ok, stat); + + stat = GdipDeleteMatrix(transform); + expect(Ok, stat); + + stat = GdipBitmapGetPixel(bitmap, 6, 6, &color); + expect(Ok, stat); + expect(0xff0000ff, color); + + stat = GdipBitmapGetPixel(bitmap, 26, 26, &color); + expect(Ok, stat); + todo_wine expect(0xff0000ff, color); + + stat = GdipBitmapGetPixel(bitmap, 86, 86, &color); + expect(Ok, stat); + expect(0xff0000ff, color); + + stat = GdipDeleteGraphics(graphics); + expect(Ok, stat); + + stat = GdipDisposeImage((GpImage*)bitmap); + expect(Ok, stat); +} + START_TEST(graphics) { struct GdiplusStartupInput gdiplusStartupInput; @@ -6885,6 +6976,7 @@ START_TEST(graphics) test_GdipGraphicsSetAbort(); test_cliphrgn_transform(); test_hdc_caching(); + test_gdi_interop();
GdiplusShutdown(gdiplusToken); DestroyWindow( hwnd );
Signed-off-by: Shawn M. Chapla schapla@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);
Signed-off-by: Esme Povirk vincent@codeweavers.com