summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-05-05 14:20:01 +0200
committerAndras Timar <andras.timar@collabora.com>2021-05-06 16:40:11 +0200
commitf50b91ef3546d673ecf3763e0407738c7082180a (patch)
tree50904d603c8d94f6ea111b9b293ac1c813374f6a /canvas
parent88adf23d03a86c5f752ecbf33066d935b723b0de (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> (cherry picked from commit 3a1d150eb99b5875e6e86117029a72e4c87b0547) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115089 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.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 7d4cdba478f4..08066c27537f 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -914,10 +914,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 );
@@ -953,14 +955,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);
}