Commit 099bfbe1 authored by Evan Stade's avatar Evan Stade Committed by Alexandre Julliard

gdi32: Improved PolyDraw in path closed case.

parent 00631b24
...@@ -824,8 +824,8 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes, ...@@ -824,8 +824,8 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
{ {
DC *dc; DC *dc;
BOOL result = FALSE; BOOL result = FALSE;
POINT lastmove; POINT * line_pts = NULL, * bzr_pts = NULL, bzr[4];
unsigned int i; INT i, num_pts, num_bzr_pts, space, size;
dc = DC_GetDCUpdate( hdc ); dc = DC_GetDCUpdate( hdc );
if(!dc) return FALSE; if(!dc) return FALSE;
...@@ -835,46 +835,75 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes, ...@@ -835,46 +835,75 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
else if(dc->funcs->pPolyDraw) else if(dc->funcs->pPolyDraw)
result = dc->funcs->pPolyDraw( dc->physDev, lppt, lpbTypes, cCount ); result = dc->funcs->pPolyDraw( dc->physDev, lppt, lpbTypes, cCount );
else { else {
/* check for each bezierto if there are two more points */ /* check for valid point types */
for( i = 0; i < cCount; i++ ) for(i = 0; i < cCount; i++) {
if( lpbTypes[i] != PT_MOVETO && switch(lpbTypes[i]) {
lpbTypes[i] & PT_BEZIERTO ) case PT_MOVETO:
{ case PT_LINETO | PT_CLOSEFIGURE:
if( cCount < i+3 ) case PT_LINETO:
goto end; break;
else case PT_BEZIERTO:
if((i + 2 < cCount) && (lpbTypes[i + 1] == PT_BEZIERTO) &&
((lpbTypes[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)){
i += 2; i += 2;
break;
}
default:
goto end;
}
} }
/* if no moveto occurs, we will close the figure here */ space = cCount + 300;
lastmove.x = dc->CursPosX; line_pts = HeapAlloc(GetProcessHeap(), 0, space * sizeof(POINT));
lastmove.y = dc->CursPosY; num_pts = 1;
/* now let's draw */ line_pts[0].x = dc->CursPosX;
for( i = 0; i < cCount; i++ ) line_pts[0].y = dc->CursPosY;
{
if( lpbTypes[i] == PT_MOVETO ) for(i = 0; i < cCount; i++) {
{ switch(lpbTypes[i]) {
MoveToEx( hdc, lppt[i].x, lppt[i].y, NULL ); case PT_MOVETO:
lastmove.x = dc->CursPosX; if(num_pts >= 2)
lastmove.y = dc->CursPosY; Polyline(dc->hSelf, line_pts, num_pts);
} num_pts = 0;
else if( lpbTypes[i] & PT_LINETO ) line_pts[num_pts++] = lppt[i];
LineTo( hdc, lppt[i].x, lppt[i].y ); break;
else if( lpbTypes[i] & PT_BEZIERTO ) case PT_LINETO:
{ case (PT_LINETO | PT_CLOSEFIGURE):
PolyBezierTo( hdc, &lppt[i], 3 ); line_pts[num_pts++] = lppt[i];
break;
case PT_BEZIERTO:
bzr[0].x = line_pts[num_pts - 1].x;
bzr[0].y = line_pts[num_pts - 1].y;
memcpy(&bzr[1], &lppt[i], 3 * sizeof(POINT));
bzr_pts = GDI_Bezier(bzr, 4, &num_bzr_pts);
size = num_pts + (cCount - i) + num_bzr_pts;
if(space < size){
space = size * 2;
line_pts = HeapReAlloc(GetProcessHeap(), 0, line_pts,
space * sizeof(POINT));
}
memcpy(&line_pts[num_pts], &bzr_pts[1],
(num_bzr_pts - 1) * sizeof(POINT));
num_pts += num_bzr_pts - 1;
HeapFree(GetProcessHeap(), 0, bzr_pts);
i += 2; i += 2;
} break;
else default:
goto end; goto end;
if( lpbTypes[i] & PT_CLOSEFIGURE )
{
LineTo( hdc, lastmove.x, lastmove.y );
} }
if(lpbTypes[i] & PT_CLOSEFIGURE)
line_pts[num_pts++] = line_pts[0];
} }
if(num_pts >= 2)
Polyline(dc->hSelf, line_pts, num_pts);
MoveToEx(dc->hSelf, line_pts[num_pts - 1].x, line_pts[num_pts - 1].y, NULL);
result = TRUE; result = TRUE;
} }
......
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