From c069861bf9a32c826cbc86a086a774eba49c4e6f 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 Cherry-picked 5f61c9fe99ac93087b898adddbb4d4733f1fcd07: Adaptions made and checked that Caio fat line draw works as expected. Surprisingly some new files were created which I removed here again. Also needs to be cherry-picked is: 9c9f76dd5b6fb115e521ac6568673c7a10879192 which will enable direct dash paint for Cairo. Not done here due to not sure if I can do two cherry-picks in one run and it's lust a view lines, so -compared to this one- should be not difficult. Change-Id: Ie10fb8093a86459dee80db5ab4355b47e46c1f8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88130 Tested-by: Jenkins Reviewed-by: Armin Le Grand Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88284 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tor Lillqvist --- vcl/opengl/gdiimpl.cxx | 70 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 17 deletions(-) (limited to 'vcl/opengl') diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index dfd916f9e4c7..4e58196e4b01 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include +#include #include #include @@ -1553,6 +1555,7 @@ void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pP aPoly, 0.0, basegfx::B2DVector(1.0, 1.0), + nullptr, // MM01 basegfx::B2DLineJoin::Miter, css::drawing::LineCap_BUTT, basegfx::deg2rad(15.0) /*default*/, @@ -1630,6 +1633,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine( const basegfx::B2DPolygon& rPolygon, double fTransparency, const basegfx::B2DVector& rLineWidth, + const std::vector< double >* pStroke, // MM01 basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, double fMiterMinimumAngle, @@ -1637,28 +1641,60 @@ bool OpenGLSalGraphicsImpl::drawPolyLine( { VCL_GL_INFO("::drawPolyLine " << rPolygon.getB2DRange()); + // MM01 check done for simple reasons + if(!rPolygon.count() || fTransparency < 0.0 || fTransparency > 1.0) + { + return true; + } + + // MM01 need to do line dashing as fallback stuff here now + const double fDotDashLength(nullptr != pStroke ? std::accumulate(pStroke->begin(), pStroke->end(), 0.0) : 0.0); + const bool bStrokeUsed(0.0 != fDotDashLength); + basegfx::B2DPolyPolygon aPolyPolygonLine; + + if(bStrokeUsed) + { + // apply LineStyle + basegfx::utils::applyLineDashing( + rPolygon, // source + *pStroke, // pattern + &aPolyPolygonLine, // traget for lines + nullptr, // target for gaps + fDotDashLength); // full length if available + } + else + { + // no line dashing, just copy + aPolyPolygonLine.append(rPolygon); + } + // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline - basegfx::B2DPolygon aPolyLine(rPolygon); - aPolyLine.transform(rObjectToDevice); - if(bPixelSnapHairline) { aPolyLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine); } + aPolyPolygonLine.transform(rObjectToDevice); + if(bPixelSnapHairline) { aPolyPolygonLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyPolygonLine); } const basegfx::B2DVector aLineWidth(rObjectToDevice * rLineWidth); - // addDrawPolyLine() assumes that there are no duplicate points in the - // polygon. - // basegfx::B2DPolygon aPolygon(rPolygon); - aPolyLine.removeDoublePoints(); + for(sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++) + { + // addDrawPolyLine() assumes that there are no duplicate points in the polygon + basegfx::B2DPolygon aPolyLine(aPolyPolygonLine.getB2DPolygon(a)); + basegfx::utils::simplifyCurveSegments(aPolyLine); + aPolyLine.removeDoublePoints(); - mpRenderList->addDrawPolyLine( - aPolyLine, - fTransparency, - aLineWidth, - eLineJoin, - eLineCap, - fMiterMinimumAngle, - mnLineColor, - mrParent.getAntiAliasB2DDraw()); + mpRenderList->addDrawPolyLine( + aPolyLine, + fTransparency, + aLineWidth, + eLineJoin, + eLineCap, + fMiterMinimumAngle, + mnLineColor, + mrParent.getAntiAliasB2DDraw()); + + // MM01: not sure - maybe this can be moved out of this loop, but to + // keep on the safe side for now, do not relly change something for now + PostBatchDraw(); + } - PostBatchDraw(); return true; } -- cgit