[2/2] gdi32: fixed PolyDraw [try6]

Evan Stade estade at gmail.com
Sat Jul 7 15:18:08 CDT 2007


On 7/6/07, Evan Stade <estade at gmail.com> wrote:
> Hi,
>
> [try6] correct ordering of cases in painting.c's PolyDraw
>
>  dlls/gdi32/gdi_private.h |    1 +
>  dlls/gdi32/painting.c    |   11 +++++--
>  dlls/gdi32/path.c        |   69 ++++++++++++++++++++++++++++++++++++++++++++++
>  dlls/gdi32/tests/path.c  |   14 +++++----
>  4 files changed, 85 insertions(+), 10 deletions(-)
>
> --
> Evan Stade
>
>
Please use this one instead. The last one left in an obsolete if statement.

 dlls/gdi32/gdi_private.h |    1 +
 dlls/gdi32/painting.c    |   14 +++++----
 dlls/gdi32/path.c        |   69 ++++++++++++++++++++++++++++++++++++++++++++++
 dlls/gdi32/tests/path.c  |   14 ++++----
 4 files changed, 85 insertions(+), 13 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index c6810dd..73627d7 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -481,6 +481,7 @@ extern BOOL PATH_Arc(DC *dc, INT x1, INT
                      INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines);
 extern BOOL PATH_PolyBezierTo(DC *dc, const POINT *pt, DWORD cbCount);
 extern BOOL PATH_PolyBezier(DC *dc, const POINT *pt, DWORD cbCount);
+extern BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types, DWORD cbCount);
 extern BOOL PATH_PolylineTo(DC *dc, const POINT *pt, DWORD cbCount);
 extern BOOL PATH_Polyline(DC *dc, const POINT *pt, DWORD cbCount);
 extern BOOL PATH_Polygon(DC *dc, const POINT *pt, DWORD cbCount);
diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c
index 4a8b8c9..199cd45 100644
--- a/dlls/gdi32/painting.c
+++ b/dlls/gdi32/painting.c
@@ -830,12 +830,15 @@ BOOL WINAPI PolyDraw(HDC hdc, const POIN
     dc = DC_GetDCUpdate( hdc );
     if(!dc) return FALSE;
 
-    if(dc->funcs->pPolyDraw)
+    if( PATH_IsPathOpen( dc->path ) )
+    {
+        result = PATH_PolyDraw(dc, lppt, lpbTypes, cCount);
+    }
+    else if(dc->funcs->pPolyDraw)
     {
         result = dc->funcs->pPolyDraw( dc->physDev, lppt, lpbTypes, cCount );
-        goto end;
     }
-
+    else {
     /* check for each bezierto if there are two more points */
     for( i = 0; i < cCount; i++ )
 	if( lpbTypes[i] != PT_MOVETO &&
@@ -872,14 +875,13 @@ BOOL WINAPI PolyDraw(HDC hdc, const POIN
 
 	if( lpbTypes[i] & PT_CLOSEFIGURE )
 	{
-	    if( PATH_IsPathOpen( dc->path ) )
-		CloseFigure( hdc );
-	    else
 		LineTo( hdc, lastmove.x, lastmove.y );
 	}
     }
 
     result = TRUE;
+    }
+
 end:
     GDI_ReleaseObj( hdc );
     return result;
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index 1a37adc..f000a25 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -933,6 +933,75 @@ BOOL PATH_PolyBezier(DC *dc, const POINT
    return TRUE;
 }
 
+/* PATH_PolyDraw
+ *
+ * Should be called when a call to PolyDraw is performed on a DC that has
+ * an open path. Returns TRUE if successful, else FALSE.
+ */
+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;
+            }
+        }
+
+        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);
+                i += 2;
+            }
+            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;
+            }
+        }
+
+        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)
 {
    GdiPath     *pPath = &dc->path;
diff --git a/dlls/gdi32/tests/path.c b/dlls/gdi32/tests/path.c
index 8e389f3..b0b330d 100644
--- a/dlls/gdi32/tests/path.c
+++ b/dlls/gdi32/tests/path.c
@@ -301,12 +301,12 @@ static const path_test_t polydraw_path[]
     {95, 95, 2, 0, 0}, /*4*/
     {10, 10, 2, 0, 0}, /*5*/
     {10, 15, 3, 0, 0}, /*6*/
-    {100, 100, 6, 0, 1}, /*7*/
-    {15, 15, 2, 0, 1}, /*8*/
-    {100, 100, 6, 0, 1}, /*9*/
-    {30, 30, 4, 0, 1}, /*10*/
-    {30, 35, 4, 0, 1}, /*11*/
-    {35, 35, 4, 0, 1}, /*12*/
+    {100, 100, 6, 0, 0}, /*7*/
+    {15, 15, 2, 0, 0}, /*8*/
+    {100, 100, 6, 0, 0}, /*9*/
+    {30, 30, 4, 0, 0}, /*10*/
+    {30, 35, 4, 0, 0}, /*11*/
+    {35, 35, 4, 0, 0}, /*12*/
     {45, 50, 2, 0, 0}, /*13*/
     {35, 35, 6, 0, 0}, /*14*/
     {50, 55, 2, 0, 0}, /*15*/
@@ -368,7 +368,7 @@ static void test_polydraw(void)
 
     EndPath(hdc);
 
-    ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t), 1);
+    ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t), 0);
 done:
     ReleaseDC(0, hdc);
 }
-- 
1.4.3.4


More information about the wine-patches mailing list