[Libreoffice-commits] core.git: vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 30 13:56:52 UTC 2020


 vcl/skia/gdiimpl.cxx |   53 +++++++++++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 18 deletions(-)

New commits:
commit fa4fe362cd15f89996cf877f31efbac7363f64af
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Apr 29 16:12:11 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Apr 30 15:56:16 2020 +0200

    implement basegfx::B2DLineJoin::NONE for Skia drawPolyLine()
    
    Change-Id: I186622aec3e944b89536bdcd44ff0be6b1d9cd8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93213
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 2ffd68dee132..efecb95b7920 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -778,12 +778,6 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
     const basegfx::B2DVector aLineWidth(rLineWidth.equalZero() ? basegfx::B2DVector(1.0, 1.0)
                                                                : rObjectToDevice * rLineWidth);
 
-    // Skia does not support B2DLineJoin::NONE; return false to use
-    // the fallback (own geometry preparation),
-    // linejoin-mode and thus the above only applies to "fat" lines.
-    if ((basegfx::B2DLineJoin::NONE == eLineJoin) && (aLineWidth.getX() > 1.3))
-        return false;
-
     // MM01 need to do line dashing as fallback stuff here now
     const double fDotDashLength(
         nullptr != pStroke ? std::accumulate(pStroke->begin(), pStroke->end(), 0.0) : 0.0);
@@ -857,21 +851,44 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
     aPaint.setStrokeWidth(aLineWidth.getX());
     aPaint.setAntiAlias(mParent.getAntiAliasB2DDraw());
 
-    SkPath aPath;
-
-    // MM01 checked/verified for Skia (on Win)
-    for (sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++)
+    if (eLineJoin != basegfx::B2DLineJoin::NONE)
+    {
+        SkPath aPath;
+        aPath.setFillType(SkPathFillType::kEvenOdd);
+        for (sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++)
+            addPolygonToPath(aPolyPolygonLine.getB2DPolygon(a), aPath);
+        // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU
+        // case as it seems to produce better results.
+        aPath.offset(0.5, 0.5, nullptr);
+        getDrawCanvas()->drawPath(aPath, aPaint);
+        addXorRegion(aPath.getBounds());
+    }
+    else // Skia does not support basegfx::B2DLineJoin::NONE, draw each line separately
     {
-        const basegfx::B2DPolygon aPolyLine(aPolyPolygonLine.getB2DPolygon(a));
-        addPolygonToPath(aPolyLine, aPath);
+        for (sal_uInt32 i = 0; i < aPolyPolygonLine.count(); ++i)
+        {
+            const basegfx::B2DPolygon& rPolygon = aPolyPolygonLine.getB2DPolygon(i);
+            sal_uInt32 nPoints = rPolygon.count();
+            bool bClosed = rPolygon.isClosed();
+            for (sal_uInt32 j = 0; j < (bClosed ? nPoints : nPoints - 1); ++j)
+            {
+                sal_uInt32 index1 = (j + 0) % nPoints;
+                sal_uInt32 index2 = (j + 1) % nPoints;
+                SkPath aPath;
+                aPath.moveTo(rPolygon.getB2DPoint(index1).getX(),
+                             rPolygon.getB2DPoint(index1).getY());
+                aPath.lineTo(rPolygon.getB2DPoint(index2).getX(),
+                             rPolygon.getB2DPoint(index2).getY());
+
+                // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU
+                // case as it seems to produce better results.
+                aPath.offset(0.5, 0.5, nullptr);
+                getDrawCanvas()->drawPath(aPath, aPaint);
+                addXorRegion(aPath.getBounds());
+            }
+        }
     }
 
-    aPath.setFillType(SkPathFillType::kEvenOdd);
-    // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU
-    // case as it seems to produce better results.
-    aPath.offset(0.5, 0.5, nullptr);
-    getDrawCanvas()->drawPath(aPath, aPaint);
-    addXorRegion(aPath.getBounds());
     postDraw();
 
     return true;


More information about the Libreoffice-commits mailing list