include/vcl/outdev.hxx | 4 - vcl/source/outdev/bitmap.cxx | 82 ++++++++++++++++++++++++++++++++++++++-- vcl/source/outdev/bitmapex.cxx | 66 +------------------------------- vcl/source/outdev/wallpaper.cxx | 2 4 files changed, 84 insertions(+), 70 deletions(-)
New commits: commit e53c5bcd82c6f6d7bc75f987e666aef5e5763866 Author: Christopher Sherlock <[email protected]> AuthorDate: Sat Sep 13 00:40:34 2025 +1000 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Oct 27 06:19:09 2025 +0100 vcl: rename DrawBitmapEx() to DrawAlphaBitmap() The DrawBitmapEx() functions forward to this version of DrawBitmapEx(). Before they foward they check if it is an alpha bitmap, if it isn't then they call on DrawBitmap(). The version of the function they forward to merely draws an alpha bitmap - there is no need for it to check that the bitmap has an alpha channel as this was done already. In fact, anything that calls directly on this function without such a bitmap should be calling DrawBitmapEx(), so I've added an assert() to flag when this occurs. Change-Id: Ia94caf28ba1d49ec7c9f17654ca73ef51baf49a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190896 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 3cc7d153a53f..7e61011aa603 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1337,8 +1337,8 @@ public: const Size& rSrcSizePixel, const Bitmap& rBitmap); - // draw bitmap, potentially with alpha information - SAL_DLLPRIVATE void DrawBitmapEx( + // draw bitmap with alpha information + SAL_DLLPRIVATE void DrawAlphaBitmap( const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 20de6b75b7bf..b163babde789 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -38,15 +38,28 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Bitmap& rBitmap ) { assert(!is_double_buffered_window()); - const Size aSizePix( rBitmap.GetSizePixel() ); - DrawBitmap( rDestPt, PixelToLogic( aSizePix ), Point(), aSizePix, rBitmap, MetaActionType::BMP ); + const Size aSizePix(rBitmap.GetSizePixel()); + + if (!rBitmap.HasAlpha()) + { + DrawBitmap(rDestPt, PixelToLogic(aSizePix), Point(), aSizePix, rBitmap, MetaActionType::BMP); + return; + } + + DrawAlphaBitmap(rDestPt, PixelToLogic(aSizePix), Point(), aSizePix, rBitmap, MetaActionType::BMPEX); } void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, const Bitmap& rBitmap ) { assert(!is_double_buffered_window()); - DrawBitmap( rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, MetaActionType::BMPSCALE ); + if (!rBitmap.HasAlpha()) + { + DrawBitmap(rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, MetaActionType::BMPSCALE); + return; + } + + DrawAlphaBitmap(rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, MetaActionType::BMPEXSCALE); } void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, @@ -55,7 +68,13 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, { assert(!is_double_buffered_window()); - DrawBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap, MetaActionType::BMPSCALEPART ); + if (!rBitmap.HasAlpha()) + { + DrawBitmap(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap, MetaActionType::BMPSCALEPART); + return; + } + + DrawAlphaBitmap(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap, MetaActionType::BMPEXSCALEPART); } void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, @@ -158,6 +177,61 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, mpGraphics->DrawBitmap( aPosAry, *aBmp.ImplGetSalBitmap(), *this ); } +void OutputDevice::DrawAlphaBitmap( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap, const MetaActionType nAction ) +{ + assert(!is_double_buffered_window()); + assert(rBitmap.HasAlpha()); + + if( ImplIsRecordLayout() ) + return; + + if (RasterOp::Invert == meRasterOp) + { + DrawRect(tools::Rectangle(rDestPt, rDestSize)); + return; + } + + Bitmap aBmp(vcl::drawmode::GetBitmap(rBitmap, GetDrawMode())); + + if (mpMetaFile) + { + switch(nAction) + { + case MetaActionType::BMPEX: + mpMetaFile->AddAction(new MetaBmpExAction(rDestPt, aBmp)); + break; + + case MetaActionType::BMPEXSCALE: + mpMetaFile->AddAction(new MetaBmpExScaleAction(rDestPt, rDestSize, aBmp)); + break; + + case MetaActionType::BMPEXSCALEPART: + mpMetaFile->AddAction(new MetaBmpExScalePartAction(rDestPt, rDestSize, + rSrcPtPixel, rSrcSizePixel, aBmp)); + break; + + default: + break; + } + } + + if (!IsDeviceOutputNecessary()) + return; + + if (!mpGraphics && !AcquireGraphics()) + return; + + if (mbInitClipRegion) + InitClipRegion(); + + if (mbOutputClipped) + return; + + DrawDeviceBitmapEx(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmp); +} + Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const { if ( !mpGraphics && !AcquireGraphics() ) diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx index 90d3bd8fc23c..42c7511f041b 100644 --- a/vcl/source/outdev/bitmapex.cxx +++ b/vcl/source/outdev/bitmapex.cxx @@ -46,7 +46,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, } const Size aSizePx = rBitmap.GetSizePixel(); - DrawBitmapEx(rDestPt, PixelToLogic(aSizePx), Point(), aSizePx, rBitmap, + DrawAlphaBitmap(rDestPt, PixelToLogic(aSizePx), Point(), aSizePx, rBitmap, MetaActionType::BMPEX); } @@ -64,7 +64,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, return; } - DrawBitmapEx(rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), + DrawAlphaBitmap(rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, MetaActionType::BMPEXSCALE); } @@ -84,70 +84,10 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, return; } - DrawBitmapEx(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap, + DrawAlphaBitmap(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap, MetaActionType::BMPEXSCALEPART); } -void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, - const Point& rSrcPtPixel, const Size& rSrcSizePixel, - const Bitmap& rBitmap, const MetaActionType nAction ) -{ - assert(!is_double_buffered_window()); - - if( ImplIsRecordLayout() ) - return; - - if( !rBitmap.HasAlpha() ) - { - DrawBitmap(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap); - return; - } - - if (RasterOp::Invert == meRasterOp) - { - DrawRect(tools::Rectangle(rDestPt, rDestSize)); - return; - } - - Bitmap aBmp(vcl::drawmode::GetBitmap(rBitmap, GetDrawMode())); - - if (mpMetaFile) - { - switch(nAction) - { - case MetaActionType::BMPEX: - mpMetaFile->AddAction(new MetaBmpExAction(rDestPt, aBmp)); - break; - - case MetaActionType::BMPEXSCALE: - mpMetaFile->AddAction(new MetaBmpExScaleAction(rDestPt, rDestSize, aBmp)); - break; - - case MetaActionType::BMPEXSCALEPART: - mpMetaFile->AddAction(new MetaBmpExScalePartAction(rDestPt, rDestSize, - rSrcPtPixel, rSrcSizePixel, aBmp)); - break; - - default: - break; - } - } - - if (!IsDeviceOutputNecessary()) - return; - - if (!mpGraphics && !AcquireGraphics()) - return; - - if (mbInitClipRegion) - InitClipRegion(); - - if (mbOutputClipped) - return; - - DrawDeviceBitmapEx(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmp); -} - void OutputDevice::DrawDeviceBitmapEx( const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel, Bitmap& rBitmap ) diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx index bcefc2557551..dac34d94c8d7 100644 --- a/vcl/source/outdev/wallpaper.cxx +++ b/vcl/source/outdev/wallpaper.cxx @@ -316,7 +316,7 @@ void OutputDevice::DrawBitmapWallpaper( tools::Long nX, tools::Long nY, if( !aBmp.HasAlpha() ) DrawBitmap( Point( nBmpX, nBmpY ), PixelToLogic( aSizePx ), Point(), aSizePx, aBmp, MetaActionType::BMP ); else - DrawBitmapEx(Point( nBmpX, nBmpY ), PixelToLogic(aSizePx), Point(), aSizePx, aBmp, + DrawAlphaBitmap(Point( nBmpX, nBmpY ), PixelToLogic(aSizePx), Point(), aSizePx, aBmp, MetaActionType::BMPEX); } }
