[Libreoffice-commits] core.git: 2 commits - comphelper/source vcl/skia

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 22 14:23:23 UTC 2021


 comphelper/source/misc/asyncnotification.cxx |   10 ++---
 vcl/skia/gdiimpl.cxx                         |   48 ++++++++++-----------------
 2 files changed, 24 insertions(+), 34 deletions(-)

New commits:
commit f30c3ff66a24d5031c077be0cb839f5f249c188e
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Sun Aug 22 14:55:58 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 16:22:57 2021 +0200

    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 at collabora.co.uk>

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);
         }
     }
 
commit 1706dba109533cce01eb982ef7cdedee5a20a1e0
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri Aug 20 21:13:27 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 16:22:49 2021 +0200

    osl::Mutex->std::mutex
    
    Change-Id: Id3c0660dae6dd5c6c026a26ec2ca39ccd6db210f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120845
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/misc/asyncnotification.cxx b/comphelper/source/misc/asyncnotification.cxx
index 0fd0c338af53..e498ce23ba44 100644
--- a/comphelper/source/misc/asyncnotification.cxx
+++ b/comphelper/source/misc/asyncnotification.cxx
@@ -163,9 +163,9 @@ namespace comphelper
 
     namespace {
 
-    osl::Mutex& GetTheNotifiersMutex()
+    std::mutex& GetTheNotifiersMutex()
     {
-        static osl::Mutex MUTEX;
+        static std::mutex MUTEX;
         return MUTEX;
     }
 
@@ -177,7 +177,7 @@ namespace comphelper
     {
         std::vector<std::weak_ptr<AsyncEventNotifierAutoJoin>> notifiers;
         {
-            ::osl::MutexGuard g(GetTheNotifiersMutex());
+            std::scoped_lock g(GetTheNotifiersMutex());
             notifiers = g_Notifiers;
         }
         for (std::weak_ptr<AsyncEventNotifierAutoJoin> const& wNotifier : notifiers)
@@ -201,7 +201,7 @@ namespace comphelper
 
     AsyncEventNotifierAutoJoin::~AsyncEventNotifierAutoJoin()
     {
-        ::osl::MutexGuard g(GetTheNotifiersMutex());
+        std::scoped_lock g(GetTheNotifiersMutex());
         // note: this doesn't happen atomically with the refcount
         // hence it's possible this deletes > 1 or 0 elements
         g_Notifiers.erase(
@@ -217,7 +217,7 @@ namespace comphelper
     {
         std::shared_ptr<AsyncEventNotifierAutoJoin> const ret(
                 new AsyncEventNotifierAutoJoin(name));
-        ::osl::MutexGuard g(GetTheNotifiersMutex());
+        std::scoped_lock g(GetTheNotifiersMutex());
         g_Notifiers.push_back(ret);
         return ret;
     }


More information about the Libreoffice-commits mailing list