[3/3] gdi32: improved PolyDraw

Evan Stade estade at gmail.com
Tue Jun 26 20:01:47 CDT 2007


Hi,

Before, PolyDraw did not behave correctly when encountering a
PT_CLOSEFIGURE type if there was an open path.

Changelog:
* adjusted PolyDraw behaviour when called with open path
* removed todo_wine from path test

 dlls/gdi32/painting.c   |   28 +++++++++++++++++++++++-----
 dlls/gdi32/tests/path.c |    2 +-
 2 files changed, 24 insertions(+), 6 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c
index 1b30d6d..923bd35 100644
--- a/dlls/gdi32/painting.c
+++ b/dlls/gdi32/painting.c
@@ -849,9 +849,24 @@ BOOL WINAPI PolyDraw(HDC hdc, const POIN
 		i += 2;
 	}
 
-    /* if no moveto occurs, we will close the figure here */
-    lastmove.x = dc->CursPosX;
-    lastmove.y = dc->CursPosY;
+    if( PATH_IsPathOpen( dc->path ) )
+    {
+        for( i = dc->path.numEntriesUsed-1; i >= 0; i-- ){
+            if(dc->path.pFlags[i] == PT_MOVETO){
+                lastmove = dc->path.pPoints[i];
+                break;
+            }
+        }
+        if(i < 0){
+            lastmove.x = 0;
+            lastmove.y = 0;
+        }
+    }
+    else{
+        /* if no moveto occurs, we will close the figure here */
+        lastmove.x = dc->CursPosX;
+        lastmove.y = dc->CursPosY;
+    }
 
     /* now let's draw */
     for( i = 0; i < cCount; i++ )
@@ -874,8 +889,11 @@ BOOL WINAPI PolyDraw(HDC hdc, const POIN
 
 	if( lpbTypes[i] & PT_CLOSEFIGURE )
 	{
-	    if( PATH_IsPathOpen( dc->path ) )
-		CloseFigure( hdc );
+	    if( PATH_IsPathOpen( dc->path ) ){
+            /* CloseFigure in a PolyDraw acts like a "CloseFigureTo" might act */
+            CloseFigure( hdc );
+            MoveToEx( hdc, lastmove.x, lastmove.y, NULL );
+        }
 	    else
 		LineTo( hdc, lastmove.x, lastmove.y );
 	}
diff --git a/dlls/gdi32/tests/path.c b/dlls/gdi32/tests/path.c
index 4453b43..e9f63db 100644
--- a/dlls/gdi32/tests/path.c
+++ b/dlls/gdi32/tests/path.c
@@ -345,7 +345,7 @@ static void test_polydraw(void)
     CloseFigure(hdc);
     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.1


More information about the wine-patches mailing list