diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-04-30 12:23:28 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-05-05 20:36:12 +0200 |
commit | 37f472c8d0e8a195c887e34cda796cdeae550ed6 (patch) | |
tree | 1c4fe7fd69fa508846100e06990ef3182589932a /vcl/source | |
parent | 2cdec016bc763f5fc9dede8835c8f45139e811ca (diff) |
fix line width in DrawPolyLine() with matrix (tdf#132498)
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 <quikee@gmail.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 28 | ||||
-rw-r--r-- | vcl/source/gdi/salgdilayout.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/line.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/polygon.cxx | 9 | ||||
-rw-r--r-- | vcl/source/outdev/polyline.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/textline.cxx | 3 | ||||
-rw-r--r-- | vcl/source/outdev/transparent.cxx | 6 |
7 files changed, 23 insertions, 37 deletions
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 80bcda56b2a6..01698c4e3d6f 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -295,12 +295,11 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics { rGraphics.SetLineColor(Color(*rRectangle.mpStrokeColor)); rGraphics.SetFillColor(); - rGraphics.DrawPolyLine( - basegfx::B2DHomMatrix(), aB2DPolygon, 1.0 - rRectangle.mnOpacity, - basegfx::B2DVector(rRectangle.mnStrokeWidth, rRectangle.mnStrokeWidth), - nullptr, // MM01 - basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, - nullptr); + rGraphics.DrawPolyLine(basegfx::B2DHomMatrix(), aB2DPolygon, + 1.0 - rRectangle.mnOpacity, rRectangle.mnStrokeWidth, + nullptr, // MM01 + basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, + 0.0f, false, nullptr); } } break; @@ -343,12 +342,11 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics rGraphics.SetFillColor(); for (auto const& rPolygon : aPolyPolygon) { - rGraphics.DrawPolyLine( - basegfx::B2DHomMatrix(), rPolygon, 1.0 - rPath.mnOpacity, - basegfx::B2DVector(rPath.mnStrokeWidth, rPath.mnStrokeWidth), - nullptr, // MM01 - basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, - nullptr); + rGraphics.DrawPolyLine(basegfx::B2DHomMatrix(), rPolygon, + 1.0 - rPath.mnOpacity, rPath.mnStrokeWidth, + nullptr, // MM01 + basegfx::B2DLineJoin::Round, + css::drawing::LineCap_ROUND, 0.0f, false, nullptr); } } } @@ -387,8 +385,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDr rGraphics.SetLineColor(rWidgetDraw.maStrokeColor); rGraphics.SetFillColor(); rGraphics.DrawPolyLine( - basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, - basegfx::B2DVector(rWidgetDraw.mnStrokeWidth, rWidgetDraw.mnStrokeWidth), + basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, rWidgetDraw.mnStrokeWidth, nullptr, // MM01 basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, nullptr); } @@ -411,8 +408,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDr }; rGraphics.DrawPolyLine( - basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, - basegfx::B2DVector(rWidgetDraw.mnStrokeWidth, rWidgetDraw.mnStrokeWidth), + basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, rWidgetDraw.mnStrokeWidth, nullptr, // MM01 basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, nullptr); } diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 16a308064b12..0a50329f62f0 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -572,7 +572,7 @@ bool SalGraphics::DrawPolyLine( const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& i_rPolygon, double i_fTransparency, - const basegfx::B2DVector& i_rLineWidth, + double i_rLineWidth, const std::vector< double >* i_pStroke, // MM01 basegfx::B2DLineJoin i_eLineJoin, css::drawing::LineCap i_eLineCap, diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx index e88dd383e7f3..f451b6e1f645 100644 --- a/vcl/source/outdev/line.cxx +++ b/vcl/source/outdev/line.cxx @@ -128,8 +128,7 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt ) basegfx::B2DHomMatrix(), aB2DPolyLine, 0.0, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, @@ -241,8 +240,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin basegfx::B2DHomMatrix(), rB2DPolygon, 0.0, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx index c742379d39de..60deaceb822c 100644 --- a/vcl/source/outdev/polygon.cxx +++ b/vcl/source/outdev/polygon.cxx @@ -96,8 +96,7 @@ void OutputDevice::DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly ) aTransform, rPolygon, 0.0, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, @@ -215,8 +214,7 @@ void OutputDevice::DrawPolygon( const tools::Polygon& rPoly ) aTransform, aB2DPolygon, 0.0, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, @@ -326,8 +324,7 @@ void OutputDevice::ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyP aTransform, rPolygon, 0.0, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx index 3e2ed372e01b..d17056d58e13 100644 --- a/vcl/source/outdev/polyline.cxx +++ b/vcl/source/outdev/polyline.cxx @@ -71,8 +71,7 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly ) aTransform, aB2DPolyLine, 0.0, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, @@ -348,8 +347,7 @@ bool OutputDevice::DrawPolyLineDirect( aTransform, rB2DPolygon, fTransparency, - // tdf#124848 use LineWidth direct, do not try to solve for zero-case (aka hairline) - basegfx::B2DVector(fLineWidth, fLineWidth), + fLineWidth, // tdf#124848 use LineWidth direct, do not try to solve for zero-case (aka hairline) pStroke, // MM01 eLineJoin, eLineCap, diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index a6eaa6b1c3a7..6ade6113fc99 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -1004,7 +1004,6 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, lo const basegfx::B2DRectangle aWaveLineRectangle(nStartX, nStartY, nEndX, nEndY + nWaveHeight); const basegfx::B2DPolygon aWaveLinePolygon = basegfx::createWaveLinePolygon(aWaveLineRectangle); const basegfx::B2DHomMatrix aRotationMatrix = basegfx::utils::createRotateAroundPoint(nStartX, nStartY, basegfx::deg2rad(-fOrientation)); - const basegfx::B2DVector aLineWidth(nLineWidth, nLineWidth); const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline); mpGraphics->SetLineColor(GetLineColor()); @@ -1012,7 +1011,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, lo aRotationMatrix, aWaveLinePolygon, 0.0, - aLineWidth, + nLineWidth, nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 0cf325d0b40a..e35d4dfbf959 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -269,8 +269,7 @@ void OutputDevice::DrawTransparent( aFullTransform, rPolygon, fTransparency, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, @@ -392,8 +391,7 @@ bool OutputDevice::DrawTransparentNatively ( const tools::PolyPolygon& rPolyPoly aTransform, rPolygon, fTransparency, - // tdf#124848 hairline - basegfx::B2DVector::getEmptyVector(), + 0.0, // tdf#124848 hairline nullptr, // MM01 basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, |