Continuation of https://gitlab.winehq.org/wine/wine/-/merge_requests/5593
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/tests/graphicspath.c | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index f6e0264b786..b5c42d8378d 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1767,6 +1767,33 @@ static path_test_t widenline_capsquareanchor_multifigure_path[] = { {57.071068, 17.071068, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*23*/ };
+static path_test_t widenline_customarrow_multifigure_path[] = { + {6.0, 9.5, PathPointTypeStart}, /*0*/ + {24.0, 9.5, PathPointTypeLine}, /*1*/ + {24.0, 10.5, PathPointTypeLine}, /*2*/ + {6.0, 10.5, PathPointTypeLine|PathPointTypeCloseSubpath}, /*3*/ + {30.5, 11.0, PathPointTypeStart}, /*4*/ + {30.5, 29.0, PathPointTypeLine}, /*5*/ + {29.5, 29.0, PathPointTypeLine}, /*6*/ + {29.5, 11.0, PathPointTypeLine|PathPointTypeCloseSubpath}, /*7*/ + {13.0, 14.0, PathPointTypeStart}, /*8*/ + {5.0, 10.0, PathPointTypeLine}, /*9*/ + {13.0, 6.0, PathPointTypeLine}, /*10*/ + {11.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath}, /*11*/ + {17.0, 6.0, PathPointTypeStart}, /*12*/ + {25.0, 10.0, PathPointTypeLine}, /*13*/ + {17.0, 14.0, PathPointTypeLine}, /*14*/ + {19.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath}, /*15*/ + {26.0, 18.0, PathPointTypeStart}, /*16*/ + {30.0, 10.0, PathPointTypeLine}, /*17*/ + {34.0, 18.0, PathPointTypeLine}, /*18*/ + {30.0, 16.0, PathPointTypeLine|PathPointTypeCloseSubpath}, /*19*/ + {34.0, 22.0, PathPointTypeStart}, /*20*/ + {30.0, 30.0, PathPointTypeLine}, /*21*/ + {26.0, 22.0, PathPointTypeLine}, /*22*/ + {30.0, 24.0, PathPointTypeLine|PathPointTypeCloseSubpath}, /*23*/ + }; + static void test_widen_cap(void) { struct @@ -1873,14 +1900,28 @@ static void test_widen_cap(void) ok_path_fudge(path, widenline_capsquareanchor_multifigure_path, ARRAY_SIZE(widenline_capsquareanchor_multifigure_path), FALSE, 0.000005);
+ status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 10.0, 25.0, 10.0); + expect(Ok, status); + status = GdipStartPathFigure(path); + expect(Ok, status); + status = GdipAddPathLine(path, 30.0, 10.0, 30.0, 30.0); + expect(Ok, status); status = GdipCreateAdjustableArrowCap(4.0, 4.0, TRUE, &arrowcap); ok(status == Ok, "Failed to create adjustable cap, %d\n", status); status = GdipSetAdjustableArrowCapMiddleInset(arrowcap, 1.0); ok(status == Ok, "Failed to set middle inset inadjustable cap, %d\n", status); + status = GdipSetPenCustomStartCap(pen, (GpCustomLineCap*)arrowcap); + ok(status == Ok, "Failed to create custom end cap, %d\n", status); status = GdipSetPenCustomEndCap(pen, (GpCustomLineCap*)arrowcap); ok(status == Ok, "Failed to create custom end cap, %d\n", status); + status = GdipSetPenWidth(pen, 1.0); + expect(Ok, status); status = GdipWidenPath(path, pen, NULL, FlatnessDefault); expect(Ok, status); + ok_path_fudge(path, widenline_customarrow_multifigure_path, + ARRAY_SIZE(widenline_customarrow_multifigure_path), FALSE, 0.000005);
GdipDeletePen(pen);
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/gdiplus_private.h | 4 +- dlls/gdiplus/graphics.c | 102 ++++++++++++--------------------- dlls/gdiplus/image.c | 81 +++----------------------- dlls/gdiplus/tests/graphics.c | 2 +- 4 files changed, 46 insertions(+), 143 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index c327d44af66..e25f60de78e 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -49,6 +49,8 @@ #define GIF_DISPOSE_RESTORE_TO_BKGND 2 #define GIF_DISPOSE_RESTORE_TO_PREV 3
+#define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24) +
COLORREF ARGB2COLORREF(ARGB color); HBITMAP ARGB2BMP(ARGB color); @@ -467,8 +469,6 @@ struct GpBitmap{ PixelFormat format; ImageLockMode lockmode; BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */ - HBITMAP hbitmap; - HDC hdc; BYTE *bits; /* actual image bits if this is a DIB */ INT stride; /* stride of bits if this is a DIB */ BYTE *own_bits; /* image bits that need to be freed with this object */ diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 7eea3f58c77..2fbe55756d4 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -3402,69 +3402,44 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image else { HDC hdc; - BOOL temp_hdc = FALSE, temp_bitmap = FALSE; HBITMAP hbitmap, old_hbm=NULL; HRGN hrgn; INT save_state; + BITMAPINFOHEADER bih; + BYTE *temp_bits; + PixelFormat dst_format;
- if (!(bitmap->format == PixelFormat16bppRGB555 || - bitmap->format == PixelFormat24bppRGB || - bitmap->format == PixelFormat32bppRGB || - bitmap->format == PixelFormat32bppPARGB)) - { - BITMAPINFOHEADER bih; - BYTE *temp_bits; - PixelFormat dst_format; - - /* we can't draw a bitmap of this format directly */ - hdc = CreateCompatibleDC(0); - temp_hdc = TRUE; - temp_bitmap = TRUE; - - bih.biSize = sizeof(BITMAPINFOHEADER); - bih.biWidth = bitmap->width; - bih.biHeight = -bitmap->height; - bih.biPlanes = 1; - bih.biBitCount = 32; - bih.biCompression = BI_RGB; - bih.biSizeImage = 0; - bih.biXPelsPerMeter = 0; - bih.biYPelsPerMeter = 0; - bih.biClrUsed = 0; - bih.biClrImportant = 0; - - hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, - (void**)&temp_bits, NULL, 0); - - if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) - dst_format = PixelFormat32bppPARGB; - else - dst_format = PixelFormat32bppRGB; + hdc = CreateCompatibleDC(0);
- convert_pixels(bitmap->width, bitmap->height, - bitmap->width*4, temp_bits, dst_format, bitmap->image.palette, - bitmap->stride, bitmap->bits, bitmap->format, - bitmap->image.palette); - } + if (bitmap->format == PixelFormat16bppRGB555 || + bitmap->format == PixelFormat24bppRGB) + dst_format = bitmap->format; + else if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) + dst_format = PixelFormat32bppPARGB; else - { - if (bitmap->hbitmap) - hbitmap = bitmap->hbitmap; - else - { - GdipCreateHBITMAPFromBitmap(bitmap, &hbitmap, 0); - temp_bitmap = TRUE; - } - - hdc = bitmap->hdc; - temp_hdc = (hdc == 0); - } - - if (temp_hdc) - { - if (!hdc) hdc = CreateCompatibleDC(0); - old_hbm = SelectObject(hdc, hbitmap); - } + dst_format = PixelFormat32bppRGB; + + bih.biSize = sizeof(BITMAPINFOHEADER); + bih.biWidth = bitmap->width; + bih.biHeight = -bitmap->height; + bih.biPlanes = 1; + bih.biBitCount = PIXELFORMATBPP(dst_format); + bih.biCompression = BI_RGB; + bih.biSizeImage = 0; + bih.biXPelsPerMeter = 0; + bih.biYPelsPerMeter = 0; + bih.biClrUsed = 0; + bih.biClrImportant = 0; + + hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, + (void**)&temp_bits, NULL, 0); + + convert_pixels(bitmap->width, bitmap->height, + bitmap->width*PIXELFORMATBPP(dst_format)/8, temp_bits, dst_format, bitmap->image.palette, + bitmap->stride, bitmap->bits, bitmap->format, + bitmap->image.palette); + + old_hbm = SelectObject(hdc, hbitmap);
save_state = SaveDC(graphics->hdc);
@@ -3493,14 +3468,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
RestoreDC(graphics->hdc, save_state);
- if (temp_hdc) - { - SelectObject(hdc, old_hbm); - DeleteDC(hdc); - } - - if (temp_bitmap) - DeleteObject(hbitmap); + SelectObject(hdc, old_hbm); + DeleteDC(hdc); + DeleteObject(hbitmap); } } else if (image->type == ImageTypeMetafile && ((GpMetafile*)image)->hemf) @@ -7005,7 +6975,7 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc) stat = METAFILE_GetDC((GpMetafile*)graphics->image, hdc); } else if (!graphics->hdc || - (graphics->image && graphics->image->type == ImageTypeBitmap && ((GpBitmap*)graphics->image)->format & PixelFormatAlpha)) + (graphics->image && graphics->image->type == ImageTypeBitmap)) { /* Create a fake HDC and fill it with a constant color. */ HDC temp_hdc; diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 3a5e338c4ac..eaf01cab65b 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -40,7 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**);
-#define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24) #define WMF_PLACEABLE_KEY 0x9ac6cdd7
static const struct @@ -1793,8 +1792,7 @@ static GpStatus get_screen_resolution(REAL *xres, REAL *yres) GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap) { - HBITMAP hbitmap=NULL; - INT row_size, dib_stride; + INT row_size; BYTE *bits=NULL, *own_bits=NULL; REAL xres, yres; GpStatus stat; @@ -1815,56 +1813,20 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, if (stat != Ok) return stat;
row_size = (width * PIXELFORMATBPP(format)+7) / 8; - dib_stride = (row_size + 3) & ~3;
- if(!scan0) - stride = dib_stride; - - if (format & PixelFormatGDI && !(format & (PixelFormatAlpha|PixelFormatIndexed)) && !scan0) - { - char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])]; - BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf; - - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biWidth = width; - pbmi->bmiHeader.biHeight = -height; - pbmi->bmiHeader.biPlanes = 1; - /* FIXME: use the rest of the data from format */ - pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(format); - pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiHeader.biSizeImage = 0; - pbmi->bmiHeader.biXPelsPerMeter = 0; - pbmi->bmiHeader.biYPelsPerMeter = 0; - pbmi->bmiHeader.biClrUsed = 0; - pbmi->bmiHeader.biClrImportant = 0; - - hbitmap = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); - - if (!hbitmap) return GenericError; - - stride = dib_stride; - } + if (scan0) + bits = scan0; else { - /* Not a GDI format; don't try to make an HBITMAP. */ - if (scan0) - bits = scan0; - else - { - INT size = abs(stride) * height; + stride = (row_size + 3) & ~3;
- own_bits = bits = calloc(1, size); - if (!own_bits) return OutOfMemory; - - if (stride < 0) - bits += stride * (1 - height); - } + own_bits = bits = calloc(1, stride * height); + if (!own_bits) return OutOfMemory; }
*bitmap = calloc(1, sizeof(GpBitmap)); if(!*bitmap) { - DeleteObject(hbitmap); free(own_bits); return OutOfMemory; } @@ -1882,8 +1844,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, (*bitmap)->format = format; (*bitmap)->image.decoder = NULL; (*bitmap)->image.encoder = NULL; - (*bitmap)->hbitmap = hbitmap; - (*bitmap)->hdc = NULL; (*bitmap)->bits = bits; (*bitmap)->stride = stride; (*bitmap)->own_bits = own_bits; @@ -2071,8 +2031,6 @@ static void move_bitmap(GpBitmap *dst, GpBitmap *src, BOOL clobber_palette)
free(dst->bitmapbits); free(dst->own_bits); - DeleteDC(dst->hdc); - DeleteObject(dst->hbitmap);
if (clobber_palette) { @@ -2087,8 +2045,6 @@ static void move_bitmap(GpBitmap *dst, GpBitmap *src, BOOL clobber_palette) dst->width = src->width; dst->height = src->height; dst->format = src->format; - dst->hbitmap = src->hbitmap; - dst->hdc = src->hdc; dst->bits = src->bits; dst->stride = src->stride; dst->own_bits = src->own_bits; @@ -2120,8 +2076,6 @@ static GpStatus free_image_data(GpImage *image) { free(((GpBitmap*)image)->bitmapbits); free(((GpBitmap*)image)->own_bits); - DeleteDC(((GpBitmap*)image)->hdc); - DeleteObject(((GpBitmap*)image)->hbitmap); if (((GpBitmap*)image)->metadata_reader) IWICMetadataReader_Release(((GpBitmap*)image)->metadata_reader); free(((GpBitmap*)image)->prop_item); @@ -2240,7 +2194,6 @@ GpStatus WINGDIPAPI GdipGetImageDimension(GpImage *image, REAL *width, GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics) { - HDC hdc; GpStatus stat;
TRACE("%p %p\n", image, graphics); @@ -2248,27 +2201,7 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, if(!image || !graphics) return InvalidParameter;
- if (image->type == ImageTypeBitmap && ((GpBitmap*)image)->hbitmap) - { - hdc = ((GpBitmap*)image)->hdc; - - if(!hdc){ - hdc = CreateCompatibleDC(0); - SelectObject(hdc, ((GpBitmap*)image)->hbitmap); - ((GpBitmap*)image)->hdc = hdc; - } - - stat = GdipCreateFromHDC(hdc, graphics); - - if (stat == Ok) - { - (*graphics)->image = image; - (*graphics)->image_type = image->type; - (*graphics)->xres = image->xres; - (*graphics)->yres = image->yres; - } - } - else if (image->type == ImageTypeMetafile) + if (image->type == ImageTypeMetafile) stat = METAFILE_GetGraphicsContext((GpMetafile*)image, graphics); else stat = graphics_from_image(image, graphics); diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 73e2a9b2c3a..c1c0fa67669 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -2726,7 +2726,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);
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 2fbe55756d4..f04d4941310 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -3401,7 +3401,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image } else { - HDC hdc; + HDC src_hdc, dst_hdc; HBITMAP hbitmap, old_hbm=NULL; HRGN hrgn; INT save_state; @@ -3409,7 +3409,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image BYTE *temp_bits; PixelFormat dst_format;
- hdc = CreateCompatibleDC(0); + src_hdc = CreateCompatibleDC(0);
if (bitmap->format == PixelFormat16bppRGB555 || bitmap->format == PixelFormat24bppRGB) @@ -3431,7 +3431,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image bih.biClrUsed = 0; bih.biClrImportant = 0;
- hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, + hbitmap = CreateDIBSection(src_hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&temp_bits, NULL, 0);
convert_pixels(bitmap->width, bitmap->height, @@ -3439,15 +3439,17 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette);
- old_hbm = SelectObject(hdc, hbitmap); + old_hbm = SelectObject(src_hdc, hbitmap);
- save_state = SaveDC(graphics->hdc); + gdi_dc_acquire(graphics, &dst_hdc); + + save_state = SaveDC(dst_hdc);
stat = get_clip_hrgn(graphics, &hrgn);
if (stat == Ok) { - ExtSelectClipRgn(graphics->hdc, hrgn, RGN_COPY); + ExtSelectClipRgn(dst_hdc, hrgn, RGN_COPY); DeleteObject(hrgn); }
@@ -3456,20 +3458,22 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) { gdi_alpha_blend(graphics, pti[0].x, pti[0].y, pti[1].x - pti[0].x, pti[2].y - pti[0].y, - hdc, srcx, srcy, srcwidth, srcheight); + src_hdc, srcx, srcy, srcwidth, srcheight); } else { - StretchBlt(graphics->hdc, pti[0].x, pti[0].y, pti[1].x-pti[0].x, pti[2].y-pti[0].y, - hdc, srcx, srcy, srcwidth, srcheight, SRCCOPY); + StretchBlt(dst_hdc, pti[0].x, pti[0].y, pti[1].x-pti[0].x, pti[2].y-pti[0].y, + src_hdc, srcx, srcy, srcwidth, srcheight, SRCCOPY); }
gdi_transform_release(graphics);
- RestoreDC(graphics->hdc, save_state); + RestoreDC(dst_hdc, save_state);
- SelectObject(hdc, old_hbm); - DeleteDC(hdc); + gdi_dc_release(graphics, dst_hdc); + + SelectObject(src_hdc, old_hbm); + DeleteDC(src_hdc); DeleteObject(hbitmap); } }
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index f04d4941310..1cf5da6f1f8 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4433,42 +4433,47 @@ GpStatus WINGDIPAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x
static GpStatus GDI32_GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path) { + HDC hdc; INT save_state; GpStatus retval; HRGN hrgn=NULL;
- if(!graphics->hdc || !brush_can_fill_path(brush, TRUE)) + if(!brush_can_fill_path(brush, TRUE)) return NotImplemented;
- save_state = SaveDC(graphics->hdc); - EndPath(graphics->hdc); - SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE - : WINDING)); + retval = gdi_dc_acquire(graphics, &hdc); + if (retval != Ok) + return retval; + + save_state = SaveDC(hdc); + EndPath(hdc); + SetPolyFillMode(hdc, (path->fill == FillModeAlternate ? ALTERNATE : WINDING));
retval = get_clip_hrgn(graphics, &hrgn);
if (retval != Ok) goto end;
- ExtSelectClipRgn(graphics->hdc, hrgn, RGN_COPY); + ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
gdi_transform_acquire(graphics);
- BeginPath(graphics->hdc); + BeginPath(hdc); retval = draw_poly(graphics, NULL, path->pathdata.Points, path->pathdata.Types, path->pathdata.Count, FALSE);
if(retval == Ok) { - EndPath(graphics->hdc); + EndPath(hdc); retval = brush_fill_path(graphics, brush); }
gdi_transform_release(graphics);
end: - RestoreDC(graphics->hdc, save_state); + RestoreDC(hdc, save_state); DeleteObject(hrgn); + gdi_dc_release(graphics, hdc);
return retval; }
From: Esme Povirk esme@codeweavers.com
--- dlls/gdiplus/graphics.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 1cf5da6f1f8..4c12cc18f11 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4734,47 +4734,47 @@ static GpStatus GDI32_GdipFillRegion(GpGraphics* graphics, GpBrush* brush, { INT save_state; GpStatus status; + HDC hdc; HRGN hrgn; RECT rc;
- if(!graphics->hdc || !brush_can_fill_path(brush, TRUE)) + if(!brush_can_fill_path(brush, TRUE)) return NotImplemented;
- save_state = SaveDC(graphics->hdc); - EndPath(graphics->hdc); + status = gdi_dc_acquire(graphics, &hdc); + if (status != Ok) + return status; + + save_state = SaveDC(hdc); + EndPath(hdc);
hrgn = NULL; status = get_clip_hrgn(graphics, &hrgn); if (status != Ok) - { - RestoreDC(graphics->hdc, save_state); - return status; - } + goto end;
- ExtSelectClipRgn(graphics->hdc, hrgn, RGN_COPY); + ExtSelectClipRgn(hdc, hrgn, RGN_COPY); DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn); if (status != Ok) - { - RestoreDC(graphics->hdc, save_state); - return status; - } + goto end;
- ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND); + ExtSelectClipRgn(hdc, hrgn, RGN_AND); DeleteObject(hrgn);
- if (GetClipBox(graphics->hdc, &rc) != NULLREGION) + if (GetClipBox(hdc, &rc) != NULLREGION) { - BeginPath(graphics->hdc); - Rectangle(graphics->hdc, rc.left, rc.top, rc.right, rc.bottom); - EndPath(graphics->hdc); + BeginPath(hdc); + Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); + EndPath(hdc);
status = brush_fill_path(graphics, brush); }
- RestoreDC(graphics->hdc, save_state); - +end: + RestoreDC(hdc, save_state); + gdi_dc_release(graphics, hdc);
return status; }