gdi32: Generate EMR_POLYPOLY{LINE|GON}16 records if the co-ords fit.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ce3921df33
commit
2e4a37f2cf
|
@ -482,11 +482,11 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po
|
||||||
DWORD iType)
|
DWORD iType)
|
||||||
{
|
{
|
||||||
EMRPOLYPOLYLINE *emr;
|
EMRPOLYPOLYLINE *emr;
|
||||||
DWORD cptl = 0, poly, size;
|
DWORD cptl = 0, poly, size, i;
|
||||||
INT point;
|
INT point;
|
||||||
RECTL bounds;
|
RECTL bounds;
|
||||||
const POINT *pts;
|
const POINT *pts;
|
||||||
BOOL ret;
|
BOOL ret, use_small_emr = TRUE;
|
||||||
|
|
||||||
bounds.left = bounds.right = pt[0].x;
|
bounds.left = bounds.right = pt[0].x;
|
||||||
bounds.top = bounds.bottom = pt[0].y;
|
bounds.top = bounds.bottom = pt[0].y;
|
||||||
|
@ -495,6 +495,10 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po
|
||||||
for(poly = 0; poly < polys; poly++) {
|
for(poly = 0; poly < polys; poly++) {
|
||||||
cptl += counts[poly];
|
cptl += counts[poly];
|
||||||
for(point = 0; point < counts[poly]; point++) {
|
for(point = 0; point < counts[poly]; point++) {
|
||||||
|
/* check whether all points fit in the SHORT int POINT structure */
|
||||||
|
if( ((pts->x+0x8000) & ~0xffff ) ||
|
||||||
|
((pts->y+0x8000) & ~0xffff ) )
|
||||||
|
use_small_emr = FALSE;
|
||||||
if(bounds.left > pts->x) bounds.left = pts->x;
|
if(bounds.left > pts->x) bounds.left = pts->x;
|
||||||
else if(bounds.right < pts->x) bounds.right = pts->x;
|
else if(bounds.right < pts->x) bounds.right = pts->x;
|
||||||
if(bounds.top > pts->y) bounds.top = pts->y;
|
if(bounds.top > pts->y) bounds.top = pts->y;
|
||||||
|
@ -503,18 +507,41 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size = sizeof(EMRPOLYPOLYLINE) + (polys - 1) * sizeof(DWORD) +
|
size = FIELD_OFFSET(EMRPOLYPOLYLINE, aPolyCounts[polys]);
|
||||||
(cptl - 1) * sizeof(POINTL);
|
if(use_small_emr)
|
||||||
|
size += cptl * sizeof(POINTS);
|
||||||
|
else
|
||||||
|
size += cptl * sizeof(POINTL);
|
||||||
|
|
||||||
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
||||||
|
|
||||||
emr->emr.iType = iType;
|
emr->emr.iType = iType;
|
||||||
|
if(use_small_emr) emr->emr.iType += EMR_POLYPOLYLINE16 - EMR_POLYPOLYLINE;
|
||||||
|
|
||||||
emr->emr.nSize = size;
|
emr->emr.nSize = size;
|
||||||
emr->rclBounds = bounds;
|
emr->rclBounds = bounds;
|
||||||
emr->nPolys = polys;
|
emr->nPolys = polys;
|
||||||
emr->cptl = cptl;
|
emr->cptl = cptl;
|
||||||
memcpy(emr->aPolyCounts, counts, polys * sizeof(DWORD));
|
|
||||||
memcpy(emr->aPolyCounts + polys, pt, cptl * sizeof(POINTL));
|
if(polys)
|
||||||
|
{
|
||||||
|
memcpy( emr->aPolyCounts, counts, polys * sizeof(DWORD) );
|
||||||
|
if(cptl)
|
||||||
|
{
|
||||||
|
if(use_small_emr)
|
||||||
|
{
|
||||||
|
POINTS *out_pts = (POINTS *)(emr->aPolyCounts + polys);
|
||||||
|
for(i = 0; i < cptl; i++ )
|
||||||
|
{
|
||||||
|
out_pts[i].x = pt[i].x;
|
||||||
|
out_pts[i].y = pt[i].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memcpy( emr->aPolyCounts + polys, pt, cptl * sizeof(POINTL) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
||||||
if(ret)
|
if(ret)
|
||||||
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
||||||
|
|
Loading…
Reference in New Issue