From: "Changhui Liu" Subject: [PATCH 1/3] gdiplus: fix get_graphics_bounds when window origin point changed Message-Id: Date: Tue, 23 Dec 2014 13:26:39 +0800 ------------------ Regards.






------------------
Regards.
 
From ea46b3619b3dc4746cde4032539c97ab635e764e Mon Sep 17 00:00:00 2001 From: Changhui Liu Date: Mon, 22 Dec 2014 16:43:47 +0800 Subject: gdiplus: fix get_graphics_bounds when window origin point changed To: wine-patches Reply-To: wine-devel --- dlls/gdiplus/graphics.c | 3 +-- dlls/gdiplus/tests/graphics.c | 57 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 840d866..68a4ee5 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2029,8 +2029,7 @@ static GpStatus get_graphics_bounds(GpGraphics* graphics, GpRectF* rect) rect->Height = GetDeviceCaps(graphics->hdc, VERTRES); } - if (graphics->hdc && - (GetMapMode(graphics->hdc) != MM_TEXT || GetGraphicsMode(graphics->hdc) != GM_COMPATIBLE)) + if (graphics->hdc) { POINT points[2]; diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index bd227dc..395c04b 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -5548,6 +5548,61 @@ static void test_GdipFillRectangles(void) ReleaseDC(hwnd, hdc); } +static void test_GdipGetVisibleClipBounds_memoryDC(void) +{ + HDC hdc,dc; + HBITMAP bmp; + HGDIOBJ old; + RECT rect; + POINT pt; + int width = 0; + int height = 0; + GpGraphics* graphics = NULL; + GpRect boundRect; + GpStatus status; + + ok(GetClientRect(hwnd, &rect), "GetClientRect should have succeeded\n"); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + + dc = GetDC(hwnd); + hdc = CreateCompatibleDC ( dc ); + bmp = CreateCompatibleBitmap ( dc, width, height ); + old = SelectObject (hdc, bmp); + + /*change the window origin is the key test point*/ + SetWindowOrgEx (hdc, rect.left+10, rect.top+10, &pt); + + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + + status = GdipGetVisibleClipBoundsI(graphics, &boundRect); + expect(Ok, status); + + ok(boundRect.X==rect.left+10 && + boundRect.Y==rect.top+10 && + boundRect.Width==width && + boundRect.Height==height, "Expected GdipGetVisibleClipBoundsI ok\n"); + + status = GdipSetClipRectI(graphics, 0, 0, width, height, CombineModeReplace); + expect(Ok, status); + + status = GdipGetVisibleClipBoundsI(graphics, &boundRect); + expect(Ok, status); + + ok(boundRect.X==rect.left+10 && + boundRect.Y==rect.top+10 && + boundRect.Width==width-10 && + boundRect.Height==height-10, "Expected GdipGetVisibleClipBoundsI ok\n"); + + GdipDeleteGraphics(graphics); + + SelectObject (hdc, old); + DeleteObject (bmp); + DeleteDC (hdc); + ReleaseDC(hwnd, dc); +} + START_TEST(graphics) { struct GdiplusStartupInput gdiplusStartupInput; @@ -5619,7 +5674,7 @@ START_TEST(graphics) test_alpha_hdc(); test_bitmapfromgraphics(); test_GdipFillRectangles(); - + test_GdipGetVisibleClipBounds_memoryDC(); GdiplusShutdown(gdiplusToken); DestroyWindow( hwnd ); } -- 1.9.1