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/quartz | |
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/quartz')
-rw-r--r-- | vcl/quartz/salgdicommon.cxx | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index 51de3820f93d..3126400709f2 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -817,7 +817,7 @@ bool AquaSalGraphics::drawPolyLine( const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, double fTransparency, - const basegfx::B2DVector& rLineWidth, + double fLineWidth, const std::vector< double >* pStroke, // MM01 basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, @@ -836,15 +836,15 @@ bool AquaSalGraphics::drawPolyLine( #endif // 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(); // #i101491# Aqua does not support B2DLineJoin::NONE; return false to use // the fallback (own geometry preparation) // #i104886# linejoin-mode and thus the above only applies to "fat" lines - if( (basegfx::B2DLineJoin::NONE == eLineJoin) && (aLineWidth.getX() > 1.3) ) + if( (basegfx::B2DLineJoin::NONE == eLineJoin) && (fLineWidth > 1.3) ) return false; // MM01 need to do line dashing as fallback stuff here now @@ -935,12 +935,7 @@ bool AquaSalGraphics::drawPolyLine( CGContextSetAlpha( maContextHolder.get(), 1.0 - fTransparency ); CGContextSetLineJoin( maContextHolder.get(), aCGLineJoin ); CGContextSetLineCap( maContextHolder.get(), aCGLineCap ); - - // aLineWidth.getX() can be negative here. That causes a warning that shows up in the debugger. - if (aLineWidth.getX() > 0) - { - CGContextSetLineWidth( maContextHolder.get(), aLineWidth.getX() ); - } + CGContextSetLineWidth( maContextHolder.get(), fLineWidth ); CGContextSetMiterLimit(maContextHolder.get(), fCGMiterLimit); CGContextDrawPath( maContextHolder.get(), kCGPathStroke ); maContextHolder.restoreState(); |