[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - canvas/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 17 12:53:45 UTC 2020
canvas/source/cairo/cairo_canvashelper.cxx | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
New commits:
commit 00665f8d986644b40c1075c599515d20c8a6bbb4
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Aug 14 16:15:07 2020 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Aug 17 14:53:11 2020 +0200
tdf#135094 cairo canvas: fix black slide containing a very small image
Don't paint when the area would be 0, that would not be visible anyway,
and the _cairo_matrix_to_pixman_matrix_offset() call would fail with
CAIRO_INT_STATUS_INVALID_MATRIX in _pixman_image_set_properties(),
failing the render of the whole slide.
Also, warn in case the painting fails, so the next time something
breaks, it's easier to find the problematic place.
[ No testcase, our tests are typically headless and currently
SvpSalGraphics::SupportsCairo() reports false, so this would be tricky
to test. ]
(cherry picked from commit 78036f74fa74ee2552e79064660634e1342692ff)
Change-Id: I7cdb9462ff8155232ea51abf321b365c2219575b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100847
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 533953e12891..09a87e2ecc4c 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -1177,10 +1177,23 @@ namespace cairocanvas
cairo_rectangle( mpCairo.get(), 0, 0, aBitmapSize.Width, aBitmapSize.Height );
cairo_clip( mpCairo.get() );
- if( bModulateColors )
- cairo_paint_with_alpha( mpCairo.get(), renderState.DeviceColor[3] );
- else
- cairo_paint( mpCairo.get() );
+ int nPixelWidth = std::round(rSize.Width * aMatrix.xx);
+ int nPixelHeight = std::round(rSize.Height * aMatrix.yy);
+ if (nPixelWidth > 0 && nPixelHeight > 0)
+ {
+ // Only render the image if it's at least 1x1 px sized.
+ if (bModulateColors)
+ cairo_paint_with_alpha(mpCairo.get(), renderState.DeviceColor[3]);
+ else
+ {
+ cairo_paint(mpCairo.get());
+ if (cairo_status(mpCairo.get()) != CAIRO_STATUS_SUCCESS)
+ {
+ SAL_WARN("canvas.cairo", "cairo_paint() failed: " << cairo_status_to_string(
+ cairo_status(mpCairo.get())));
+ }
+ }
+ }
cairo_restore( mpCairo.get() );
}
else
More information about the Libreoffice-commits
mailing list