From e1130cbb99fb21f9884cd969b0121dd3ccb827b3 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Fri, 29 Jul 2016 15:09:32 +0100 Subject: [PATCH] gdi32: Add an internal version of DPtoLP that takes a DC pointer. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/clipping.c | 2 +- dlls/gdi32/dc.c | 2 +- dlls/gdi32/font.c | 22 +++++++++++----------- dlls/gdi32/gdi_private.h | 1 + dlls/gdi32/mapping.c | 26 ++++++++++++++++++++------ dlls/gdi32/path.c | 2 +- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/dlls/gdi32/clipping.c b/dlls/gdi32/clipping.c index 4e965b9a4a1..d5553eeba05 100644 --- a/dlls/gdi32/clipping.c +++ b/dlls/gdi32/clipping.c @@ -438,7 +438,7 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect ) rect->left = rect->right - 1; rect->right = tmp - 1; } - DPtoLP( hdc, (LPPOINT)rect, 2 ); + dp_to_lp( dc, (LPPOINT)rect, 2 ); release_dc_ptr( dc ); TRACE("%p => %d %s\n", hdc, ret, wine_dbgstr_rect( rect )); return ret; diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index f8bf3f82970..59a3d9b33f3 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -1484,7 +1484,7 @@ UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags) rect->bottom = min( rect->bottom, dc->vis_rect.bottom - dc->vis_rect.top ); ret = DCB_SET; } - DPtoLP( hdc, (POINT *)rect, 2 ); + dp_to_lp( dc, (POINT *)rect, 2 ); } else ret = 0; diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 02efc8a90f2..afeebb83390 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -1901,7 +1901,7 @@ static RECT get_total_extents( HDC hdc, INT x, INT y, UINT flags, UINT aa_flags, } /* helper for nulldrv_ExtTextOut */ -static void draw_glyph( HDC hdc, INT origin_x, INT origin_y, const GLYPHMETRICS *metrics, +static void draw_glyph( DC *dc, INT origin_x, INT origin_y, const GLYPHMETRICS *metrics, const struct gdi_image_bits *image, const RECT *clip ) { static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; @@ -1941,8 +1941,8 @@ static void draw_glyph( HDC hdc, INT origin_x, INT origin_y, const GLYPHMETRICS } } assert( count <= max_count ); - DPtoLP( hdc, pts, count ); - for (i = 0; i < count; i += 2) Polyline( hdc, pts + i, 2 ); + dp_to_lp( dc, pts, count ); + for (i = 0; i < count; i += 2) Polyline( dc->hSelf, pts + i, 2 ); HeapFree( GetProcessHeap(), 0, pts ); } @@ -1966,7 +1966,7 @@ BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect if (brush) { orig = SelectObject( dev->hdc, brush ); - DPtoLP( dev->hdc, (POINT *)&rc, 2 ); + dp_to_lp( dc, (POINT *)&rc, 2 ); PatBlt( dev->hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY ); SelectObject( dev->hdc, orig ); DeleteObject( brush ); @@ -2063,7 +2063,7 @@ BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect err = get_glyph_bitmap( dev->hdc, str[i], flags, GGO_BITMAP, &metrics, &image ); if (err) continue; - if (image.ptr) draw_glyph( dev->hdc, x, y, &metrics, &image, (flags & ETO_CLIPPED) ? rect : NULL ); + if (image.ptr) draw_glyph( dc, x, y, &metrics, &image, (flags & ETO_CLIPPED) ? rect : NULL ); if (image.free) image.free( &image ); if (dx) @@ -2424,7 +2424,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, { pt.x = x + width.x; pt.y = y + width.y; - DPtoLP(hdc, &pt, 1); + dp_to_lp(dc, &pt, 1); MoveToEx(hdc, pt.x, pt.y, NULL); } break; @@ -2441,7 +2441,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, { pt.x = x; pt.y = y; - DPtoLP(hdc, &pt, 1); + dp_to_lp(dc, &pt, 1); MoveToEx(hdc, pt.x, pt.y, NULL); } break; @@ -2494,8 +2494,6 @@ done: if(reordered_str != str) HeapFree(GetProcessHeap(), 0, reordered_str); - release_dc_ptr( dc ); - if (ret && (lf.lfUnderline || lf.lfStrikeOut)) { int underlinePos, strikeoutPos; @@ -2541,7 +2539,7 @@ done: pts[3].y = pts[0].y + underlineWidth * cosEsc; pts[4].x = pts[0].x; pts[4].y = pts[0].y; - DPtoLP(hdc, pts, 5); + dp_to_lp(dc, pts, 5); Polygon(hdc, pts, 5); } @@ -2557,7 +2555,7 @@ done: pts[3].y = pts[0].y + strikeoutWidth * cosEsc; pts[4].x = pts[0].x; pts[4].y = pts[0].y; - DPtoLP(hdc, pts, 5); + dp_to_lp(dc, pts, 5); Polygon(hdc, pts, 5); } @@ -2566,6 +2564,8 @@ done: DeleteObject(hbrush); } + release_dc_ptr( dc ); + return ret; } diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 3df3a2c5d58..e4633d1c338 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -304,6 +304,7 @@ extern void GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN; extern void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN; /* mapping.c */ +extern BOOL dp_to_lp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN; extern void lp_to_dp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN; /* metafile.c */ diff --git a/dlls/gdi32/mapping.c b/dlls/gdi32/mapping.c index 496643e7350..28b12bc48cc 100644 --- a/dlls/gdi32/mapping.c +++ b/dlls/gdi32/mapping.c @@ -306,13 +306,12 @@ BOOL nulldrv_SetWorldTransform( PHYSDEV dev, const XFORM *xform ) } /*********************************************************************** - * DPtoLP (GDI32.@) + * dp_to_lp + * + * Internal version of DPtoLP that takes a DC *. */ -BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count ) +BOOL dp_to_lp( DC *dc, POINT *points, INT count ) { - DC * dc = get_dc_ptr( hdc ); - if (!dc) return FALSE; - if (dc->vport2WorldValid) { while (count--) @@ -328,10 +327,25 @@ BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count ) points++; } } - release_dc_ptr( dc ); return (count < 0); } +/*********************************************************************** + * DPtoLP (GDI32.@) + */ +BOOL WINAPI DPtoLP( HDC hdc, POINT *points, INT count ) +{ + DC * dc = get_dc_ptr( hdc ); + BOOL ret; + + if (!dc) return FALSE; + + ret = dp_to_lp( dc, points, count ); + + release_dc_ptr( dc ); + return ret; +} + /*********************************************************************** * lp_to_dp diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index f6b655282a0..4ae9ba27527 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -670,7 +670,7 @@ INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes, INT nSize) memcpy(pTypes, dc->path->flags, sizeof(BYTE)*dc->path->count); /* Convert the points to logical coordinates */ - if(!DPtoLP(hdc, pPoints, dc->path->count)) + if(!dp_to_lp(dc, pPoints, dc->path->count)) { /* FIXME: Is this the correct value? */ SetLastError(ERROR_CAN_NOT_COMPLETE);