Jeff Smith : gdiplus: Calculate centroid of path as default center of path gradient.

Alexandre Julliard julliard at winehq.org
Thu Jan 23 15:48:50 CST 2020


Module: wine
Branch: master
Commit: 1802ca5e344ba7d6ffb9805bdc46c23e115fb3f9
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1802ca5e344ba7d6ffb9805bdc46c23e115fb3f9

Author: Jeff Smith <whydoubt at gmail.com>
Date:   Wed Jan 22 11:03:27 2020 -0600

gdiplus: Calculate centroid of path as default center of path gradient.

Signed-off-by: Jeff Smith <whydoubt at gmail.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/brush.c       | 16 ++++++++++------
 dlls/gdiplus/tests/brush.c |  6 +++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index e321dcaa60..ff0b009559 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -574,7 +574,8 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect
 
 static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradient **grad)
 {
-    GpRectF bounds;
+    INT i;
+    REAL sum_x = 0, sum_y = 0;
 
     if(!path || !grad)
         return InvalidParameter;
@@ -582,8 +583,6 @@ static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradi
     if (path->pathdata.Count < 2)
         return OutOfMemory;
 
-    GdipGetPathWorldBounds(path, &bounds, NULL, NULL);
-
     *grad = heap_alloc_zero(sizeof(GpPathGradient));
     if (!*grad)
     {
@@ -613,9 +612,14 @@ static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradi
     (*grad)->centercolor = centercolor;
     (*grad)->wrap = WrapModeClamp;
     (*grad)->gamma = FALSE;
-    /* FIXME: this should be set to the "centroid" of the path by default */
-    (*grad)->center.X = bounds.X + bounds.Width / 2;
-    (*grad)->center.Y = bounds.Y + bounds.Height / 2;
+    for (i=0; i<path->pathdata.Count; i++)
+    {
+        sum_x += path->pathdata.Points[i].X;
+        sum_y += path->pathdata.Points[i].Y;
+    }
+    (*grad)->center.X = sum_x / path->pathdata.Count;
+    (*grad)->center.Y = sum_y / path->pathdata.Count;
+
     (*grad)->focus.X = 0.0;
     (*grad)->focus.Y = 0.0;
     (*grad)->surroundcolors[0] = 0xffffffff;
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index c67ab74708..b8067c735c 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -1342,8 +1342,8 @@ static void test_pathgradientcenterpoint(void)
 
     status = GdipGetPathGradientCenterPoint(grad, &point);
     expect(Ok, status);
-    todo_wine expectf(1.0, point.X);
-    todo_wine expectf(4.0/3.0, point.Y);
+    expectf(1.0, point.X);
+    expectf(4.0/3.0, point.Y);
 
     status = GdipDeleteBrush((GpBrush*)grad);
     expect(Ok, status);
@@ -1359,7 +1359,7 @@ static void test_pathgradientcenterpoint(void)
 
     status = GdipGetPathGradientCenterPoint(grad, &point);
     expect(Ok, status);
-    todo_wine expectf(700.0/13.0, point.X);
+    expectf(700.0/13.0, point.X);
     expectf(25.0, point.Y);
 
     status = GdipDeletePath(path);




More information about the wine-cvs mailing list