vcl/skia/gdiimpl.cxx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
New commits: commit 7957a3c6ab6ba4b61b0a237b680e6393029cc426 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon Aug 31 15:48:42 2020 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Tue Sep 1 18:52:25 2020 +0200 no polygon merge in Skia if they contain no straight lines (tdf#136240) Merging polygons with beziers is even more expensive, and those are very unlikely to be parts of a larger polygon that are meant to line up perfectly. Change-Id: Ic9d641d3264b962896347ed52addeca2a0d5ea22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101742 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index a0299160496c..15c9937c26e7 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -132,6 +132,54 @@ void addPolyPolygonToPath(const basegfx::B2DPolyPolygon& rPolyPolygon, SkPath& r } } +// Check if the given polygon contains a straight line. If not, it consists +// solely of curves. +bool polygonContainsLine(const basegfx::B2DPolyPolygon& rPolyPolygon) +{ + if (!rPolyPolygon.areControlPointsUsed()) + return true; // no curves at all + for (const auto& rPolygon : rPolyPolygon) + { + const sal_uInt32 nPointCount(rPolygon.count()); + bool bFirst = true; + + const bool bClosePath(rPolygon.isClosed()); + + sal_uInt32 nCurrentIndex = 0; + sal_uInt32 nPreviousIndex = nPointCount - 1; + + basegfx::B2DPoint aCurrentPoint; + basegfx::B2DPoint aPreviousPoint; + + for (sal_uInt32 nIndex = 0; nIndex <= nPointCount; nIndex++) + { + if (nIndex == nPointCount && !bClosePath) + continue; + + // Make sure we loop the last point to first point + nCurrentIndex = nIndex % nPointCount; + if (bFirst) + bFirst = false; + else + { + basegfx::B2DPoint aPreviousControlPoint + = rPolygon.getNextControlPoint(nPreviousIndex); + basegfx::B2DPoint aCurrentControlPoint + = rPolygon.getPrevControlPoint(nCurrentIndex); + + if (aPreviousControlPoint.equal(aPreviousPoint) + && aCurrentControlPoint.equal(aCurrentPoint)) + { + return true; // found a straight line + } + } + aPreviousPoint = aCurrentPoint; + nPreviousIndex = nCurrentIndex; + } + } + return false; // no straight line found +} + SkColor toSkColor(Color color) { return SkColorSetARGB(255 - color.GetTransparency(), color.GetRed(), color.GetGreen(), @@ -818,6 +866,11 @@ bool SkiaSalGraphicsImpl::delayDrawPolyPolygon(const basegfx::B2DPolyPolygon& aP // so they do not need joining. if (aPolyPolygon.count() != 1) return false; + // If a polygon does not contain a straight line, i.e. it's all curves, then do not merge. + // First of all that's even more expensive, and second it's very unlikely that it's a polygon + // split into more polygons. + if (!polygonContainsLine(aPolyPolygon)) + return false; if (mLastPolyPolygonInfo.polygons.size() != 0 && (mLastPolyPolygonInfo.transparency != fTransparency _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits