From 446de9cbea55af65b5f1a274f1ac4b88a6be9ae6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Sep 2020 21:16:28 +0200 Subject: [PATCH] tdf#136337 cairo canvas: fix missing image with negative height Regression from commit 78036f74fa74ee2552e79064660634e1342692ff (tdf#135094 cairo canvas: fix black slide containing a very small image, 2020-08-14), we try to predict when cairo would end up in an invalid state due to an invalid transformation matrix, but in this case we were too aggressive, so the image was missing while presenting. Fix the problem by allowing negative sizes, just require that neither of width/height is zero, because negative values are poor, but valid way of vertical/horizontal flip. [ No testcase, our tests are typically headless and currently SvpSalGraphics::SupportsCairo() reports false, so this would be tricky to test. ] Change-Id: Iaf843c0d40c108d5221c9b94b39d617e4d50f65c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103127 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- canvas/source/cairo/cairo_canvashelper.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 09a87e2ecc4c..0ca169ca1fe4 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -1179,7 +1179,7 @@ namespace cairocanvas int nPixelWidth = std::round(rSize.Width * aMatrix.xx); int nPixelHeight = std::round(rSize.Height * aMatrix.yy); - if (nPixelWidth > 0 && nPixelHeight > 0) + if (std::abs(nPixelWidth) > 0 && std::abs(nPixelHeight) > 0) { // Only render the image if it's at least 1x1 px sized. if (bModulateColors)