Commit 6e05189b authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Don't update the bounds if any poly{line|gon} has fewer than two points.

parent 2e4a37f2
...@@ -484,28 +484,33 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po ...@@ -484,28 +484,33 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po
EMRPOLYPOLYLINE *emr; EMRPOLYPOLYLINE *emr;
DWORD cptl = 0, poly, size, i; DWORD cptl = 0, poly, size, i;
INT point; INT point;
RECTL bounds; const RECTL empty = {0, 0, -1, -1};
RECTL bounds = empty;
const POINT *pts; const POINT *pts;
BOOL ret, use_small_emr = TRUE; BOOL ret, use_small_emr = TRUE, bounds_valid = TRUE;
bounds.left = bounds.right = pt[0].x;
bounds.top = bounds.bottom = pt[0].y;
pts = pt; pts = pt;
for(poly = 0; poly < polys; poly++) { for(poly = 0; poly < polys; poly++) {
cptl += counts[poly]; cptl += counts[poly];
if(counts[poly] < 2) bounds_valid = FALSE;
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 */ /* check whether all points fit in the SHORT int POINT structure */
if( ((pts->x+0x8000) & ~0xffff ) || if( ((pts->x+0x8000) & ~0xffff ) ||
((pts->y+0x8000) & ~0xffff ) ) ((pts->y+0x8000) & ~0xffff ) )
use_small_emr = FALSE; use_small_emr = FALSE;
if(pts == pt) {
bounds.left = bounds.right = pts->x;
bounds.top = bounds.bottom = pts->y;
} else {
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;
else if(bounds.bottom < pts->y) bounds.bottom = pts->y; else if(bounds.bottom < pts->y) bounds.bottom = pts->y;
}
pts++; pts++;
} }
} }
if(!cptl) bounds_valid = FALSE;
size = FIELD_OFFSET(EMRPOLYPOLYLINE, aPolyCounts[polys]); size = FIELD_OFFSET(EMRPOLYPOLYLINE, aPolyCounts[polys]);
if(use_small_emr) if(use_small_emr)
...@@ -519,7 +524,10 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po ...@@ -519,7 +524,10 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po
if(use_small_emr) emr->emr.iType += EMR_POLYPOLYLINE16 - EMR_POLYPOLYLINE; if(use_small_emr) emr->emr.iType += EMR_POLYPOLYLINE16 - EMR_POLYPOLYLINE;
emr->emr.nSize = size; emr->emr.nSize = size;
if(bounds_valid)
emr->rclBounds = bounds; emr->rclBounds = bounds;
else
emr->rclBounds = empty;
emr->nPolys = polys; emr->nPolys = polys;
emr->cptl = cptl; emr->cptl = cptl;
...@@ -543,6 +551,11 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po ...@@ -543,6 +551,11 @@ EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT po
} }
ret = EMFDRV_WriteRecord( dev, &emr->emr ); ret = EMFDRV_WriteRecord( dev, &emr->emr );
if(ret && !bounds_valid)
{
ret = FALSE;
SetLastError( ERROR_INVALID_PARAMETER );
}
if(ret) if(ret)
EMFDRV_UpdateBBox( dev, &emr->rclBounds ); EMFDRV_UpdateBBox( dev, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr ); HeapFree( GetProcessHeap(), 0, emr );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment