diff options
author | Noel Grandin <noel@peralex.com> | 2021-08-22 14:55:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-22 16:22:57 +0200 |
commit | f30c3ff66a24d5031c077be0cb839f5f249c188e (patch) | |
tree | c84f4d2e9d3891bf72b4042f2bd4a53a89ede4c1 | |
parent | 1706dba109533cce01eb982ef7cdedee5a20a1e0 (diff) |
speedup SkiaSalGraphicsImpl::drawPolyLine
no need to convert the line to a polypoly and then unwrap the polypoly,
just go straight to a poly
Change-Id: I3f0ccfb7ce557dc4c6cd67e6e66a0562609ce736
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120843
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/skia/gdiimpl.cxx | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index fa1e43f0533c..ef4809bc0288 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1075,12 +1075,11 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev fLineWidth = (rObjectToDevice * basegfx::B2DVector(fLineWidth, 0)).getLength(); // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline - basegfx::B2DPolyPolygon aPolyPolygonLine; - aPolyPolygonLine.append(rPolyLine); - aPolyPolygonLine.transform(rObjectToDevice); + basegfx::B2DPolygon aPolyLine(rPolyLine); + aPolyLine.transform(rObjectToDevice); if (bPixelSnapHairline) { - aPolyPolygonLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyPolygonLine); + aPolyLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine); } // Setup Line Join @@ -1143,39 +1142,30 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev if (eLineJoin != basegfx::B2DLineJoin::NONE || fLineWidth <= 1.0) { SkPath aPath; - sal_uInt32 nPointCount = 0; - for (const auto& rPolygon : std::as_const(aPolyPolygonLine)) - nPointCount += (rPolygon.count() + 1); - aPath.incReserve(nPointCount + 2); - + aPath.incReserve(aPolyLine.count() + 2); aPath.setFillType(SkPathFillType::kEvenOdd); - for (const auto& rPolygon : std::as_const(aPolyPolygonLine)) - addPolygonToPath(rPolygon, aPath); + addPolygonToPath(aPolyLine, aPath); aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr); addUpdateRegion(aPath.getBounds()); getDrawCanvas()->drawPath(aPath, aPaint); } else { - for (sal_uInt32 i = 0; i < aPolyPolygonLine.count(); ++i) + sal_uInt32 nPoints = aPolyLine.count(); + bool bClosed = aPolyLine.isClosed(); + for (sal_uInt32 j = 0; j < (bClosed ? nPoints : nPoints - 1); ++j) { - const basegfx::B2DPolygon& rPolygon = aPolyPolygonLine.getB2DPolygon(i); - sal_uInt32 nPoints = rPolygon.count(); - bool bClosed = rPolygon.isClosed(); - for (sal_uInt32 j = 0; j < (bClosed ? nPoints : nPoints - 1); ++j) - { - sal_uInt32 index1 = (j + 0) % nPoints; - sal_uInt32 index2 = (j + 1) % nPoints; - SkPath aPath; - aPath.moveTo(rPolygon.getB2DPoint(index1).getX(), - rPolygon.getB2DPoint(index1).getY()); - aPath.lineTo(rPolygon.getB2DPoint(index2).getX(), - rPolygon.getB2DPoint(index2).getY()); - - aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr); - addUpdateRegion(aPath.getBounds()); - getDrawCanvas()->drawPath(aPath, aPaint); - } + sal_uInt32 index1 = (j + 0) % nPoints; + sal_uInt32 index2 = (j + 1) % nPoints; + SkPath aPath; + aPath.moveTo(aPolyLine.getB2DPoint(index1).getX(), + aPolyLine.getB2DPoint(index1).getY()); + aPath.lineTo(aPolyLine.getB2DPoint(index2).getX(), + aPolyLine.getB2DPoint(index2).getY()); + + aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr); + addUpdateRegion(aPath.getBounds()); + getDrawCanvas()->drawPath(aPath, aPaint); } } |