[Libreoffice-commits] core.git: canvas/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 29 07:56:16 UTC 2020


 canvas/source/vcl/canvashelper.cxx |   32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

New commits:
commit 6f224a17dbf635319503a81ce4038b1ae2ad6de0
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Sep 24 13:32:51 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Sep 29 09:55:34 2020 +0200

    make vclcanvas try directly VCL for drawing stroked polygon (tdf#136933)
    
    There's no point in trying to do all the stroking stuff manually
    if the VCL function can do it and better/faster.
    
    Change-Id: I9949637e2504d9b5d10ac77fbd5bd1f491ea6eee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103313
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index a9c9e1eda6d3..0e759d4fbe61 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -315,19 +315,34 @@ namespace vclcanvas
             ::basegfx::B2DHomMatrix aMatrix;
             ::canvas::tools::mergeViewAndRenderTransform(aMatrix, viewState, renderState);
 
-            ::basegfx::B2DSize aLinePixelSize(strokeAttributes.StrokeWidth,
-                                              strokeAttributes.StrokeWidth);
-            aLinePixelSize *= aMatrix;
-
             ::basegfx::B2DPolyPolygon aPolyPoly(
                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon) );
 
-            // apply dashing, if any
+            std::vector<double> aDashArray;
             if( strokeAttributes.DashArray.hasElements() )
+                aDashArray = ::comphelper::sequenceToContainer< std::vector<double> >(strokeAttributes.DashArray);
+
+            // First try to draw directly using VCL.
+            bool directFailed = false;
+            setupOutDevState( viewState, renderState, LINE_COLOR );
+            for( sal_uInt32 i=0; i<aPolyPoly.count(); ++i )
             {
-                const std::vector<double>& aDashArray(
-                    ::comphelper::sequenceToContainer< std::vector<double> >(strokeAttributes.DashArray) );
+                if( !mpOutDevProvider->getOutDev().DrawPolyLineDirect( aMatrix, aPolyPoly.getB2DPolygon(i),
+                    strokeAttributes.StrokeWidth, 0, !aDashArray.empty() ? &aDashArray : nullptr,
+                    b2DJoineFromJoin(strokeAttributes.JoinType), unoCapeFromCap(strokeAttributes.StartCapType)))
+                {
+                    directFailed = true;
+                    break;
+                }
+            }
+            if(!directFailed)
+                return uno::Reference< rendering::XCachedPrimitive >(nullptr);
+
+            // Do it all manually.
 
+            // apply dashing, if any
+            if( strokeAttributes.DashArray.hasElements() )
+            {
                 ::basegfx::B2DPolyPolygon aDashedPolyPoly;
 
                 for( sal_uInt32 i=0; i<aPolyPoly.count(); ++i )
@@ -342,6 +357,9 @@ namespace vclcanvas
                 aPolyPoly = aDashedPolyPoly;
             }
 
+            ::basegfx::B2DSize aLinePixelSize(strokeAttributes.StrokeWidth,
+                                              strokeAttributes.StrokeWidth);
+            aLinePixelSize *= aMatrix;
             ::basegfx::B2DPolyPolygon aStrokedPolyPoly;
             if( aLinePixelSize.getLength() < 1.42 )
             {


More information about the Libreoffice-commits mailing list