From 32020eb33ba9501510acb449bc84cfaa85bc0bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 24 Sep 2020 19:43:58 +0200 Subject: don't write metafile action twice in DrawPolyLineDirect() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All other functions calling it already do so, so write it only when called from the outside. Change-Id: If17d973a5d6b3797db46e91a1ec36606a89c5d07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103353 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/source/outdev/polyline.cxx | 54 +++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'vcl/source/outdev') diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx index 672854a9ed55..2a405e5eaf5a 100644 --- a/vcl/source/outdev/polyline.cxx +++ b/vcl/source/outdev/polyline.cxx @@ -56,7 +56,7 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly ) InitLineColor(); // use b2dpolygon drawing if possible - if(DrawPolyLineDirect( + if(DrawPolyLineDirectInternal( basegfx::B2DHomMatrix(), rPoly.getB2DPolygon())) { @@ -171,7 +171,7 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon, InitLineColor(); // use b2dpolygon drawing if possible - if(DrawPolyLineDirect( + if(DrawPolyLineDirectInternal( basegfx::B2DHomMatrix(), rB2DPolygon, fLineWidth, @@ -228,7 +228,7 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon, // to avoid optical gaps for(auto const& rPolygon : aAreaPolyPolygon) { - (void)DrawPolyLineDirect( + (void)DrawPolyLineDirectInternal( basegfx::B2DHomMatrix(), rPolygon, 0.0, @@ -310,6 +310,40 @@ bool OutputDevice::DrawPolyLineDirect( css::drawing::LineCap eLineCap, double fMiterMinimumAngle, bool bBypassAACheck) +{ + if(DrawPolyLineDirectInternal(rObjectTransform, rB2DPolygon, fLineWidth, fTransparency, + pStroke, eLineJoin, eLineCap, fMiterMinimumAngle, bBypassAACheck)) + { + // Worked, add metafile action (if recorded). This is done only here, + // because this function is public, other OutDev functions already add metafile + // actions, so they call the internal function directly. + if( mpMetaFile ) + { + LineInfo aLineInfo; + if( fLineWidth != 0.0 ) + aLineInfo.SetWidth( static_cast(fLineWidth+0.5) ); + // Transport known information, might be needed + aLineInfo.SetLineJoin(eLineJoin); + aLineInfo.SetLineCap(eLineCap); + // MiterMinimumAngle does not exist yet in LineInfo + const tools::Polygon aToolsPolygon( rB2DPolygon ); + mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) ); + } + return true; + } + return false; +} + +bool OutputDevice::DrawPolyLineDirectInternal( + const basegfx::B2DHomMatrix& rObjectTransform, + const basegfx::B2DPolygon& rB2DPolygon, + double fLineWidth, + double fTransparency, + const std::vector< double >* pStroke, // MM01 + basegfx::B2DLineJoin eLineJoin, + css::drawing::LineCap eLineCap, + double fMiterMinimumAngle, + bool bBypassAACheck) { assert(!is_double_buffered_window()); @@ -358,20 +392,6 @@ bool OutputDevice::DrawPolyLineDirect( if( bDrawSuccess ) { - // worked, add metafile action (if recorded) and return true - if( mpMetaFile ) - { - LineInfo aLineInfo; - if( fLineWidth != 0.0 ) - aLineInfo.SetWidth( static_cast(fLineWidth+0.5) ); - // Transport known information, might be needed - aLineInfo.SetLineJoin(eLineJoin); - aLineInfo.SetLineCap(eLineCap); - // MiterMinimumAngle does not exist yet in LineInfo - const tools::Polygon aToolsPolygon( rB2DPolygon ); - mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) ); - } - if (mpAlphaVDev) mpAlphaVDev->DrawPolyLineDirect(rObjectTransform, rB2DPolygon, fLineWidth, fTransparency, pStroke, eLineJoin, eLineCap, -- cgit v1.2.1