Alexandre Julliard : gdi32: Avoid directly modifying the cursor position in the DC structure in PolyDraw .
Alexandre Julliard
julliard at winehq.org
Thu Oct 27 13:30:10 CDT 2011
Module: wine
Branch: master
Commit: 97a261d573fec67d891bd763c660e7f2ec092636
URL: http://source.winehq.org/git/wine.git/?a=commit;h=97a261d573fec67d891bd763c660e7f2ec092636
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Oct 26 19:47:27 2011 +0200
gdi32: Avoid directly modifying the cursor position in the DC structure in PolyDraw.
---
dlls/gdi32/path.c | 91 +++++++++++++++++++++++++----------------------------
1 files changed, 43 insertions(+), 48 deletions(-)
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index e8c7eaa..9f44944 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -1199,63 +1199,58 @@ BOOL PATH_PolyBezier(DC *dc, const POINT *pts, DWORD cbPoints)
BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types,
DWORD cbPoints)
{
- GdiPath *pPath = &dc->path;
- POINT lastmove, orig_pos;
- INT i;
-
- lastmove.x = orig_pos.x = dc->CursPosX;
- lastmove.y = orig_pos.y = dc->CursPosY;
-
- for(i = pPath->numEntriesUsed - 1; i >= 0; i--){
- if(pPath->pFlags[i] == PT_MOVETO){
- lastmove.x = pPath->pPoints[i].x;
- lastmove.y = pPath->pPoints[i].y;
- if(!DPtoLP(dc->hSelf, &lastmove, 1))
- return FALSE;
- break;
- }
+ GdiPath *pPath = &dc->path;
+ POINT lastmove, orig_pos;
+ INT i;
+
+ GetCurrentPositionEx( dc->hSelf, &orig_pos );
+ lastmove = orig_pos;
+
+ for(i = pPath->numEntriesUsed - 1; i >= 0; i--){
+ if(pPath->pFlags[i] == PT_MOVETO){
+ lastmove = pPath->pPoints[i];
+ DPtoLP(dc->hSelf, &lastmove, 1);
+ break;
}
+ }
- for(i = 0; i < cbPoints; i++){
- if(types[i] == PT_MOVETO){
- pPath->newStroke = TRUE;
- lastmove.x = pts[i].x;
- lastmove.y = pts[i].y;
- }
- else if((types[i] & ~PT_CLOSEFIGURE) == PT_LINETO){
- PATH_LineTo(dc, pts[i].x, pts[i].y);
- }
- else if(types[i] == PT_BEZIERTO){
- if(!((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO)
- && ((types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)))
- goto err;
- PATH_PolyBezierTo(dc, &(pts[i]), 3);
+ for(i = 0; i < cbPoints; i++)
+ {
+ switch (types[i])
+ {
+ case PT_MOVETO:
+ MoveToEx( dc->hSelf, pts[i].x, pts[i].y, NULL );
+ break;
+ case PT_LINETO:
+ case PT_LINETO | PT_CLOSEFIGURE:
+ LineTo( dc->hSelf, pts[i].x, pts[i].y );
+ break;
+ case PT_BEZIERTO:
+ if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
+ (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
+ {
+ PolyBezierTo( dc->hSelf, &pts[i], 3 );
i += 2;
+ break;
}
- else
- goto err;
-
- dc->CursPosX = pts[i].x;
- dc->CursPosY = pts[i].y;
-
- if(types[i] & PT_CLOSEFIGURE){
- pPath->pFlags[pPath->numEntriesUsed-1] |= PT_CLOSEFIGURE;
- pPath->newStroke = TRUE;
- dc->CursPosX = lastmove.x;
- dc->CursPosY = lastmove.y;
+ /* 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;
}
- 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;
+ if(types[i] & PT_CLOSEFIGURE){
+ pPath->pFlags[pPath->numEntriesUsed-1] |= PT_CLOSEFIGURE;
+ MoveToEx( dc->hSelf, lastmove.x, lastmove.y, NULL );
}
+ }
- return FALSE;
+ return TRUE;
}
BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints)
More information about the wine-cvs
mailing list