summaryrefslogtreecommitdiff
path: root/vcl/skia
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-15 16:07:10 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-06-16 09:51:53 +0200
commit120070f252585fccf36a2edc32d797306fdf7e33 (patch)
treef816a696e647da57076c1892437d6971af69b78a /vcl/skia
parent7b137e5c7b25438cc56d988ca5dab099afbb31a5 (diff)
implement Skia workaround for adjacent AA-ed polygons (tdf#133016)
Non-antialised adjacent polygons line up perfectly when drawn, and LO code assumes this is the case even when AA is enabled, which seems to work with Cairo, but not with Skia. So add a hack. Ideally LO code should not use such polygons. Change-Id: Ib46139db80f7bda78fde3aac4244da391133b7cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96369 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia')
-rw-r--r--vcl/skia/gdiimpl.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 7e522304c85d..7acb0f35d07f 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -708,6 +708,24 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectTo
aPaint.setColor(toSkColorWithTransparency(mFillColor, fTransparency));
aPaint.setStyle(SkPaint::kFill_Style);
getDrawCanvas()->drawPath(aPath, aPaint);
+ // There is some code that needlessly subdivides areas into adjacent rectangles,
+ // but Skia doesn't line them up perfectly if AA is enabled (e.g. Cairo, Qt5 do,
+ // but Skia devs claim it's working as intended
+ // https://groups.google.com/d/msg/skia-discuss/NlKpD2X_5uc/Vuwd-kyYBwAJ).
+ // An example is tdf#133016, which triggers SvgStyleAttributes::add_stroke()
+ // implementing a line stroke as a bunch of polygons instead of just one, and
+ // SvgLinearAtomPrimitive2D::create2DDecomposition() creates a gradient
+ // as a series of polygons of gradually changing color. Those places should be
+ // changed, but for now explicitly draw the polygon outline in these cases,
+ // which will fill the holes between polygons left by AA.
+ // TODO: If fTransparency != 0 then this will draw some pixels twice, if that
+ // is a problem then this can be handled by drawing to a temporary surface
+ // and drawing that using the given transparency.
+ if (mParent.getAntiAliasB2DDraw() && mLineColor == SALCOLOR_NONE)
+ {
+ aPaint.setStyle(SkPaint::kStroke_Style);
+ getDrawCanvas()->drawPath(aPath, aPaint);
+ }
}
if (mLineColor != SALCOLOR_NONE)
{