[9/11] gdiplus: use custom cap base inset differently

Evan Stade estade at gmail.com
Thu Aug 2 19:53:08 CDT 2007


Hi,

My previous use of base inset was good at imitating extreme cases, but
this one is much simpler and seemingly better at imitating the way
pptviewer uses base inset.  It also happens to be the way base inset
*should* be used.  This version does not imitate windows well in
extreme cases but looks better in normal cases.

 dlls/gdiplus/graphics.c |   57 +++++++++++------------------------------------
 1 files changed, 13 insertions(+), 44 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 439dedd..ab19fa7 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -574,9 +574,8 @@ static void shorten_bezier_amt(GpPointF 
 static GpStatus draw_polybezier(GpGraphics *graphics, GpPen *pen,
     GDIPCONST GpPointF * pt, INT count, BOOL caps)
 {
-    POINT *pti, curpos;
+    POINT *pti;
     GpPointF *ptcopy;
-    REAL x, y;
     GpStatus status = GenericError;
 
     if(!count)
@@ -595,30 +594,14 @@ static GpStatus draw_polybezier(GpGraphi
     if(caps){
         if(pen->endcap == LineCapArrowAnchor)
             shorten_bezier_amt(&ptcopy[count-4], pen->width, FALSE);
-        /* FIXME The following is seemingly correct only for baseinset < 0 or
-         * baseinset > ~3. With smaller baseinsets, windows actually
-         * lengthens the bezier line instead of shortening it. */
-        else if((pen->endcap == LineCapCustom) && pen->customend){
-            x = pt[count - 1].X;
-            y = pt[count - 1].Y;
-            shorten_line_amt(pt[count - 2].X, pt[count - 2].Y, &x, &y,
-                             pen->width * pen->customend->inset);
-            MoveToEx(graphics->hdc, roundr(pt[count - 1].X), roundr(pt[count - 1].Y), &curpos);
-            LineTo(graphics->hdc, roundr(x), roundr(y));
-            MoveToEx(graphics->hdc, curpos.x, curpos.y, NULL);
-        }
+        else if((pen->endcap == LineCapCustom) && pen->customend)
+            shorten_bezier_amt(&ptcopy[count-4], pen->width * pen->customend->inset,
+                               FALSE);
 
         if(pen->startcap == LineCapArrowAnchor)
             shorten_bezier_amt(ptcopy, pen->width, TRUE);
-        else if((pen->startcap == LineCapCustom) && pen->customstart){
-            x = ptcopy[0].X;
-            y = ptcopy[0].Y;
-            shorten_line_amt(ptcopy[1].X, ptcopy[1].Y, &x, &y,
-                             pen->width * pen->customend->inset);
-            MoveToEx(graphics->hdc, roundr(pt[0].X), roundr(pt[0].Y), &curpos);
-            LineTo(graphics->hdc, roundr(x), roundr(y));
-            MoveToEx(graphics->hdc, curpos.x, curpos.y, NULL);
-        }
+        else if((pen->startcap == LineCapCustom) && pen->customstart)
+            shorten_bezier_amt(ptcopy, pen->width * pen->customend->inset, TRUE);
 
         /* the direction of the line cap is parallel to the direction at the
          * end of the bezier (which, if it has been shortened, is not the same
@@ -650,10 +633,9 @@ end:
 static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * pt,
     GDIPCONST BYTE * types, INT count, BOOL caps)
 {
-    POINT *pti = GdipAlloc(count * sizeof(POINT)), curpos;
+    POINT *pti = GdipAlloc(count * sizeof(POINT));
     BYTE *tp = GdipAlloc(count);
     GpPointF *ptcopy = GdipAlloc(count * sizeof(GpPointF));
-    REAL x = pt[count - 1].X, y = pt[count - 1].Y;
     INT i, j;
     GpStatus status = GenericError;
 
@@ -686,16 +668,9 @@ static GpStatus draw_poly(GpGraphics *gr
             case PathPointTypeBezier:
                 if(pen->endcap == LineCapArrowAnchor)
                     shorten_bezier_amt(&ptcopy[count - 4], pen->width, FALSE);
-                else if((pen->endcap == LineCapCustom) && pen->customend){
-                    x = pt[count - 1].X;
-                    y = pt[count - 1].Y;
-                    shorten_line_amt(pt[count - 2].X, pt[count - 2].Y, &x, &y,
-                                     pen->width * pen->customend->inset);
-                    MoveToEx(graphics->hdc, roundr(pt[count - 1].X),
-                             roundr(pt[count - 1].Y), &curpos);
-                    LineTo(graphics->hdc, roundr(x), roundr(y));
-                    MoveToEx(graphics->hdc, curpos.x, curpos.y, NULL);
-                }
+                else if((pen->endcap == LineCapCustom) && pen->customend)
+                    shorten_bezier_amt(&ptcopy[count - 4],
+                                       pen->width * pen->customend->inset, FALSE);
 
                 draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
                     pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
@@ -731,15 +706,9 @@ static GpStatus draw_poly(GpGraphics *gr
             case PathPointTypeBezier:
                 if(pen->startcap == LineCapArrowAnchor)
                     shorten_bezier_amt(&ptcopy[j - 1], pen->width, TRUE);
-                else if((pen->startcap == LineCapCustom) && pen->customstart){
-                    x = pt[j - 1].X;
-                    y = pt[j - 1].Y;
-                    shorten_line_amt(ptcopy[j].X, ptcopy[j].Y, &x, &y,
-                                     pen->width * pen->customstart->inset);
-                    MoveToEx(graphics->hdc, roundr(pt[j - 1].X), roundr(pt[j - 1].Y), &curpos);
-                    LineTo(graphics->hdc, roundr(x), roundr(y));
-                    MoveToEx(graphics->hdc, curpos.x, curpos.y, NULL);
-                }
+                else if((pen->startcap == LineCapCustom) && pen->customstart)
+                    shorten_bezier_amt(&ptcopy[j - 1],
+                                       pen->width * pen->customend->inset, TRUE);
 
                 draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
                     pt[j - 1].X - (ptcopy[j - 1].X - ptcopy[j].X),
-- 
1.4.1


More information about the wine-patches mailing list