[PATCH] gdiplus: Implement triangular line caps in widened paths.

Clemens Tamme clemens.tamme at gmail.com
Sat Jun 17 10:28:28 CDT 2017


Pens in GDI+ have a startcap an an endcap property. Previously,
values LineCapFlat, LineCapSquare and LineCapRound were supported,
now LineCapTriangle is added.

This solves two FIXMEs in GdipWidenPath: unimplemented end cap 3
and unimplemented start cap 3 (3 being the value of
LineCapTriangle).

Test dlls/gdiplus/test/graphicspath.c runs on Ubuntu 16.04.

Signed-off-by: Clemens Tamme <clemens.tamme at gmail.com>
---
 dlls/gdiplus/graphicspath.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 3d33c29..e34f4ed 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -1883,6 +1883,27 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint,
         }
         break;
     }
+    case LineCapTriangle:
+    {
+        REAL segment_dy = nextpoint->Y-endpoint->Y;
+        REAL segment_dx = nextpoint->X-endpoint->X;
+        REAL segment_length = sqrtf(segment_dy*segment_dy + segment_dx*segment_dx);
+        REAL distance = pen->width/2.0;
+        REAL dx, dy;
+
+        dx = distance * segment_dx / segment_length;
+        dy = distance * segment_dy / segment_length;
+
+        if (add_first_points) {
+            add_bevel_point(endpoint, nextpoint, pen, 1, last_point);
+
+            *last_point = add_path_list_node(*last_point, endpoint->X - dx,
+                endpoint->Y - dy, PathPointTypeLine);
+        }
+        if (add_last_point)
+            add_bevel_point(endpoint, nextpoint, pen, 0, last_point);
+        break;
+    }
     }
 }
 
@@ -2118,10 +2139,10 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
     {
         last_point = points;
 
-        if (pen->endcap > LineCapRound)
+        if (pen->endcap > LineCapTriangle)
             FIXME("unimplemented end cap %x\n", pen->endcap);
 
-        if (pen->startcap > LineCapRound)
+        if (pen->startcap > LineCapTriangle)
             FIXME("unimplemented start cap %x\n", pen->startcap);
 
         if (pen->dashcap != DashCapFlat)
-- 
2.7.4




More information about the wine-patches mailing list