[Libreoffice-commits] core.git: canvas/source
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Wed May 5 17:57:25 UTC 2021
canvas/source/cairo/cairo_canvashelper.cxx | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
New commits:
commit 3a1d150eb99b5875e6e86117029a72e4c87b0547
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed May 5 14:20:01 2021 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed May 5 19:56:24 2021 +0200
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 at collabora.com>
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);
}
More information about the Libreoffice-commits
mailing list