[1/3] gdiplus: Implement LineCapSquare in GdipWidenPath.

Vincent Povirk madewokherd at gmail.com
Thu Sep 20 16:50:46 CDT 2012


-------------- next part --------------
From 1ce6696d787e0e57d34086ab5a9d1d4447266a82 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 20 Sep 2012 15:16:58 -0500
Subject: [PATCH 1/3] gdiplus: Implement LineCapSquare in GdipWidenPath.

---
 dlls/gdiplus/graphicspath.c |   29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 16f5e2d..0515175 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -1774,6 +1774,31 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint,
         if (add_last_point)
             add_bevel_point(endpoint, nextpoint, pen, 0, last_point);
         break;
+    case LineCapSquare:
+    {
+        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 bevel_dx, bevel_dy;
+        REAL extend_dx, extend_dy;
+
+        extend_dx = -distance * segment_dx / segment_length;
+        extend_dy = -distance * segment_dy / segment_length;
+
+        bevel_dx = -distance * segment_dy / segment_length;
+        bevel_dy = distance * segment_dx / segment_length;
+
+        if (add_first_points)
+            *last_point = add_path_list_node(*last_point, endpoint->X + extend_dx + bevel_dx,
+                endpoint->Y + extend_dy + bevel_dy, PathPointTypeLine);
+
+        if (add_last_point)
+            *last_point = add_path_list_node(*last_point, endpoint->X + extend_dx - bevel_dx,
+                endpoint->Y + extend_dy - bevel_dy, PathPointTypeLine);
+
+        break;
+    }
     }
 }
 
@@ -1878,10 +1903,10 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
     {
         last_point = points;
 
-        if (pen->endcap != LineCapFlat)
+        if (pen->endcap > LineCapSquare)
             FIXME("unimplemented end cap %x\n", pen->endcap);
 
-        if (pen->startcap != LineCapFlat)
+        if (pen->startcap > LineCapSquare)
             FIXME("unimplemented start cap %x\n", pen->startcap);
 
         if (pen->dashcap != DashCapFlat)
-- 
1.7.9.5


More information about the wine-patches mailing list