diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-11-15 08:27:57 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-15 09:57:01 +0100 |
commit | 94df17d2fcdb72bc529097d77b174d934a25cc24 (patch) | |
tree | cbea666976c4e543a824f799e21892c987c031a5 /canvas | |
parent | 8a2f32a74794c6ee736c5015c920651c9eb6fead (diff) |
tdf#145416 canvas: fix rotated, not zero-sized bitmap, which is not rendered
The presentation had a rotated bitmap, which is not zero size, but we
still decided to just not render it. The bug is specific to the "cairo
canvas", which is the default on Linux, but not elsewhere.
The trouble is that CanvasHelper::implDrawBitmapSurface() accessed the
transform matrix directly, assuming that the (0,0) and (1,1) members
represent scaling as-is. This is only true in case there are no other
transforms in the matrix (rotation, sharing).
Fix the problem by getting the scale info via
cairo_matrix_transform_distance(), which correctly determines if the
scaling is 0 or not.
This went wrong in commit 78036f74fa74ee2552e79064660634e1342692ff
(tdf#135094 cairo canvas: fix black slide containing a very small image,
2020-08-14). No testcase, our tests are typically headless and
currently SvpSalGraphics::SupportsCairo() reports false, so this would
be tricky to test.
Change-Id: I0af18e89a3fbc76805053ba2f2f8ce509716f678
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142722
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 0306bff9f379..14113e89361f 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -1175,8 +1175,13 @@ constexpr OUStringLiteral PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME = u"Canvas:: cairo_rectangle( mpCairo.get(), 0, 0, aBitmapSize.Width, aBitmapSize.Height ); cairo_clip( mpCairo.get() ); - int nPixelWidth = std::round(rSize.Width * aMatrix.xx); - int nPixelHeight = std::round(rSize.Height * aMatrix.yy); + // Use cairo_matrix_transform_distance() to determine the scaling, as that works even if + // the matrix also has rotation. + double fPixelWidth = rSize.Width; + double fPixelHeight = rSize.Height; + cairo_matrix_transform_distance(&aMatrix, &fPixelWidth, &fPixelHeight); + int nPixelWidth = std::round(fPixelWidth); + int nPixelHeight = std::round(fPixelHeight); if (std::abs(nPixelWidth) > 0 && std::abs(nPixelHeight) > 0) { // Only render the image if it's at least 1x1 px sized. |