drawinglayer/source/processor2d/cairopixelprocessor2d.cxx | 40 +++++++++----- 1 file changed, 27 insertions(+), 13 deletions(-)
New commits: commit 3e7660983a63c395b84fb18f3e45529dcc76930c Author: Armin Le Grand (collabora) <armin.legr...@collabora.com> AuthorDate: Thu Aug 7 21:02:41 2025 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Tue Aug 19 15:32:30 2025 +0200 tdf#167831 avoid painting bitmap data with zero dimensions See task, there may be bitmap-filled objects in files that have a logical size of (0, 0), despite the bitmap having valid data. That leads to problems *inside* cairo paint, so I have to test and avoid that. Change-Id: I18db3b030fb5cdf77caa5afd1bf901095fa1c67b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189135 Tested-by: Jenkins Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> (cherry picked from commit cd93f83bbcba0379bf39f3a4e76b955b7fa368b5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189187 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 30e82ab0a28c4e820aaa3336b96b17c7badfefeb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189923 Tested-by: Andras Timar <andras.ti...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx index ee55a3c3bccc..270843713def 100644 --- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx @@ -1285,6 +1285,17 @@ void CairoPixelProcessor2D::paintBitmapAlpha(const BitmapEx& rBitmapEx, return; } + // work with dimensions in discrete target pixels to use evtl. MipMap pre-scale + const tools::Long nDestWidth((aLocalTransform * basegfx::B2DVector(1.0, 0.0)).getLength()); + const tools::Long nDestHeight((aLocalTransform * basegfx::B2DVector(0.0, 1.0)).getLength()); + + // tdf#167831 check for output size, may have zero discrete dimension in X and/or Y + if (0 == nDestWidth || 0 == nDestHeight) + { + // it has and is thus invisible + return; + } + if (maBColorModifierStack.count()) { // need to apply ColorModifier to Bitmap data @@ -1317,10 +1328,6 @@ void CairoPixelProcessor2D::paintBitmapAlpha(const BitmapEx& rBitmapEx, return; } - // work with dimensions in discrete target pixels to use evtl. MipMap pre-scale - const tools::Long nDestWidth((aLocalTransform * basegfx::B2DVector(1.0, 0.0)).getLength()); - const tools::Long nDestHeight((aLocalTransform * basegfx::B2DVector(0.0, 1.0)).getLength()); - cairo_surface_t* pTarget(aCairoSurfaceHelper->getCairoSurface(nDestWidth, nDestHeight)); if (nullptr == pTarget) { @@ -2412,6 +2419,22 @@ void CairoPixelProcessor2D::processFillGraphicPrimitive2D( return; } + // work with dimensions in discrete target pixels to use evtl. MipMap pre-scale + const basegfx::B2DHomMatrix aLocalTransform( + getViewInformation2D().getObjectToViewTransformation() + * rFillGraphicPrimitive2D.getTransformation()); + const tools::Long nDestWidth( + (aLocalTransform * basegfx::B2DVector(aFillUnitRange.getWidth(), 0.0)).getLength()); + const tools::Long nDestHeight( + (aLocalTransform * basegfx::B2DVector(0.0, aFillUnitRange.getHeight())).getLength()); + + // tdf#167831 check for output size, may have zero discrete dimension in X and/or Y + if (0 == nDestWidth || 0 == nDestHeight) + { + // it has and is thus invisible + return; + } + // render tiled using the prepared Bitmap data if (maBColorModifierStack.count()) { @@ -2450,15 +2473,6 @@ void CairoPixelProcessor2D::processFillGraphicPrimitive2D( return; } - // work with dimensions in discrete target pixels to use evtl. MipMap pre-scale - const basegfx::B2DHomMatrix aLocalTransform( - getViewInformation2D().getObjectToViewTransformation() - * rFillGraphicPrimitive2D.getTransformation()); - const tools::Long nDestWidth( - (aLocalTransform * basegfx::B2DVector(aFillUnitRange.getWidth(), 0.0)).getLength()); - const tools::Long nDestHeight( - (aLocalTransform * basegfx::B2DVector(0.0, aFillUnitRange.getHeight())).getLength()); - cairo_surface_t* pTarget(aCairoSurfaceHelper->getCairoSurface(nDestWidth, nDestHeight)); if (nullptr == pTarget) {