summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-05-05 14:20:01 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-05-05 19:56:24 +0200
commit3a1d150eb99b5875e6e86117029a72e4c87b0547 (patch)
tree8892f9b460c68f50560ac79d112c889f71bbbc1f /canvas
parente859bf8c4da78698b820d13af1a2fdee3602f5b4 (diff)
scale stroked line properly in cairocanvas
- Line width should be scaled by the scaled vector, not just its X component (see VclMetafileProcessor2D::getTransformedLineWidth()). - Lenths of dashes should not be scaled by the scaled line width, but by the scaling. Testcase document sd/qa/unit/data/pptx/tdf134053_dashdot.pptx . Change-Id: I4116f82e91620f5612f5e4e187468508f683b93e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115147 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index d308961a0865..2711634e9948 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -913,10 +913,12 @@ namespace cairocanvas
useStates( viewState, renderState, true );
cairo_matrix_t aMatrix;
- double w = strokeAttributes.StrokeWidth, h = 0;
cairo_get_matrix( mpCairo.get(), &aMatrix );
- cairo_matrix_transform_distance( &aMatrix, &w, &h );
- cairo_set_line_width( mpCairo.get(), w );
+ double scaleFactorX = 1;
+ double scaleFactorY = 0;
+ cairo_matrix_transform_distance( &aMatrix, &scaleFactorX, &scaleFactorY );
+ double scaleFactor = basegfx::B2DVector( scaleFactorX, scaleFactorY ).getLength();
+ cairo_set_line_width( mpCairo.get(), strokeAttributes.StrokeWidth * scaleFactor );
cairo_set_miter_limit( mpCairo.get(), strokeAttributes.MiterLimit );
@@ -952,14 +954,14 @@ namespace cairocanvas
break;
}
- //tdf#103026 If the w scaling is 0, then all dashes become zero so
+ //tdf#103026 If the scaling is 0, then all dashes become zero so
//cairo will set the cairo_t status to CAIRO_STATUS_INVALID_DASH
//and no further drawing will occur
- if (strokeAttributes.DashArray.hasElements() && w > 0.0)
+ if (strokeAttributes.DashArray.hasElements() && scaleFactor > 0.0)
{
auto aDashArray(comphelper::sequenceToContainer<std::vector<double>>(strokeAttributes.DashArray));
for (auto& rDash : aDashArray)
- rDash *= w;
+ rDash *= scaleFactor;
cairo_set_dash(mpCairo.get(), aDashArray.data(), aDashArray.size(), 0);
}