vcl/source/outdev/bitmap.cxx | 76 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-)
New commits: commit d0a5366b8232f7c9e45f58d7c4fa2475c98e7df5 Author: Christopher Sherlock <chris.sherloc...@gmail.com> AuthorDate: Sat Aug 9 19:12:29 2025 +1000 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Aug 11 09:45:01 2025 +0200 vcl: flatten OutputDevice::DrawBitmap() Change-Id: I868ffb1c575576d90fa423500efe722512764efc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189251 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index eba9850cd498..141d0c012c64 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -130,50 +130,50 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, if ( mbOutputClipped ) return; - if( !aBmp.IsEmpty() ) - { - SalTwoRect aPosAry(rSrcPtPixel.X(), rSrcPtPixel.Y(), rSrcSizePixel.Width(), rSrcSizePixel.Height(), - ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()), - ImplLogicWidthToDevicePixel(rDestSize.Width()), - ImplLogicHeightToDevicePixel(rDestSize.Height())); + if (aBmp.IsEmpty()) + return; - if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight ) - { - const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, aBmp.GetSizePixel() ); + SalTwoRect aPosAry(rSrcPtPixel.X(), rSrcPtPixel.Y(), rSrcSizePixel.Width(), rSrcSizePixel.Height(), + ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()), + ImplLogicWidthToDevicePixel(rDestSize.Width()), + ImplLogicHeightToDevicePixel(rDestSize.Height())); - if ( nMirrFlags != BmpMirrorFlags::NONE ) - aBmp.Mirror( nMirrFlags ); + if (!aPosAry.mnSrcWidth || !aPosAry.mnSrcHeight || !aPosAry.mnDestWidth || !aPosAry.mnDestHeight) + return; - if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight ) - { - if (nAction == MetaActionType::BMPSCALE && CanSubsampleBitmap()) - { - double nScaleX = aPosAry.mnDestWidth / static_cast<double>(aPosAry.mnSrcWidth); - double nScaleY = aPosAry.mnDestHeight / static_cast<double>(aPosAry.mnSrcHeight); - - // If subsampling, use Bitmap::Scale() for subsampling of better quality. - - // but hidpi surfaces like the cairo one have their own scale, so don't downscale - // past the surface scaling which can retain the extra detail - double fScale(1.0); - if (mpGraphics->ShouldDownscaleIconsAtSurface(fScale)) - { - nScaleX *= fScale; - nScaleY *= fScale; - } - - if ( nScaleX < 1.0 || nScaleY < 1.0 ) - { - aBmp.Scale(nScaleX, nScaleY); - aPosAry.mnSrcWidth = aPosAry.mnDestWidth * fScale; - aPosAry.mnSrcHeight = aPosAry.mnDestHeight * fScale; - } - } + const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, aBmp.GetSizePixel() ); - mpGraphics->DrawBitmap( aPosAry, *aBmp.ImplGetSalBitmap(), *this ); - } + if ( nMirrFlags != BmpMirrorFlags::NONE ) + aBmp.Mirror( nMirrFlags ); + + if (!aPosAry.mnSrcWidth || !aPosAry.mnSrcHeight || !aPosAry.mnDestWidth || !aPosAry.mnDestHeight) + return; + + if (nAction == MetaActionType::BMPSCALE && CanSubsampleBitmap()) + { + double nScaleX = aPosAry.mnDestWidth / static_cast<double>(aPosAry.mnSrcWidth); + double nScaleY = aPosAry.mnDestHeight / static_cast<double>(aPosAry.mnSrcHeight); + + // If subsampling, use Bitmap::Scale() for subsampling of better quality. + + // but hidpi surfaces like the cairo one have their own scale, so don't downscale + // past the surface scaling which can retain the extra detail + double fScale(1.0); + if (mpGraphics->ShouldDownscaleIconsAtSurface(fScale)) + { + nScaleX *= fScale; + nScaleY *= fScale; + } + + if ( nScaleX < 1.0 || nScaleY < 1.0 ) + { + aBmp.Scale(nScaleX, nScaleY); + aPosAry.mnSrcWidth = aPosAry.mnDestWidth * fScale; + aPosAry.mnSrcHeight = aPosAry.mnDestHeight * fScale; } } + + mpGraphics->DrawBitmap( aPosAry, *aBmp.ImplGetSalBitmap(), *this ); } Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const