gdi32: Use NtGdiPolyPolyDraw for PolyBezierTo 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-22 11:27:36 +02:00 committed by Alexandre Julliard
parent d69a6ab731
commit 82d59861a0
5 changed files with 56 additions and 74 deletions

View File

@ -671,18 +671,6 @@ static BOOL CDECL emfpathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
next->funcs->pExtTextOut( next, x, y, flags, rect, str, count, dx ));
}
/***********************************************************************
* emfpathdrv_PolyBezierTo
*/
static BOOL CDECL emfpathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count )
{
PHYSDEV emfdev = get_emfdev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pPolyBezierTo );
return (emfdev->funcs->pPolyBezierTo( emfdev, pts, count ) &&
next->funcs->pPolyBezierTo( next, pts, count ));
}
/***********************************************************************
* emfpathdrv_PolyDraw
*/
@ -768,7 +756,7 @@ static const struct gdi_dc_funcs emfpath_driver =
NULL, /* pPatBlt */
NULL, /* pPie */
NULL, /* pPolyBezier */
emfpathdrv_PolyBezierTo, /* pPolyBezierTo */
NULL, /* pPolyBezierTo */
emfpathdrv_PolyDraw, /* pPolyDraw */
NULL, /* pPolyPolygon */
NULL, /* pPolyPolyline */

View File

@ -66,14 +66,14 @@ static void *store_points( POINTL *dest, const POINT *pts, UINT count, BOOL shor
}
/* compute the bounds of an array of points, optionally including the current position */
static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, DC *dc )
static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, DC_ATTR *dc_attr )
{
UINT i;
if (dc)
if (dc_attr)
{
bounds->left = bounds->right = dc->attr->cur_pos.x;
bounds->top = bounds->bottom = dc->attr->cur_pos.y;
bounds->left = bounds->right = dc_attr->cur_pos.x;
bounds->top = bounds->bottom = dc_attr->cur_pos.y;
}
else if (count)
{
@ -551,33 +551,31 @@ COLORREF CDECL EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
*
* Helper for EMFDRV_Poly{line|gon}
*/
static BOOL
EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
static BOOL EMFDC_Polylinegon( DC_ATTR *dc_attr, const POINT *points, INT count, DWORD type )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRPOLYLINE *emr;
DWORD size;
BOOL ret, use_small_emr = can_use_short_points( pt, count );
BOOL ret, use_small_emr = can_use_short_points( points, count );
size = use_small_emr ? offsetof( EMRPOLYLINE16, apts[count] ) : offsetof( EMRPOLYLINE, aptl[count] );
emr = HeapAlloc( GetProcessHeap(), 0, size );
emr->emr.iType = use_small_emr ? iType + EMR_POLYLINE16 - EMR_POLYLINE : iType;
emr->emr.iType = use_small_emr ? type + EMR_POLYLINE16 - EMR_POLYLINE : type;
emr->emr.nSize = size;
emr->cptl = count;
store_points( emr->aptl, pt, count, use_small_emr );
store_points( emr->aptl, points, count, use_small_emr );
if (!physDev->path)
get_points_bounds( &emr->rclBounds, pt, count,
(iType == EMR_POLYBEZIERTO || iType == EMR_POLYLINETO) ? dc : 0 );
if (!emf->path)
get_points_bounds( &emr->rclBounds, points, count,
(type == EMR_POLYBEZIERTO || type == EMR_POLYLINETO) ? dc_attr : 0 );
else
emr->rclBounds = empty_bounds;
ret = EMFDRV_WriteRecord( dev, &emr->emr );
if (ret && !physDev->path)
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
if (ret && !emf->path)
EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
@ -588,15 +586,15 @@ EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
*/
BOOL EMFDC_Polyline( DC_ATTR *dc_attr, const POINT *points, INT count )
{
return EMFDRV_Polylinegon( dc_attr->emf, points, count, EMR_POLYLINE );
return EMFDC_Polylinegon( dc_attr, points, count, EMR_POLYLINE );
}
/**********************************************************************
* EMFDC_PolylineTo
*/
BOOL EMFDC_PolylineTo( DC_ATTR *dc_attr, const POINT *pt, INT count )
BOOL EMFDC_PolylineTo( DC_ATTR *dc_attr, const POINT *points, INT count )
{
return EMFDRV_Polylinegon( dc_attr->emf, pt, count, EMR_POLYLINETO );
return EMFDC_Polylinegon( dc_attr, points, count, EMR_POLYLINETO );
}
/**********************************************************************
@ -614,7 +612,7 @@ BOOL CDECL EMFDRV_PolylineTo( PHYSDEV dev, const POINT* pt, INT count )
BOOL EMFDC_Polygon( DC_ATTR *dc_attr, const POINT *pt, INT count )
{
if(count < 2) return FALSE;
return EMFDRV_Polylinegon( dc_attr->emf, pt, count, EMR_POLYGON );
return EMFDC_Polylinegon( dc_attr, pt, count, EMR_POLYGON );
}
/**********************************************************************
@ -622,7 +620,15 @@ BOOL EMFDC_Polygon( DC_ATTR *dc_attr, const POINT *pt, INT count )
*/
BOOL EMFDC_PolyBezier( DC_ATTR *dc_attr, const POINT *pts, DWORD count )
{
return EMFDRV_Polylinegon( dc_attr->emf, pts, count, EMR_POLYBEZIER );
return EMFDC_Polylinegon( dc_attr, pts, count, EMR_POLYBEZIER );
}
/**********************************************************************
* EMFDC_PolyBezierTo
*/
BOOL EMFDC_PolyBezierTo( DC_ATTR *dc_attr, const POINT *pts, DWORD count )
{
return EMFDC_Polylinegon( dc_attr, pts, count, EMR_POLYBEZIERTO );
}
/**********************************************************************
@ -639,7 +645,8 @@ BOOL CDECL EMFDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
*/
BOOL CDECL EMFDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count )
{
return EMFDRV_Polylinegon( dev, pts, count, EMR_POLYBEZIERTO );
/* FIXME: update bounding rect */
return TRUE;
}

View File

@ -70,6 +70,7 @@ extern BOOL EMFDC_Ellipse( DC_ATTR *dc_attr, INT left, INT top, INT right,
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_PolyBezier( DC_ATTR *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyBezierTo( DC_ATTR *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyPolyline( DC_ATTR *dc_attr, const POINT *points, const DWORD *counts,
DWORD polys ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyPolygon( DC_ATTR *dc_attr, const POINT *points, const INT *counts,

View File

@ -310,6 +310,20 @@ BOOL WINAPI PolyBezier( HDC hdc, const POINT *points, DWORD count )
return NtGdiPolyPolyDraw( hdc, points, &count, 1, NtGdiPolyBezier );
}
/******************************************************************************
* PolyBezierTo (GDI32.@)
*/
BOOL WINAPI PolyBezierTo( HDC hdc, const POINT *points, DWORD count )
{
DC_ATTR *dc_attr;
TRACE( "%p, %p, %u\n", hdc, points, count );
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_PolyBezierTo( dc_attr, points, count )) return FALSE;
return NtGdiPolyPolyDraw( hdc, points, &count, 1, NtGdiPolyBezierTo );
}
/**********************************************************************
* PolylineTo (GDI32.@)
*/

View File

@ -611,6 +611,16 @@ ULONG WINAPI NtGdiPolyPolyDraw( HDC hdc, const POINT *points, const UINT *counts
else ret = FALSE;
break;
case NtGdiPolyBezierTo:
if (count == 1 && *counts && *counts % 3 == 0)
{
physdev = GET_DC_PHYSDEV( dc, pPolyBezierTo );
ret = physdev->funcs->pPolyBezierTo( physdev, points, *counts );
if (ret) dc->attr->cur_pos = points[*counts - 1];
}
else ret = FALSE;
break;
case NtGdiPolylineTo:
if (count == 1)
{
@ -660,44 +670,6 @@ BOOL WINAPI FloodFill( HDC hdc, INT x, INT y, COLORREF color )
return ExtFloodFill( hdc, x, y, color, FLOODFILLBORDER );
}
/******************************************************************************
* PolyBezierTo [GDI32.@]
* Draws one or more Bezier curves
*
* PARAMS
* hDc [I] Handle to device context
* lppt [I] Pointer to endpoints and control points
* cPoints [I] Count of endpoints and control points
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI PolyBezierTo( HDC hdc, const POINT* lppt, DWORD cPoints )
{
DC * dc;
BOOL ret;
PHYSDEV physdev;
TRACE( "%p, %p, %u\n", hdc, lppt, cPoints );
/* cbPoints must be 3 * n (where n>=1) */
if (!cPoints || (cPoints % 3) != 0) return FALSE;
dc = get_dc_ptr( hdc );
if(!dc) return FALSE;
update_dc( dc );
physdev = GET_DC_PHYSDEV( dc, pPolyBezierTo );
ret = physdev->funcs->pPolyBezierTo( physdev, lppt, cPoints );
if(ret)
dc->attr->cur_pos = lppt[cPoints - 1];
release_dc_ptr( dc );
return ret;
}
/***********************************************************************
* NtGdiAngleArc (win32u.@)
*/