[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - drawinglayer/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 16 22:59:13 UTC 2020


 drawinglayer/source/primitive2d/svggradientprimitive2d.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit ddf3b1226cf5816d2eefafe32a90b317fb172502
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Jul 16 11:37:52 2020 +0200
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Fri Jul 17 00:58:41 2020 +0200

    hack for gradients split into adjacent polygons (tdf#133016)
    
    Converting a gradient to a group of adjacent polygons is silly
    (at least according to Skia developers), because adjacent polygon
    edges are guaranteed to line up perfectly only if antialising
    is not used.
    
    Change-Id: I38696c10b14958936cf97d4001c0ea0dfcadaa58
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98886
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    (cherry picked from commit 777ac5456a1f24fea29931ede983b5b8ad9a063d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98840
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
index d3e32e22ea46..e6906a638084 100644
--- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
@@ -30,7 +30,7 @@
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 #include <sal/log.hxx>
 #include <cmath>
-
+#include <vcl/skia/SkiaHelper.hxx>
 
 using namespace com::sun::star;
 
@@ -868,6 +868,12 @@ namespace drawinglayer::primitive2d
             // use color distance and discrete lengths to calculate step count
             const sal_uInt32 nSteps(calculateStepsForSvgGradient(getColorA(), getColorB(), fDelta, fDiscreteUnit));
 
+            // HACK: Splitting a gradient into adjacent polygons with gradually changing color is silly.
+            // If antialiasing is used to draw them, the AA-ed adjacent edges won't line up perfectly
+            // because of the AA (see SkiaSalGraphicsImpl::mergePolyPolygonToPrevious()).
+            // Make the polygons a bit wider, so they the partial overlap "fixes" this.
+            const double fixup = SkiaHelper::isVCLSkiaEnabled() ? fDiscreteUnit / 2 : 0;
+
             // tdf#117949 Use a small amount of discrete overlap at the edges. Usually this
             // should be exactly 0.0 and 1.0, but there were cases when this gets clipped
             // against the mask polygon which got numerically problematic.
@@ -881,7 +887,7 @@ namespace drawinglayer::primitive2d
                     basegfx::B2DRange(
                         getOffsetA() - fDiscreteUnit,
                         -0.0001, // TTTT -> should be 0.0, see comment above
-                        getOffsetA() + (fDelta / nSteps) + fDiscreteUnit,
+                        getOffsetA() + (fDelta / nSteps) + fDiscreteUnit + fixup,
                         1.0001))); // TTTT -> should be 1.0, see comment above
 
             // prepare loop (inside to outside, [0.0 .. 1.0[)


More information about the Libreoffice-commits mailing list