Jacek Caban : gdi32: Use NtGdiRectangle for Rectangle implementation.
Alexandre Julliard
julliard at winehq.org
Wed Jul 21 16:04:30 CDT 2021
Module: wine
Branch: master
Commit: 0636b360130baf05025492eb59a806bbeffc3d33
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0636b360130baf05025492eb59a806bbeffc3d33
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Jul 20 09:19:51 2021 +0200
gdi32: Use NtGdiRectangle for Rectangle implementation.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/enhmfdrv/dc.c | 14 +---------
dlls/gdi32/enhmfdrv/graphics.c | 59 ++++++++++++++++++++++++++----------------
dlls/gdi32/gdi_private.h | 3 +++
dlls/gdi32/gdidc.c | 15 +++++++++++
dlls/gdi32/mfdrv/graphics.c | 6 ++---
dlls/gdi32/mfdrv/init.c | 2 +-
dlls/gdi32/mfdrv/metafiledrv.h | 1 -
dlls/gdi32/painting.c | 7 ++---
8 files changed, 62 insertions(+), 45 deletions(-)
diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c
index 80caa6cb9d3..c19c9527dc2 100644
--- a/dlls/gdi32/enhmfdrv/dc.c
+++ b/dlls/gdi32/enhmfdrv/dc.c
@@ -779,18 +779,6 @@ static BOOL CDECL emfpathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT coun
next->funcs->pPolylineTo( next, pts, count ));
}
-/***********************************************************************
- * emfpathdrv_Rectangle
- */
-static BOOL CDECL emfpathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
-{
- PHYSDEV emfdev = get_emfdev( dev );
- PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRectangle );
-
- return (emfdev->funcs->pRectangle( emfdev, x1, y1, x2, y2 ) &&
- next->funcs->pRectangle( next, x1, y1, x2, y2 ));
-}
-
static const struct gdi_dc_funcs emfpath_driver =
{
@@ -874,7 +862,7 @@ static const struct gdi_dc_funcs emfpath_driver =
NULL, /* pPutImage */
NULL, /* pRealizeDefaultPalette */
NULL, /* pRealizePalette */
- emfpathdrv_Rectangle, /* pRectangle */
+ NULL, /* pRectangle */
NULL, /* pResetDC */
NULL, /* pRestoreDC */
NULL, /* pRoundRect */
diff --git a/dlls/gdi32/enhmfdrv/graphics.c b/dlls/gdi32/enhmfdrv/graphics.c
index a3197276525..82e6f894521 100644
--- a/dlls/gdi32/enhmfdrv/graphics.c
+++ b/dlls/gdi32/enhmfdrv/graphics.c
@@ -422,37 +422,52 @@ BOOL CDECL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom
}
/***********************************************************************
- * EMFDRV_Rectangle
+ * EMFDC_Rectangle
*/
-BOOL CDECL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
+BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom )
{
- EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
- DC *dc = get_physdev_dc( dev );
+ EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRRECTANGLE emr;
- INT temp;
-
- TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
if(left == right || top == bottom) return FALSE;
- if(left > right) {temp = left; left = right; right = temp;}
- if(top > bottom) {temp = top; top = bottom; bottom = temp;}
-
- if(dc->attr->graphics_mode == GM_COMPATIBLE) {
- right--;
- bottom--;
- }
-
emr.emr.iType = EMR_RECTANGLE;
emr.emr.nSize = sizeof(emr);
- emr.rclBox.left = left;
- emr.rclBox.top = top;
- emr.rclBox.right = right;
- emr.rclBox.bottom = bottom;
+ emr.rclBox.left = min( left, right );
+ emr.rclBox.top = min( top, bottom );
+ emr.rclBox.right = max( left, right );
+ emr.rclBox.bottom = max( top, bottom );
+ if (dc_attr->graphics_mode == GM_COMPATIBLE)
+ {
+ emr.rclBox.right--;
+ emr.rclBox.bottom--;
+ }
- if(!physDev->path)
- EMFDRV_UpdateBBox( dev, &emr.rclBox );
- return EMFDRV_WriteRecord( dev, &emr.emr );
+ return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
+}
+
+/***********************************************************************
+ * EMFDC_Rectangle
+ */
+BOOL EMFDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
+{
+ DC *dc = get_physdev_dc( dev );
+ RECTL bounds;
+
+ if (left == right || top == bottom) return FALSE;
+
+ bounds.left = min( left, right );
+ bounds.top = min( top, bottom );
+ bounds.right = max( left, right );
+ bounds.bottom = max( top, bottom );
+ if (dc->attr->graphics_mode == GM_COMPATIBLE)
+ {
+ bounds.right--;
+ bounds.bottom--;
+ }
+
+ EMFDRV_UpdateBBox( dev, &bounds );
+ return TRUE;
}
/***********************************************************************
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 52302fe4c23..8dd20c4bf11 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -51,6 +51,7 @@ extern BOOL METADC_LineTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL METADC_MoveTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL METADC_Pie( HDC hdc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
+extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
@@ -62,6 +63,8 @@ extern BOOL EMFDC_Ellipse( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_LineTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_MoveTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
+extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right,
+ INT bottom) DECLSPEC_HIDDEN;
extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c
index fbdfbed450c..f642eef75c0 100644
--- a/dlls/gdi32/gdidc.c
+++ b/dlls/gdi32/gdidc.c
@@ -185,6 +185,21 @@ BOOL WINAPI Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom )
return NtGdiEllipse( hdc, left, top, right, bottom );
}
+/***********************************************************************
+ * Rectangle (GDI32.@)
+ */
+BOOL WINAPI Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom )
+{
+ DC_ATTR *dc_attr;
+
+ TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc, left, top, right, bottom );
+
+ if (is_meta_dc( hdc )) return METADC_Rectangle( hdc, left, top, right, bottom );
+ if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
+ if (dc_attr->emf && !EMFDC_Rectangle( dc_attr, left, top, right, bottom )) return FALSE;
+ return NtGdiRectangle( hdc, left, top, right, bottom );
+}
+
/***********************************************************************
* RoundRect (GDI32.@)
*/
diff --git a/dlls/gdi32/mfdrv/graphics.c b/dlls/gdi32/mfdrv/graphics.c
index 727065eac65..37da92185af 100644
--- a/dlls/gdi32/mfdrv/graphics.c
+++ b/dlls/gdi32/mfdrv/graphics.c
@@ -98,11 +98,11 @@ BOOL METADC_Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom )
}
/***********************************************************************
- * MFDRV_Rectangle
+ * METADC_Rectangle
*/
-BOOL CDECL MFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
+BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom )
{
- return MFDRV_MetaParam4(dev, META_RECTANGLE, left, top, right, bottom);
+ return metadc_param4( hdc, META_RECTANGLE, left, top, right, bottom );
}
/***********************************************************************
diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c
index a90b5da35e7..df4d9dc9541 100644
--- a/dlls/gdi32/mfdrv/init.c
+++ b/dlls/gdi32/mfdrv/init.c
@@ -179,7 +179,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
NULL, /* pPutImage */
NULL, /* pRealizeDefaultPalette */
MFDRV_RealizePalette, /* pRealizePalette */
- MFDRV_Rectangle, /* pRectangle */
+ NULL, /* pRectangle */
NULL, /* pResetDC */
MFDRV_RestoreDC, /* pRestoreDC */
NULL, /* pRoundRect */
diff --git a/dlls/gdi32/mfdrv/metafiledrv.h b/dlls/gdi32/mfdrv/metafiledrv.h
index 5a2ad9958bd..66375295cd9 100644
--- a/dlls/gdi32/mfdrv/metafiledrv.h
+++ b/dlls/gdi32/mfdrv/metafiledrv.h
@@ -98,7 +98,6 @@ extern BOOL CDECL MFDRV_PolyBezierTo( PHYSDEV dev, const POINT* pt, DWORD count
extern BOOL CDECL MFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polygons) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_Polyline( PHYSDEV dev, const POINT* pt,INT count) DECLSPEC_HIDDEN;
-extern BOOL CDECL MFDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_SaveDC( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_ScaleViewportExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c
index e31fb997b9a..637b9ccda3f 100644
--- a/dlls/gdi32/painting.c
+++ b/dlls/gdi32/painting.c
@@ -357,17 +357,14 @@ BOOL WINAPI NtGdiEllipse( HDC hdc, INT left, INT top, INT right, INT bottom )
/***********************************************************************
- * Rectangle (GDI32.@)
+ * NtGdiRectangle (win32u.@)
*/
-BOOL WINAPI Rectangle( HDC hdc, INT left, INT top,
- INT right, INT bottom )
+BOOL WINAPI NtGdiRectangle( HDC hdc, INT left, INT top, INT right, INT bottom )
{
PHYSDEV physdev;
BOOL ret;
DC * dc = get_dc_ptr( hdc );
- TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc, left, top, right, bottom );
-
if (!dc) return FALSE;
update_dc( dc );
physdev = GET_DC_PHYSDEV( dc, pRectangle );
More information about the wine-cvs
mailing list