[PATCH 07/10] gdi32: Add an internal version of DPtoLP that takes a DC pointer.
Huw Davies
huw at codeweavers.com
Fri Jul 29 04:41:16 CDT 2016
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
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 4e965b9..d5553ee 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 f8bf3f8..59a3d9b 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 b42aaa6..a2b4170 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -1865,7 +1865,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};
@@ -1905,8 +1905,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 );
}
@@ -1930,7 +1930,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 );
@@ -2027,7 +2027,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)
@@ -2388,7 +2388,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;
@@ -2405,7 +2405,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;
@@ -2458,8 +2458,6 @@ done:
if(reordered_str != str)
HeapFree(GetProcessHeap(), 0, reordered_str);
- release_dc_ptr( dc );
-
if (ret && (lf.lfUnderline || lf.lfStrikeOut))
{
int underlinePos, strikeoutPos;
@@ -2505,7 +2503,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);
}
@@ -2521,7 +2519,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);
}
@@ -2530,6 +2528,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 3df3a2c..e4633d1 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 496643e..28b12bc 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 f6b6552..4ae9ba2 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);
--
2.7.4
More information about the wine-patches
mailing list