From 37f472c8d0e8a195c887e34cda796cdeae550ed6 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 30 Apr 2020 12:23:28 +0200 Subject: fix line width in DrawPolyLine() with matrix (tdf#132498) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For backends that do the object-to-device coordinates transformation directly, it's necessary to also convert the size of line width. But simply multiplying it with the matrix can also rotate the line width "vector", making it e.g. negative. So don't use just the X coordinate, use vector length for the transformation, which is ok. In fact it doesn't even make sense to treat width as a vector, because a width simply is not a vector (and for this reason it's also not actually used). Change-Id: I1241c9cb29155df105170d568a879ebc32b11a5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93203 Reviewed-by: Tomaž Vajngerl Tested-by: Jenkins --- vcl/qt5/Qt5Graphics_GDI.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'vcl/qt5') diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx index eb43811466d4..cfebca7c6acb 100644 --- a/vcl/qt5/Qt5Graphics_GDI.cxx +++ b/vcl/qt5/Qt5Graphics_GDI.cxx @@ -325,7 +325,7 @@ bool Qt5Graphics::drawPolyPolygonBezier(sal_uInt32 /*nPoly*/, const sal_uInt32* bool Qt5Graphics::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, double fTransparency, - const basegfx::B2DVector& rLineWidth, + double fLineWidth, const std::vector* pStroke, // MM01 basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, double fMiterMinimumAngle, bool bPixelSnapHairline) @@ -371,9 +371,10 @@ bool Qt5Graphics::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, } // tdf#124848 get correct LineWidth in discrete coordinates, - // take hairline case into account - const basegfx::B2DVector aLineWidth(rLineWidth.equalZero() ? basegfx::B2DVector(1.0, 1.0) - : rObjectToDevice * rLineWidth); + if (fLineWidth == 0) // hairline + fLineWidth = 1.0; + else // Adjust line width for object-to-device scale. + fLineWidth = (rObjectToDevice * basegfx::B2DVector(fLineWidth, 0)).getLength(); // setup poly-polygon path QPainterPath aPath; @@ -390,7 +391,7 @@ bool Qt5Graphics::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, // setup line attributes QPen aPen = aPainter.pen(); - aPen.setWidth(aLineWidth.getX()); + aPen.setWidth(fLineWidth); switch (eLineJoin) { -- cgit