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/win | |
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/win')
-rw-r--r-- | vcl/win/gdi/gdiimpl.cxx | 13 | ||||
-rw-r--r-- | vcl/win/gdi/gdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/salgdi_gdiplus.cxx | 4 |
3 files changed, 9 insertions, 10 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index 08c5f7861e8e..b019692726eb 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -2204,7 +2204,7 @@ bool WinSalGraphicsImpl::drawPolyLine( const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolygon, double fTransparency, - const basegfx::B2DVector& rLineWidth, + double fLineWidth, const std::vector< double >* pStroke, // MM01 basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, @@ -2218,29 +2218,28 @@ bool WinSalGraphicsImpl::drawPolyLine( } // need to check/handle LineWidth when ObjectToDevice transformation is used - basegfx::B2DVector aLineWidth(rLineWidth); const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity()); - const bool bIsHairline(aLineWidth.equalZero()); + const bool bIsHairline(fLineWidth == 0); // tdf#124848 calculate-back logical LineWidth for a hairline // since this implementation hands over the transformation to // the graphic sub-system if(bIsHairline) { - aLineWidth = basegfx::B2DVector(1.0, 1.0); + fLineWidth = 1.0; if(!bObjectToDeviceIsIdentity) { basegfx::B2DHomMatrix aObjectToDeviceInv(rObjectToDevice); aObjectToDeviceInv.invert(); - aLineWidth = aObjectToDeviceInv * aLineWidth; + fLineWidth = (aObjectToDeviceInv * basegfx::B2DVector(fLineWidth, 0)).getLength(); } } Gdiplus::Graphics aGraphics(mrParent.getHDC()); const sal_uInt8 aTrans = static_cast<sal_uInt8>(basegfx::fround( 255 * (1.0 - fTransparency) )); const Gdiplus::Color aTestColor(aTrans, maLineColor.GetRed(), maLineColor.GetGreen(), maLineColor.GetBlue()); - Gdiplus::Pen aPen(aTestColor.GetValue(), Gdiplus::REAL(aLineWidth.getX())); + Gdiplus::Pen aPen(aTestColor.GetValue(), Gdiplus::REAL(fLineWidth)); bool bNoLineJoin(false); // Set full (Object-to-Device) transformation - if used @@ -2340,7 +2339,7 @@ bool WinSalGraphicsImpl::drawPolyLine( // the back-calculated logical linewidth is already here, just use it. // Still be careful - a zero LineWidth *should* not happen, but... std::vector<Gdiplus::REAL> aDashArray(pStroke->size()); - const double fFactor(aLineWidth.equalZero() ? 1.0 : 1.0 / aLineWidth.getX()); + const double fFactor(fLineWidth == 0 ? 1.0 : 1.0 / fLineWidth); for(size_t a(0); a < pStroke->size(); a++) { diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx index eb56388ff42d..748afbcf04d4 100644 --- a/vcl/win/gdi/gdiimpl.hxx +++ b/vcl/win/gdi/gdiimpl.hxx @@ -129,7 +129,7 @@ public: const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon&, double fTransparency, - const basegfx::B2DVector& rLineWidths, + double fLineWidth, const std::vector< double >* pStroke, // MM01 basegfx::B2DLineJoin, css::drawing::LineCap, diff --git a/vcl/win/gdi/salgdi_gdiplus.cxx b/vcl/win/gdi/salgdi_gdiplus.cxx index ce2f2cc69c20..f56a227609f9 100644 --- a/vcl/win/gdi/salgdi_gdiplus.cxx +++ b/vcl/win/gdi/salgdi_gdiplus.cxx @@ -41,7 +41,7 @@ bool WinSalGraphics::drawPolyLine( const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolygon, double fTransparency, - const basegfx::B2DVector& rLineWidths, + double fLineWidth, const std::vector< double >* pStroke, // MM01 basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, @@ -52,7 +52,7 @@ bool WinSalGraphics::drawPolyLine( rObjectToDevice, rPolygon, fTransparency, - rLineWidths, + fLineWidth, pStroke, // MM01 eLineJoin, eLineCap, |