Continuation of https://gitlab.winehq.org/wine/wine/-/merge_requests/5593
The incorrect background key was found while fixing other test failures caused by removing GDI objects from GpBitmaps.
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index bd77758eb51..9e08ddeb5bf 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -1973,6 +1973,7 @@ static void shorten_bezier_amt(GpPointF * pt, REAL amt, BOOL rev) static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * pt, GDIPCONST BYTE * types, INT count, BOOL caps) { + HDC hdc; POINT *pti = malloc(count * sizeof(POINT)); BYTE *tp = malloc(count); GpPointF *ptcopy = malloc(count * sizeof(GpPointF)); @@ -2085,7 +2086,13 @@ static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * tp[i] = convert_path_point_type(types[i]); }
- PolyDraw(graphics->hdc, pti, tp, count); + status = gdi_dc_acquire(graphics, &hdc); + if (status != Ok) + goto end; + + PolyDraw(hdc, pti, tp, count); + + gdi_dc_release(graphics, hdc);
status = Ok;
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 9e08ddeb5bf..e849446d2a7 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2106,12 +2106,20 @@ end:
GpStatus trace_path(GpGraphics *graphics, GpPath *path) { + HDC hdc; GpStatus result;
- BeginPath(graphics->hdc); + result = gdi_dc_acquire(graphics, &hdc); + if (result != Ok) + return result; + + BeginPath(hdc); result = draw_poly(graphics, NULL, path->pathdata.Points, path->pathdata.Types, path->pathdata.Count, FALSE); - EndPath(graphics->hdc); + EndPath(hdc); + + gdi_dc_release(graphics, hdc); + return result; }
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index e849446d2a7..229518307de 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2268,7 +2268,7 @@ static GpStatus get_graphics_bounds(GpGraphics* graphics, GpRectF* rect) { GpStatus stat = get_graphics_device_bounds(graphics, rect);
- if (stat == Ok && graphics->hdc) + if (stat == Ok && has_gdi_dc(graphics)) { GpPointF points[4], min_point, max_point; int i;
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 229518307de..14dfb41376b 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2418,17 +2418,17 @@ GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics) return GdipCreateFromHDC2(hdc, NULL, graphics); }
-static void get_gdi_transform(GpGraphics *graphics, GpMatrix *matrix) +static void get_gdi_transform(HDC hdc, GpMatrix *matrix) { XFORM xform;
- if (graphics->hdc == NULL) + if (hdc == NULL) { GdipSetMatrixElements(matrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); return; }
- GetTransform(graphics->hdc, 0x204, &xform); + GetTransform(hdc, 0x204, &xform); GdipSetMatrixElements(matrix, xform.eM11, xform.eM12, xform.eM21, xform.eM22, xform.eDx, xform.eDy); }
@@ -2483,7 +2483,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra list_init(&(*graphics)->containers); (*graphics)->contid = 0; (*graphics)->printer_display = (GetDeviceCaps(hdc, TECHNOLOGY) == DT_RASPRINTER); - get_gdi_transform(*graphics, &(*graphics)->gdi_transform); + get_gdi_transform(hdc, &(*graphics)->gdi_transform);
(*graphics)->gdi_clip = CreateRectRgn(0,0,0,0); if (!GetClipRgn(hdc, (*graphics)->gdi_clip))
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 2 +- dlls/gdiplus/tests/graphics.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 14dfb41376b..86c156354ef 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -6908,7 +6908,7 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G }
/* Color used to fill bitmaps so we can tell which parts have been drawn over by gdi32. */ -static const COLORREF DC_BACKGROUND_KEY = 0x0c0b0d; +static const COLORREF DC_BACKGROUND_KEY = 0x0d0b0c;
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc) { diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 4af7f179ec2..ff6a64e1fb5 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -2699,7 +2699,7 @@ static void test_fromMemoryBitmap(void) color = GetPixel(hdc, 0, 0); /* The HDC is write-only, and native fills with a solid color to figure out * which pixels have changed. */ - todo_wine expect(0x0c0b0d, color); + expect(0x0c0b0d, color);
SetPixel(hdc, 0, 0, 0x797979); SetPixel(hdc, 1, 0, 0x0c0b0d); @@ -2710,7 +2710,7 @@ static void test_fromMemoryBitmap(void) GdipDeleteGraphics(graphics);
expect(0x79, bits[0]); - todo_wine expect(0x68, bits[3]); + expect(0x68, bits[3]);
GdipDisposeImage((GpImage*)bitmap);
@@ -2747,7 +2747,7 @@ static void test_fromMemoryBitmap(void) ok(hdc != NULL, "got NULL hdc\n");
color = GetPixel(hdc, 0, 0); - todo_wine expect(0x0c0b0d, color); + expect(0x0c0b0d, color);
status = GdipReleaseDC(graphics, hdc); expect(Ok, status);