vcl/skia/gdiimpl.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 6b2046b41719a391e758ea57055adb2e111f94c1
Author:     Noel Grandin <n...@peralex.com>
AuthorDate: Mon Aug 23 20:27:01 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 24 11:28:07 2021 +0200

    reduce skia realloc when drawing polygons
    
    Change-Id: Ide65945b2baa01b78c954112cdbf35edc41e2f8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120916
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ef4809bc0288..f3122dc208e5 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -148,8 +148,8 @@ void addPolyPolygonToPath(const basegfx::B2DPolyPolygon& 
rPolyPolygon, SkPath& r
 
     sal_uInt32 nPointCount = 0;
     for (const auto& rPolygon : rPolyPolygon)
-        nPointCount += rPolygon.count();
-    rPath.incReserve(nPointCount * 2);
+        nPointCount += rPolygon.count() * 3; // because cubicTo is 3 elements
+    rPath.incReserve(nPointCount);
 
     for (const auto& rPolygon : rPolyPolygon)
     {
@@ -1142,7 +1142,7 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const 
basegfx::B2DHomMatrix& rObjectToDev
     if (eLineJoin != basegfx::B2DLineJoin::NONE || fLineWidth <= 1.0)
     {
         SkPath aPath;
-        aPath.incReserve(aPolyLine.count() + 2);
+        aPath.incReserve(aPolyLine.count() * 3); // because cubicTo is 3 
elements
         aPath.setFillType(SkPathFillType::kEvenOdd);
         addPolygonToPath(aPolyLine, aPath);
         aPath.offset(toSkX(0) + posFix, toSkY(0) + posFix, nullptr);

Reply via email to