gdi32: Avoid directly modifying the cursor position in the DC structure in PolyDraw.

This commit is contained in:
Alexandre Julliard 2011-10-26 19:47:27 +02:00
parent da6363e377
commit 97a261d573
1 changed files with 44 additions and 49 deletions

View File

@ -1203,59 +1203,54 @@ BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types,
POINT lastmove, orig_pos; POINT lastmove, orig_pos;
INT i; INT i;
lastmove.x = orig_pos.x = dc->CursPosX; GetCurrentPositionEx( dc->hSelf, &orig_pos );
lastmove.y = orig_pos.y = dc->CursPosY; lastmove = orig_pos;
for(i = pPath->numEntriesUsed - 1; i >= 0; i--){ for(i = pPath->numEntriesUsed - 1; i >= 0; i--){
if(pPath->pFlags[i] == PT_MOVETO){ if(pPath->pFlags[i] == PT_MOVETO){
lastmove.x = pPath->pPoints[i].x; lastmove = pPath->pPoints[i];
lastmove.y = pPath->pPoints[i].y; DPtoLP(dc->hSelf, &lastmove, 1);
if(!DPtoLP(dc->hSelf, &lastmove, 1))
return FALSE;
break; break;
} }
} }
for(i = 0; i < cbPoints; i++){ for(i = 0; i < cbPoints; i++)
if(types[i] == PT_MOVETO){ {
pPath->newStroke = TRUE; switch (types[i])
lastmove.x = pts[i].x; {
lastmove.y = pts[i].y; case PT_MOVETO:
} MoveToEx( dc->hSelf, pts[i].x, pts[i].y, NULL );
else if((types[i] & ~PT_CLOSEFIGURE) == PT_LINETO){ break;
PATH_LineTo(dc, pts[i].x, pts[i].y); case PT_LINETO:
} case PT_LINETO | PT_CLOSEFIGURE:
else if(types[i] == PT_BEZIERTO){ LineTo( dc->hSelf, pts[i].x, pts[i].y );
if(!((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) break;
&& ((types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO))) case PT_BEZIERTO:
goto err; if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
PATH_PolyBezierTo(dc, &(pts[i]), 3); (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
{
PolyBezierTo( dc->hSelf, &pts[i], 3 );
i += 2; i += 2;
break;
}
/* fall through */
default:
if (i) /* restore original position */
{
if (!(types[i - 1] & PT_CLOSEFIGURE)) lastmove = pts[i - 1];
if (lastmove.x != orig_pos.x || lastmove.y != orig_pos.y)
MoveToEx( dc->hSelf, orig_pos.x, orig_pos.y, NULL );
}
return FALSE;
} }
else
goto err;
dc->CursPosX = pts[i].x;
dc->CursPosY = pts[i].y;
if(types[i] & PT_CLOSEFIGURE){ if(types[i] & PT_CLOSEFIGURE){
pPath->pFlags[pPath->numEntriesUsed-1] |= PT_CLOSEFIGURE; pPath->pFlags[pPath->numEntriesUsed-1] |= PT_CLOSEFIGURE;
pPath->newStroke = TRUE; MoveToEx( dc->hSelf, lastmove.x, lastmove.y, NULL );
dc->CursPosX = lastmove.x;
dc->CursPosY = lastmove.y;
} }
} }
return TRUE; return TRUE;
err:
if((dc->CursPosX != orig_pos.x) || (dc->CursPosY != orig_pos.y)){
pPath->newStroke = TRUE;
dc->CursPosX = orig_pos.x;
dc->CursPosY = orig_pos.y;
}
return FALSE;
} }
BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints) BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints)