vcl: flatten OutputDevice::DrawBitmap()

Change-Id: I868ffb1c575576d90fa423500efe722512764efc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189251
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Christopher Sherlock
2025-08-11 09:45:01 +02:00
committed by Michael Weghorn
parent 7b93ad1ff2
commit d0a5366b82
+38 -38
View File
@@ -130,50 +130,50 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize,
if ( mbOutputClipped )
return;
if( !aBmp.IsEmpty() )
if (aBmp.IsEmpty())
return;
SalTwoRect aPosAry(rSrcPtPixel.X(), rSrcPtPixel.Y(), rSrcSizePixel.Width(), rSrcSizePixel.Height(),
ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
ImplLogicWidthToDevicePixel(rDestSize.Width()),
ImplLogicHeightToDevicePixel(rDestSize.Height()));
if (!aPosAry.mnSrcWidth || !aPosAry.mnSrcHeight || !aPosAry.mnDestWidth || !aPosAry.mnDestHeight)
return;
const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, aBmp.GetSizePixel() );
if ( nMirrFlags != BmpMirrorFlags::NONE )
aBmp.Mirror( nMirrFlags );
if (!aPosAry.mnSrcWidth || !aPosAry.mnSrcHeight || !aPosAry.mnDestWidth || !aPosAry.mnDestHeight)
return;
if (nAction == MetaActionType::BMPSCALE && CanSubsampleBitmap())
{
SalTwoRect aPosAry(rSrcPtPixel.X(), rSrcPtPixel.Y(), rSrcSizePixel.Width(), rSrcSizePixel.Height(),
ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
ImplLogicWidthToDevicePixel(rDestSize.Width()),
ImplLogicHeightToDevicePixel(rDestSize.Height()));
double nScaleX = aPosAry.mnDestWidth / static_cast<double>(aPosAry.mnSrcWidth);
double nScaleY = aPosAry.mnDestHeight / static_cast<double>(aPosAry.mnSrcHeight);
if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
// 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))
{
const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, aBmp.GetSizePixel() );
nScaleX *= fScale;
nScaleY *= fScale;
}
if ( nMirrFlags != BmpMirrorFlags::NONE )
aBmp.Mirror( nMirrFlags );
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;
}
}
mpGraphics->DrawBitmap( aPosAry, *aBmp.ImplGetSalBitmap(), *this );
}
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