From 5f61c9fe99ac93087b898adddbb4d4733f1fcd07 Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (Collabora)" Date: Thu, 6 Feb 2020 18:53:12 +0100 Subject: tdf#130478 Enhance Dashed line drawing on all systems For more info and explanation including state of process information and discussion(s) see task please. Adding corrections for gerrit build Change-Id: Ie10fb8093a86459dee80db5ab4355b47e46c1f8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88130 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- .../source/processor2d/vclpixelprocessor2d.cxx | 92 +++++++--------------- 1 file changed, 27 insertions(+), 65 deletions(-) (limited to 'drawinglayer/source/processor2d/vclpixelprocessor2d.cxx') diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index e9642dd410fb..2fa5a7d47a44 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -96,7 +96,7 @@ namespace drawinglayer::processor2d void VclPixelProcessor2D::tryDrawPolyPolygonColorPrimitive2DDirect(const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D& rSource, double fTransparency) { - if(!rSource.getB2DPolyPolygon().count()) + if(!rSource.getB2DPolyPolygon().count() || fTransparency < 0.0 || fTransparency >= 1.0) { // no geometry, done return; @@ -116,7 +116,7 @@ namespace drawinglayer::processor2d { const basegfx::B2DPolygon& rLocalPolygon(rSource.getB2DPolygon()); - if(!rLocalPolygon.count()) + if(!rLocalPolygon.count() || fTransparency < 0.0 || fTransparency >= 1.0) { // no geometry, done return true; @@ -138,41 +138,28 @@ namespace drawinglayer::processor2d bool VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency) { - if(!rSource.getB2DPolygon().count()) + const basegfx::B2DPolygon& rLocalPolygon(rSource.getB2DPolygon()); + + if(!rLocalPolygon.count() || fTransparency < 0.0 || fTransparency >= 1.0) { // no geometry, done return true; } - // get geometry data, prepare hairline data - const basegfx::B2DPolygon& aLocalPolygon(rSource.getB2DPolygon()); - basegfx::B2DPolyPolygon aHairLinePolyPolygon; - - // simplify curve segments - // moved to PolygonStrokePrimitive2D::PolygonStrokePrimitive2D - // aLocalPolygon = basegfx::utils::simplifyCurveSegments(aLocalPolygon); - - if(rSource.getStrokeAttribute().isDefault() || 0.0 == rSource.getStrokeAttribute().getFullDotDashLen()) - { - // no line dashing, just copy - aHairLinePolyPolygon.append(aLocalPolygon); - } - else + if (basegfx::B2DLineJoin::NONE == rSource.getLineAttribute().getLineJoin() + && css::drawing::LineCap_BUTT != rSource.getLineAttribute().getLineCap()) { - // apply LineStyle - basegfx::utils::applyLineDashing( - aLocalPolygon, - rSource.getStrokeAttribute().getDotDashArray(), - &aHairLinePolyPolygon, - nullptr, - rSource.getStrokeAttribute().getFullDotDashLen()); + // better use decompose to get that combination done for now, see discussion + // at https://bugs.documentfoundation.org/show_bug.cgi?id=130478#c17 and ff + return false; } - if(!aHairLinePolyPolygon.count()) - { - // no geometry, done - return true; - } + // MM01: Radically change here - no dismantle/applyLineDashing, + // let that happen low-level at DrawPolyLineDirect implementations + // to open up for buffering and evtl. direct draw with sys-dep + // graphic systems. Check for stroke is in use + const bool bStrokeAttributeNotUsed(rSource.getStrokeAttribute().isDefault() + || 0.0 == rSource.getStrokeAttribute().getFullDotDashLen()); // check if LineWidth can be simplified in world coordinates double fLineWidth(rSource.getLineAttribute().getWidth()); @@ -201,42 +188,17 @@ namespace drawinglayer::processor2d mpOutputDevice->SetFillColor(); mpOutputDevice->SetLineColor(Color(aLineColor)); - // do not transform self - // aHairLinePolyPolygon.transform(maCurrentTransformation); - - bool bHasPoints(false); - bool bTryWorked(false); - - for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++) - { - const basegfx::B2DPolygon& aSingle(aHairLinePolyPolygon.getB2DPolygon(a)); - - if(aSingle.count()) - { - bHasPoints = true; - - if(mpOutputDevice->DrawPolyLineDirect( - maCurrentTransformation, - aSingle, - fLineWidth, - fTransparency, - rSource.getLineAttribute().getLineJoin(), - rSource.getLineAttribute().getLineCap(), - rSource.getLineAttribute().getMiterMinimumAngle() - /* false bBypassAACheck, default*/)) - { - bTryWorked = true; - } - } - } - - if(!bTryWorked && !bHasPoints) - { - // no geometry despite try - bTryWorked = true; - } - - return bTryWorked; + // MM01 draw direct, hand over dash data if available + return mpOutputDevice->DrawPolyLineDirect( + maCurrentTransformation, + rLocalPolygon, + fLineWidth, + fTransparency, + bStrokeAttributeNotUsed ? nullptr : &rSource.getStrokeAttribute().getDotDashArray(), + rSource.getLineAttribute().getLineJoin(), + rSource.getLineAttribute().getLineCap(), + rSource.getLineAttribute().getMiterMinimumAngle() + /* false bBypassAACheck, default*/); } void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) -- cgit