gdi32: Use NtGdiRoundRect for RoundRect implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-07-20 09:19:41 +02:00 committed by Alexandre Julliard
parent 680220c565
commit ffaf75a082
8 changed files with 89 additions and 49 deletions

View File

@ -791,19 +791,6 @@ static BOOL CDECL emfpathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT
next->funcs->pRectangle( next, x1, y1, x2, y2 ));
}
/***********************************************************************
* emfpathdrv_RoundRect
*/
static BOOL CDECL emfpathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2,
INT ell_width, INT ell_height )
{
PHYSDEV emfdev = get_emfdev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRoundRect );
return (emfdev->funcs->pRoundRect( emfdev, x1, y1, x2, y2, ell_width, ell_height ) &&
next->funcs->pRoundRect( next, x1, y1, x2, y2, ell_width, ell_height ));
}
static const struct gdi_dc_funcs emfpath_driver =
{
@ -890,7 +877,7 @@ static const struct gdi_dc_funcs emfpath_driver =
emfpathdrv_Rectangle, /* pRectangle */
NULL, /* pResetDC */
NULL, /* pRestoreDC */
emfpathdrv_RoundRect, /* pRoundRect */
NULL, /* pRoundRect */
NULL, /* pSaveDC */
NULL, /* pScaleViewportExt */
NULL, /* pScaleWindowExt */

View File

@ -455,39 +455,57 @@ BOOL CDECL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT botto
return EMFDRV_WriteRecord( dev, &emr.emr );
}
/***********************************************************************
* EMFDC_RoundRect
*/
BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRROUNDRECT emr;
if (left == right || top == bottom) return FALSE;
emr.emr.iType = EMR_ROUNDRECT;
emr.emr.nSize = sizeof(emr);
emr.rclBox.left = min( left, right );
emr.rclBox.top = min( top, bottom );
emr.rclBox.right = max( left, right );
emr.rclBox.bottom = max( top, bottom );
emr.szlCorner.cx = ell_width;
emr.szlCorner.cy = ell_height;
if (dc_attr->graphics_mode == GM_COMPATIBLE)
{
emr.rclBox.right--;
emr.rclBox.bottom--;
}
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
}
/***********************************************************************
* EMFDRV_RoundRect
*/
BOOL CDECL EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRROUNDRECT emr;
INT temp;
RECTL bounds;
if(left == right || top == bottom) return FALSE;
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--;
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--;
}
emr.emr.iType = EMR_ROUNDRECT;
emr.emr.nSize = sizeof(emr);
emr.rclBox.left = left;
emr.rclBox.top = top;
emr.rclBox.right = right;
emr.rclBox.bottom = bottom;
emr.szlCorner.cx = ell_width;
emr.szlCorner.cy = ell_height;
if(!physDev->path)
EMFDRV_UpdateBBox( dev, &emr.rclBox );
return EMFDRV_WriteRecord( dev, &emr.emr );
EMFDRV_UpdateBBox( dev, &bounds );
return TRUE;
}
/***********************************************************************

View File

@ -51,6 +51,8 @@ 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_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
/* enhanced metafiles */
extern BOOL EMFDC_ArcChordPie( DC_ATTR *dc_attr, INT left, INT top, INT right,
@ -60,5 +62,7 @@ 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_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
#endif /* __WINE_GDI_PRIVATE_H */

View File

@ -184,3 +184,25 @@ BOOL WINAPI Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom )
if (dc_attr->emf && !EMFDC_Ellipse( dc_attr, left, top, right, bottom )) return FALSE;
return NtGdiEllipse( hdc, left, top, right, bottom );
}
/***********************************************************************
* RoundRect (GDI32.@)
*/
BOOL WINAPI RoundRect( HDC hdc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
DC_ATTR *dc_attr;
TRACE( "%p, (%d, %d)-(%d, %d), %dx%d\n", hdc, left, top, right, bottom,
ell_width, ell_height );
if (is_meta_dc( hdc ))
return METADC_RoundRect( hdc, left, top, right, bottom, ell_width, ell_height );
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_RoundRect( dc_attr, left, top, right, bottom,
ell_width, ell_height ))
return FALSE;
return NtGdiRoundRect( hdc, left, top, right, bottom, ell_width, ell_height );
}

View File

@ -106,13 +106,13 @@ BOOL CDECL MFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom
}
/***********************************************************************
* MFDRV_RoundRect
* MF_RoundRect
*/
BOOL CDECL MFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
return MFDRV_MetaParam6(dev, META_ROUNDRECT, left, top, right, bottom,
ell_width, ell_height);
return metadc_param6( hdc, META_ROUNDRECT, left, top, right, bottom,
ell_width, ell_height );
}
/***********************************************************************

View File

@ -182,7 +182,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_Rectangle, /* pRectangle */
NULL, /* pResetDC */
MFDRV_RestoreDC, /* pRestoreDC */
MFDRV_RoundRect, /* pRoundRect */
NULL, /* pRoundRect */
MFDRV_SaveDC, /* pSaveDC */
MFDRV_ScaleViewportExtEx, /* pScaleViewportExtEx */
MFDRV_ScaleWindowExtEx, /* pScaleWindowExtEx */
@ -623,6 +623,17 @@ BOOL metadc_param4( HDC hdc, short func, short param1, short param2,
return MFDRV_MetaParam4( &dev->dev, func, param1, param2, param3, param4 );
}
BOOL metadc_param6( HDC hdc, short func, short param1, short param2,
short param3, short param4, short param5,
short param6 )
{
METAFILEDRV_PDEVICE *dev;
if (!(dev = get_metadc_ptr( hdc ))) return FALSE;
return MFDRV_MetaParam6( &dev->dev, func, param1, param2, param3,
param4, param5, param6 );
}
BOOL metadc_param8( HDC hdc, short func, short param1, short param2,
short param3, short param4, short param5,
short param6, short param7, short param8)

View File

@ -62,6 +62,8 @@ extern INT16 MFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) DECLSPEC_HI
extern BOOL metadc_param2( HDC hdc, short func, short param1, short param2 ) DECLSPEC_HIDDEN;
extern BOOL metadc_param4( HDC hdc, short func, short param1, short param2,
short param3, short param4 ) DECLSPEC_HIDDEN;
extern BOOL metadc_param6( HDC hdc, short func, short param1, short param2, short param3,
short param4, short param5, short param6 ) DECLSPEC_HIDDEN;
extern BOOL metadc_param8( HDC hdc, short func, short param1, short param2,
short param3, short param4, short param5, short param6,
short param7, short param8 ) DECLSPEC_HIDDEN;
@ -98,8 +100,6 @@ extern BOOL CDECL MFDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) DECLS
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 BOOL CDECL MFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) 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;
extern BOOL CDECL MFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;

View File

@ -378,17 +378,15 @@ BOOL WINAPI Rectangle( HDC hdc, INT left, INT top,
/***********************************************************************
* RoundRect (GDI32.@)
* NtGdiRoundRect (win32u.@)
*/
BOOL WINAPI RoundRect( HDC hdc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
BOOL WINAPI NtGdiRoundRect( HDC hdc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
PHYSDEV physdev;
BOOL ret;
DC *dc = get_dc_ptr( hdc );
TRACE( "%p, (%d, %d)-(%d, %d), %dx%d\n", hdc, left, top, right, bottom, ell_width, ell_height );
if (!dc) return FALSE;
update_dc( dc );
physdev = GET_DC_PHYSDEV( dc, pRoundRect );