diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-07-16 11:37:52 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-07-16 16:01:14 +0200 |
commit | 777ac5456a1f24fea29931ede983b5b8ad9a063d (patch) | |
tree | da58fe38628fec502ffd286e5fe25d2cae732285 /drawinglayer | |
parent | b0ba9e835060f8f5daf3943a03039ed443705eba (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>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/svggradientprimitive2d.cxx | 10 |
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[) |