summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-07-16 11:37:52 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2020-07-17 00:58:41 +0200
commitddf3b1226cf5816d2eefafe32a90b317fb172502 (patch)
tree6892e1d64513df4e141ed3f75f67862414edb926 /drawinglayer
parent52f004e27fbdef114a6fa1b467a7919ab1762dab (diff)
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@collabora.com> (cherry picked from commit 777ac5456a1f24fea29931ede983b5b8ad9a063d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98840 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/svggradientprimitive2d.cxx10
1 files changed, 8 insertions, 2 deletions
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[)