[15/15] gdiplus: added start cap rendering for lines

Evan Stade estade at gmail.com
Thu Jul 19 20:23:17 CDT 2007


Hi,

previously only end caps were actually drawn.

 dlls/gdiplus/graphics.c |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 22fcf63..21fe203 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -361,8 +361,8 @@ static void shorten_line_amt(REAL x1, RE
 static GpStatus draw_polyline(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
     INT count, BOOL caps)
 {
-    POINT *pti;
-    REAL x = pt[count - 1].X, y = pt[count - 1].Y;
+    POINT *pti = NULL;
+    GpPointF *ptcopy = NULL;
     INT i;
     GpStatus status = GenericError;
 
@@ -370,35 +370,48 @@ static GpStatus draw_polyline(HDC hdc, G
         return Ok;
 
     pti = GdipAlloc(count * sizeof(POINT));
+    ptcopy = GdipAlloc(count * sizeof(GpPointF));
 
-    if(!pti){
+    if(!pti || !ptcopy){
         status = OutOfMemory;
         goto end;
     }
 
+    memcpy(ptcopy, pt, count * sizeof(GpPointF));
+
     if(caps){
         if(pen->endcap == LineCapArrowAnchor)
-            shorten_line_amt(pt[count-2].X, pt[count-2].Y, &x, &y, pen->width);
+            shorten_line_amt(ptcopy[count-2].X, ptcopy[count-2].Y,
+                             &ptcopy[count-1].X, &ptcopy[count-1].Y, pen->width);
         else if((pen->endcap == LineCapCustom) && pen->customend)
-            shorten_line_amt(pt[count-2].X, pt[count-2].Y, &x, &y,
+            shorten_line_amt(ptcopy[count-2].X, ptcopy[count-2].Y,
+                             &ptcopy[count-1].X, &ptcopy[count-1].Y,
+                             pen->customend->inset * pen->width);
+
+        if(pen->startcap == LineCapArrowAnchor)
+            shorten_line_amt(ptcopy[1].X, ptcopy[1].Y,
+                             &ptcopy[0].X, &ptcopy[0].Y, pen->width);
+        else if((pen->startcap == LineCapCustom) && pen->customstart)
+            shorten_line_amt(ptcopy[1].X, ptcopy[1].Y,
+                             &ptcopy[0].X, &ptcopy[0].Y,
                              pen->customend->inset * pen->width);
 
         draw_cap(hdc, pen->color, pen->endcap, pen->width, pen->customend,
-                 pt[count-2].X, pt[count-2].Y, pt[count - 1].X, pt[count - 1].Y);
+                 pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X, pt[count - 1].Y);
+        draw_cap(hdc, pen->color, pen->startcap, pen->width, pen->customstart,
+                         pt[1].X, pt[1].Y, pt[0].X, pt[0].Y);
     }
 
-    for(i = 0; i < count - 1; i ++){
-        pti[i].x = roundr(pt[i].X);
-        pti[i].y = roundr(pt[i].Y);
+    for(i = 0; i < count; i ++){
+        pti[i].x = roundr(ptcopy[i].X);
+        pti[i].y = roundr(ptcopy[i].Y);
     }
 
-    pti[i].x = roundr(x);
-    pti[i].y = roundr(y);
-
     Polyline(hdc, pti, count);
 
 end:
     GdipFree(pti);
+    GdipFree(ptcopy);
 
     return status;
 }
-- 
1.4.1


More information about the wine-patches mailing list