canvas/source/cairo/cairo_devicehelper.cxx | 2 canvas/source/vcl/canvascustomsprite.cxx | 16 -- canvas/source/vcl/canvashelper.cxx | 139 ------------------------- canvas/source/vcl/canvashelper.hxx | 10 - canvas/source/vcl/canvashelper_texturefill.cxx | 72 +----------- canvas/source/vcl/devicehelper.cxx | 2 canvas/source/vcl/spritedevicehelper.cxx | 2 canvas/source/vcl/spritehelper.cxx | 36 +----- canvas/source/vcl/spritehelper.hxx | 4 sw/source/core/layout/paintfrm.cxx | 52 ++++----- 10 files changed, 43 insertions(+), 292 deletions(-)
New commits: commit e7b460f9197a57360dd017481dc747170e6a729f Author: Noel Grandin <[email protected]> AuthorDate: Sat Aug 30 15:23:11 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Aug 30 21:21:46 2025 +0200 BitmapEx->Bitmap in canvas now that Bitmap supports transparency Change-Id: I83630fdc6d2600ae0f853d5a00b3a65fd22e1572 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190412 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/canvas/source/cairo/cairo_devicehelper.cxx b/canvas/source/cairo/cairo_devicehelper.cxx index 5c586ea34e52..4859c4096298 100644 --- a/canvas/source/cairo/cairo_devicehelper.cxx +++ b/canvas/source/cairo/cairo_devicehelper.cxx @@ -230,7 +230,7 @@ namespace cairocanvas const ::Point aEmptyPoint; bool bOldMap( mpRefDevice->IsMapModeEnabled() ); mpRefDevice->EnableMapMode( false ); - const ::BitmapEx aTempBitmap(mpRefDevice->GetBitmap(aEmptyPoint, mpRefDevice->GetOutputSizePixel())); + const ::Bitmap aTempBitmap(mpRefDevice->GetBitmap(aEmptyPoint, mpRefDevice->GetOutputSizePixel())); WriteDIB(aTempBitmap, aStream, false); mpRefDevice->EnableMapMode( bOldMap ); diff --git a/canvas/source/vcl/canvascustomsprite.cxx b/canvas/source/vcl/canvascustomsprite.cxx index 316176f6ac24..a19dd18c4781 100644 --- a/canvas/source/vcl/canvascustomsprite.cxx +++ b/canvas/source/vcl/canvascustomsprite.cxx @@ -58,43 +58,27 @@ namespace vclcanvas BackBufferSharedPtr pBackBuffer = std::make_shared<BackBuffer>( rOutDevProvider->getOutDev() ); pBackBuffer->setSize( aSize ); - // create mask backbuffer - BackBufferSharedPtr pBackBufferMask = std::make_shared<BackBuffer>( rOutDevProvider->getOutDev() ); - pBackBufferMask->setSize( aSize ); - // TODO(F1): Implement alpha vdev (could prolly enable // antialiasing again, then) // disable font antialiasing (causes ugly shadows otherwise) pBackBuffer->getOutDev().SetAntialiasing( AntialiasingFlags::DisableText ); - pBackBufferMask->getOutDev().SetAntialiasing( AntialiasingFlags::DisableText ); - - // set mask vdev drawmode, such that everything is painted - // black. That leaves us with a binary image, white for - // background, black for painted content - pBackBufferMask->getOutDev().SetDrawMode( DrawModeFlags::BlackLine | DrawModeFlags::BlackFill | DrawModeFlags::BlackText | - DrawModeFlags::BlackGradient | DrawModeFlags::BlackBitmap ); - // setup canvas helper - // always render into back buffer, don't preserve state (it's // our private VDev, after all), have notion of alpha maCanvasHelper.init( rDevice, pBackBuffer, false, true ); - maCanvasHelper.setBackgroundOutDev( pBackBufferMask ); // setup sprite helper - maSpriteHelper.init( rSpriteSize, rOwningSpriteCanvas, pBackBuffer, - pBackBufferMask, bShowSpriteBounds ); // clear sprite to 100% transparent diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 602d385755fe..295661ce83a7 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -114,7 +114,6 @@ namespace vclcanvas mpDevice = nullptr; mpProtectedOutDevProvider.reset(); mpOutDevProvider.reset(); - mp2ndOutDevProvider.reset(); } void CanvasHelper::init( rendering::XGraphicDevice& rDevice, @@ -141,13 +140,6 @@ namespace vclcanvas mpOutDevProvider = rOutDev; } - void CanvasHelper::setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev ) - { - mp2ndOutDevProvider = rOutDev; - mp2ndOutDevProvider->getOutDev().EnableMapMode( false ); - mp2ndOutDevProvider->getOutDev().SetAntialiasing( AntialiasingFlags::Enable ); - } - void CanvasHelper::clear() { // are we disposed? @@ -164,22 +156,6 @@ namespace vclcanvas rOutDev.SetClipRegion(); rOutDev.DrawRect( ::tools::Rectangle( Point(), rOutDev.GetOutputSizePixel()) ); - - if( !mp2ndOutDevProvider ) - return; - - OutputDevice& rOutDev2( mp2ndOutDevProvider->getOutDev() ); - - rOutDev2.SetDrawMode( DrawModeFlags::Default ); - rOutDev2.EnableMapMode( false ); - rOutDev2.SetAntialiasing( AntialiasingFlags::Enable ); - rOutDev2.SetLineColor( COL_WHITE ); - rOutDev2.SetFillColor( COL_WHITE ); - rOutDev2.SetClipRegion(); - rOutDev2.DrawRect( ::tools::Rectangle( Point(), - rOutDev2.GetOutputSizePixel()) ); - rOutDev2.SetDrawMode( DrawModeFlags::BlackLine | DrawModeFlags::BlackFill | DrawModeFlags::BlackText | - DrawModeFlags::BlackGradient | DrawModeFlags::BlackBitmap ); } void CanvasHelper::drawLine( const rendering::XCanvas* , @@ -202,9 +178,6 @@ namespace vclcanvas viewState, renderState ) ); // TODO(F2): alpha mpOutDevProvider->getOutDev().DrawLine( aStartPoint, aEndPoint ); - - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawLine( aStartPoint, aEndPoint ); } void CanvasHelper::drawBezier( const rendering::XCanvas* , @@ -243,8 +216,6 @@ namespace vclcanvas // TODO(F2): alpha mpOutDevProvider->getOutDev().DrawPolygon( aPoly ); - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawPolygon( aPoly ); } uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas* , @@ -267,9 +238,6 @@ namespace vclcanvas if( aBasegfxPolyPoly.isClosed() ) { mpOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly ); - - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly ); } else { @@ -285,9 +253,6 @@ namespace vclcanvas for( sal_uInt16 i=0; i<nSize; ++i ) { mpOutDevProvider->getOutDev().DrawPolyLine( aPolyPoly[i] ); - - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawPolyLine( aPolyPoly[i] ); } } } @@ -402,12 +367,8 @@ namespace vclcanvas const basegfx::B2DPolygon& polygon = aStrokedPolyPoly.getB2DPolygon( i ); if( polygon.isClosed()) { mpOutDevProvider->getOutDev().DrawPolygon( polygon ); - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawPolygon( polygon ); } else { mpOutDevProvider->getOutDev().DrawPolyLine( polygon ); - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawPolyLine( polygon ); } } } @@ -475,19 +436,6 @@ namespace vclcanvas const int nTransPercent( ((255 - nAlpha) * 100 + 128) / 255 ); // normal rounding, no truncation here mpOutDevProvider->getOutDev().DrawTransparent( aPolyPoly, static_cast<sal_uInt16>(nTransPercent) ); } - - if( mp2ndOutDevProvider ) - { - // HACK. Normally, CanvasHelper does not care about - // actually what mp2ndOutDev is... well, here we do & - // assume a 1bpp target - everything beyond 97% - // transparency is fully transparent - if( nAlpha > 2 ) - { - mp2ndOutDevProvider->getOutDev().SetFillColor( COL_BLACK ); - mp2ndOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly ); - } - } } // TODO(P1): Provide caching here. @@ -571,15 +519,6 @@ namespace vclcanvas text.Text, ::canvastools::numeric_cast<sal_uInt16>(text.StartPosition), ::canvastools::numeric_cast<sal_uInt16>(text.Length) ); - - if( mp2ndOutDevProvider ) - { - mp2ndOutDevProvider->getOutDev().SetLayoutMode( nLayoutMode ); - mp2ndOutDevProvider->getOutDev().DrawText( aOutpos, - text.Text, - ::canvastools::numeric_cast<sal_uInt16>(text.StartPosition), - ::canvastools::numeric_cast<sal_uInt16>(text.Length) ); - } } return uno::Reference< rendering::XCachedPrimitive >(nullptr); @@ -613,9 +552,6 @@ namespace vclcanvas // TODO(F2): What about the offset scalings? // TODO(F2): alpha pTextLayout->draw( mpOutDevProvider->getOutDev(), aOutpos, viewState, renderState ); - - if( mp2ndOutDevProvider ) - pTextLayout->draw( mp2ndOutDevProvider->getOutDev(), aOutpos, viewState, renderState ); } } else @@ -683,21 +619,6 @@ namespace vclcanvas mpOutDevProvider->getOutDev().DrawBitmapEx( vcl::unotools::pointFromB2DPoint( aOutputPos ), aBmp ); - if( mp2ndOutDevProvider ) - { - // HACK. Normally, CanvasHelper does not care about - // actually what mp2ndOutDev is... well, here we do & - // assume a 1bpp target - everything beyond 97% - // transparency is fully transparent - if( aBmp.HasAlpha() && !SkiaHelper::isVCLSkiaEnabled()) - { - BitmapFilter::Filter(aBmp, BitmapAlphaClampFilter(253)); - } - - mp2ndOutDevProvider->getOutDev().DrawBitmapEx( vcl::unotools::pointFromB2DPoint( aOutputPos ), - aBmp ); - } - // Returning a cache object is not useful, the XBitmap // itself serves this purpose return uno::Reference< rendering::XCachedPrimitive >(nullptr); @@ -710,31 +631,6 @@ namespace vclcanvas const double fAlpha = bModulateColors ? renderState.DeviceColor[3] : 1.0; mpOutDevProvider->getOutDev().DrawTransformedBitmapEx( aMatrix, aBmp, fAlpha ); - if( mp2ndOutDevProvider ) - { - if( aBmp.HasAlpha() ) - { - // tdf#157790 invert alpha mask - // Due to commit 81994cb2b8b32453a92bcb011830fcb884f22ff3, - // the alpha mask needs to be inverted. Note: when - // testing tdf#157790, this code only gets executed - // when Skia is enabled. - AlphaMask aAlpha( aBmp.CreateAlphaMask() ); - aAlpha.Invert(); - aBmp = Bitmap( aBmp.CreateColorBitmap(), aAlpha ); - - // HACK. Normally, CanvasHelper does not care about - // actually what mp2ndOutDev is... well, here we do & - // assume a 1bpp target - everything beyond 97% - // transparency is fully transparent - if( !SkiaHelper::isVCLSkiaEnabled()) - { - BitmapFilter::Filter(aBmp, BitmapAlphaClampFilter(253)); - } - } - - mp2ndOutDevProvider->getOutDev().DrawTransformedBitmapEx( aMatrix, aBmp ); - } return uno::Reference< rendering::XCachedPrimitive >(nullptr); } else @@ -829,28 +725,6 @@ namespace vclcanvas aSz, &aGrfAttr); - if( mp2ndOutDevProvider ) - { - GraphicObjectSharedPtr p2ndGrfObj = pGrfObj; - if( aBmp.HasAlpha() ) - { - // tdf#157790 invert alpha mask - // Due to commit 81994cb2b8b32453a92bcb011830fcb884f22ff3, - // the alpha mask needs to be inverted. Note: when - // testing tdf#157790, this code only gets executed - // when Skia is disabled. - AlphaMask aAlpha( aBmp.CreateAlphaMask() ); - aAlpha.Invert(); - BitmapEx a2ndBmpEx( aBmp.CreateColorBitmap(), aAlpha ); - p2ndGrfObj = std::make_shared<GraphicObject>( Bitmap(a2ndBmpEx) ); - } - - p2ndGrfObj->Draw(mp2ndOutDevProvider->getOutDev(), - aPt, - aSz, - &aGrfAttr); - } - // created GraphicObject, which possibly cached // display bitmap - return cache object, to retain // that information. @@ -1041,9 +915,6 @@ namespace vclcanvas rOutDev.EnableMapMode( false ); rOutDev.SetAntialiasing( AntialiasingFlags::Enable ); - if( mp2ndOutDevProvider ) - p2ndOutDev = &mp2ndOutDevProvider->getOutDev(); - int nAlpha(255); // TODO(P2): Don't change clipping all the time, maintain current clip @@ -1143,9 +1014,6 @@ namespace vclcanvas rOutDev.SetFont( aVCLFont ); - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().SetFont( aVCLFont ); - return true; } @@ -1169,10 +1037,6 @@ namespace vclcanvas if (!rGrf->Draw(mpOutDevProvider->getOutDev(), rPt, rSz, &rAttr)) return false; - // #i80779# Redraw also into mask outdev - if (mp2ndOutDevProvider) - return rGrf->Draw(mp2ndOutDevProvider->getOutDev(), rPt, rSz, &rAttr); - return true; } } @@ -1181,9 +1045,6 @@ namespace vclcanvas { if (mpOutDevProvider) mpOutDevProvider->getOutDev().Flush(); - - if (mp2ndOutDevProvider) - mp2ndOutDevProvider->getOutDev().Flush(); } } diff --git a/canvas/source/vcl/canvashelper.hxx b/canvas/source/vcl/canvashelper.hxx index cf406d287351..86472c790eb1 100644 --- a/canvas/source/vcl/canvashelper.hxx +++ b/canvas/source/vcl/canvashelper.hxx @@ -86,13 +86,6 @@ namespace vclcanvas void setOutDev( const OutDevProviderSharedPtr& rOutDev, bool bProtect); - /** Set secondary output device - - Used for sprites, to generate mask bitmap. - */ - void setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev ); - - // CanvasHelper functionality // ========================== @@ -282,9 +275,6 @@ namespace vclcanvas /// Rendering to this outdev does not preserve its state OutDevProviderSharedPtr mpOutDevProvider; - /// Rendering to this outdev does not preserve its state - OutDevProviderSharedPtr mp2ndOutDevProvider; - /// When true, content is able to represent alpha bool mbHaveAlpha; diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx index 44eaabc2e666..011f9be7f469 100644 --- a/canvas/source/vcl/canvashelper_texturefill.cxx +++ b/canvas/source/vcl/canvashelper_texturefill.cxx @@ -477,14 +477,12 @@ namespace vclcanvas } bool gradientFill( OutputDevice& rOutDev, - OutputDevice* p2ndOutDev, const ::canvas::ParametricPolyPolygon::Values& rValues, const std::vector< ::Color >& rColors, const ::tools::PolyPolygon& rPoly, const rendering::ViewState& viewState, const rendering::RenderState& renderState, - const rendering::Texture& texture, - int nTransparency ) + const rendering::Texture& texture ) { // TODO(T2): It is maybe necessary to lock here, should // maGradientPoly someday cease to be const. But then, beware of @@ -533,16 +531,6 @@ namespace vclcanvas aPolygonDeviceRectOrig, nStepCount ); rOutDev.Pop(); - - if( p2ndOutDev && nTransparency < 253 ) - { - // HACK. Normally, CanvasHelper does not care about - // actually what mp2ndOutDev is... well, here we do & - // assume a 1bpp target - everything beyond 97% - // transparency is fully transparent - p2ndOutDev->SetFillColor( COL_BLACK ); - p2ndOutDev->DrawRect( aPolygonDeviceRectOrig ); - } } else { @@ -558,16 +546,6 @@ namespace vclcanvas aPolygonDeviceRectOrig, nStepCount ); rOutDev.Pop(); - - if( p2ndOutDev && nTransparency < 253 ) - { - // HACK. Normally, CanvasHelper does not care about - // actually what mp2ndOutDev is... well, here we do & - // assume a 1bpp target - everything beyond 97% - // transparency is fully transparent - p2ndOutDev->SetFillColor( COL_BLACK ); - p2ndOutDev->DrawPolyPolygon( rPoly ); - } } #ifdef DEBUG_CANVAS_CANVASHELPER_TEXTUREFILL @@ -611,7 +589,7 @@ namespace vclcanvas { vclcanvastools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); - const int nTransparency( setupOutDevState( viewState, renderState, IGNORE_COLOR ) ); + setupOutDevState( viewState, renderState, IGNORE_COLOR ); ::tools::PolyPolygon aPolyPoly( vclcanvastools::mapPolyPolygon( ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon), viewState, renderState ) ); @@ -650,14 +628,12 @@ namespace vclcanvas // TODO(E1): Return value // TODO(F1): FillRule gradientFill( mpOutDevProvider->getOutDev(), - mp2ndOutDevProvider ? &mp2ndOutDevProvider->getOutDev() : nullptr, aValues, aColors, aPolyPoly, viewState, renderState, - textures[0], - nTransparency ); + textures[0] ); } } else @@ -948,21 +924,6 @@ namespace vclcanvas nTilesY, aSz, aGrfAttr ); - - if( mp2ndOutDevProvider ) - { - OutputDevice& r2ndOutDev( mp2ndOutDevProvider->getOutDev() ); - r2ndOutDev.IntersectClipRegion( aPolygonDeviceRect ); - textureFill( r2ndOutDev, - *pGrfObj, - aPt, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - } } else { @@ -1001,7 +962,7 @@ namespace vclcanvas // output VDev content alpha-blended to // target position. const ::Point aEmptyPoint; - BitmapEx aContentBmp( + Bitmap aContentBmp( pVDev->GetBitmap( aEmptyPoint, pVDev->GetOutputSizePixel() ) ); @@ -1010,13 +971,9 @@ namespace vclcanvas AlphaMask aAlpha( pVDev->GetOutputSizePixel(), &nCol ); - BitmapEx aOutputBmpEx( aContentBmp.GetBitmap(), aAlpha ); + Bitmap aOutputBmp( aContentBmp.CreateColorBitmap(), aAlpha ); rOutDev.DrawBitmapEx( aPolygonDeviceRect.TopLeft(), - aOutputBmpEx ); - - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawBitmapEx( aPolygonDeviceRect.TopLeft(), - aOutputBmpEx ); + aOutputBmp ); } else { @@ -1035,23 +992,6 @@ namespace vclcanvas aSz, aGrfAttr ); rOutDev.Pop(); - - if( mp2ndOutDevProvider ) - { - OutputDevice& r2ndOutDev( mp2ndOutDevProvider->getOutDev() ); - auto popIt = r2ndOutDev.ScopedPush(vcl::PushFlags::CLIPREGION); - - r2ndOutDev.IntersectClipRegion( aPolyClipRegion ); - textureFill( r2ndOutDev, - *pGrfObj, - aPt, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - } } } } diff --git a/canvas/source/vcl/devicehelper.cxx b/canvas/source/vcl/devicehelper.cxx index 51d2ad05e820..7023458175b4 100644 --- a/canvas/source/vcl/devicehelper.cxx +++ b/canvas/source/vcl/devicehelper.cxx @@ -206,7 +206,7 @@ namespace vclcanvas OutputDevice& rOutDev = mpOutDev->getOutDev(); bool bOldMap( rOutDev.IsMapModeEnabled() ); rOutDev.EnableMapMode( false ); - WriteDIB(BitmapEx(rOutDev.GetBitmap(aEmptyPoint, rOutDev.GetOutputSizePixel())), aStream, false); + WriteDIB(rOutDev.GetBitmap(aEmptyPoint, rOutDev.GetOutputSizePixel()), aStream, false); rOutDev.EnableMapMode( bOldMap ); ++nFilePostfixCount; diff --git a/canvas/source/vcl/spritedevicehelper.cxx b/canvas/source/vcl/spritedevicehelper.cxx index 2ce87c400b30..e26de98029c9 100644 --- a/canvas/source/vcl/spritedevicehelper.cxx +++ b/canvas/source/vcl/spritedevicehelper.cxx @@ -108,7 +108,7 @@ namespace vclcanvas const ::Point aEmptyPoint; mpBackBuffer->getOutDev().EnableMapMode( false ); mpBackBuffer->getOutDev().SetAntialiasing( AntialiasingFlags::Enable ); - WriteDIB(BitmapEx(mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint, mpBackBuffer->getOutDev().GetOutputSizePixel())), aStream, false); + WriteDIB(mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint, mpBackBuffer->getOutDev().GetOutputSizePixel()), aStream, false); } ++nFilePostfixCount; diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx index eda7a1e93f40..111a199adfca 100644 --- a/canvas/source/vcl/spritehelper.cxx +++ b/canvas/source/vcl/spritehelper.cxx @@ -49,14 +49,12 @@ namespace vclcanvas void SpriteHelper::init( const geometry::RealSize2D& rSpriteSize, const ::canvas::SpriteSurface::Reference& rOwningSpriteCanvas, const BackBufferSharedPtr& rBackBuffer, - const BackBufferSharedPtr& rBackBufferMask, bool bShowSpriteBounds ) { - ENSURE_OR_THROW( rOwningSpriteCanvas && rBackBuffer && rBackBufferMask, + ENSURE_OR_THROW( rOwningSpriteCanvas && rBackBuffer, "SpriteHelper::init(): Invalid sprite canvas or back buffer" ); mpBackBuffer = rBackBuffer; - mpBackBufferMask = rBackBufferMask; mbShowSpriteBounds = bShowSpriteBounds; init( rSpriteSize, rOwningSpriteCanvas ); @@ -65,7 +63,6 @@ namespace vclcanvas void SpriteHelper::disposing() { mpBackBuffer.reset(); - mpBackBufferMask.reset(); // forward to parent CanvasCustomSpriteHelper::disposing(); @@ -76,8 +73,7 @@ namespace vclcanvas bool& io_bSurfacesDirty, bool /*bBufferedUpdate*/ ) const { - if( !mpBackBuffer || - !mpBackBufferMask ) + if( !mpBackBuffer ) { return; // we're disposed } @@ -118,31 +114,13 @@ namespace vclcanvas if( bNeedBitmapUpdate ) { const Point aEmptyPoint; - BitmapEx aBmp( mpBackBuffer->getOutDev().GetBitmap( aEmptyPoint, + Bitmap aBmp( mpBackBuffer->getOutDev().GetBitmap( aEmptyPoint, aOutputSize ) ); - if( isContentFullyOpaque() ) - { - // optimized case: content canvas is fully - // opaque. Note: since we retrieved aBmp directly - // from an OutDev, it's already a 'display bitmap' - // on windows. - maContent = aBmp; - } - else - { - // sprite content might contain alpha, create - // BmpEx, then. - BitmapEx aMask( mpBackBufferMask->getOutDev().GetBitmap( aEmptyPoint, - aOutputSize ) ); - AlphaMask aAlpha( aMask.GetBitmap() ); - aAlpha.Invert(); - - // Note: since we retrieved aBmp and aMask - // directly from an OutDev, it's already a - // 'display bitmap' on windows. - maContent = BitmapEx( aBmp.GetBitmap(), aAlpha ); - } + // Note: since we retrieved aBmp directly + // from an OutDev, it's already a 'display bitmap' + // on windows. + maContent = aBmp; } ::basegfx::B2DHomMatrix aTransform( getTransformation() ); diff --git a/canvas/source/vcl/spritehelper.hxx b/canvas/source/vcl/spritehelper.hxx index 41d9883f6ffe..aa1a5a06da52 100644 --- a/canvas/source/vcl/spritehelper.hxx +++ b/canvas/source/vcl/spritehelper.hxx @@ -64,7 +64,6 @@ namespace vclcanvas void init( const css::geometry::RealSize2D& rSpriteSize, const ::canvas::SpriteSurface::Reference& rOwningSpriteCanvas, const BackBufferSharedPtr& rBackBuffer, - const BackBufferSharedPtr& rBackBufferMask, bool bShowSpriteBounds ); void disposing(); @@ -94,10 +93,9 @@ namespace vclcanvas // for the redraw BackBufferSharedPtr mpBackBuffer; - BackBufferSharedPtr mpBackBufferMask; /// Cached bitmap for the current sprite content - mutable ::canvas::vcltools::VCLObject<BitmapEx> maContent; + mutable ::canvas::vcltools::VCLObject<Bitmap> maContent; /// When true, line sprite corners in red bool mbShowSpriteBounds; commit df1bd879fd2309d5423a06c7f60d5b5fb43eb403 Author: Noel Grandin <[email protected]> AuthorDate: Sat Aug 30 15:07:02 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Aug 30 21:21:37 2025 +0200 BitmapEx->Bitmap in PaintBorderAndShadow now that Bitmap supports transparency Change-Id: I6577b815cc49e1d13a740184b47df652d49051fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190411 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 40f2559279c4..e6cfe5dd0009 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6293,7 +6293,7 @@ enum PaintArea {LEFT, RIGHT, TOP, BOTTOM}; #define BORDER_TILE_SIZE 512 /// Wrapper around pOut->DrawBitmapEx. -static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoint, const Size& aSize, const BitmapEx& rBitmapEx, PaintArea eArea) +static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoint, const Size& aSize, const Bitmap& rBitmap, PaintArea eArea) { if(!comphelper::LibreOfficeKit::isActive()) { @@ -6333,7 +6333,7 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin pOut->DrawBitmapEx(pOut->PixelToLogic(aRender.TopLeft()), pOut->PixelToLogic(aRender.GetSize()), Point(0, 0), aRender.GetSize(), - rBitmapEx); + rBitmap); } } @@ -6362,22 +6362,22 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin ImageLoadFlags::IgnoreDarkTheme | ImageLoadFlags::IgnoreScalingFactor)); drawinglayer::primitive2d::DiscreteShadow& shadowMask = *shadowMaskObj.get(); - static tools::DeleteOnDeinit< BitmapEx > aPageTopRightShadowObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageBottomRightShadowObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageBottomLeftShadowObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageBottomShadowBaseObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageRightShadowBaseObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageTopShadowBaseObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageTopLeftShadowObj {}; - static tools::DeleteOnDeinit< BitmapEx > aPageLeftShadowBaseObj {}; - BitmapEx& aPageTopRightShadow = *aPageTopRightShadowObj.get(); - BitmapEx& aPageBottomRightShadow = *aPageBottomRightShadowObj.get(); - BitmapEx& aPageBottomLeftShadow = *aPageBottomLeftShadowObj.get(); - BitmapEx& aPageBottomShadow = *aPageBottomShadowBaseObj.get(); - BitmapEx& aPageRightShadow = *aPageRightShadowBaseObj.get(); - BitmapEx& aPageTopShadow = *aPageTopShadowBaseObj.get(); - BitmapEx& aPageTopLeftShadow = *aPageTopLeftShadowObj.get(); - BitmapEx& aPageLeftShadow = *aPageLeftShadowBaseObj.get(); + static tools::DeleteOnDeinit< Bitmap > aPageTopRightShadowObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageBottomRightShadowObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageBottomLeftShadowObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageBottomShadowBaseObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageRightShadowBaseObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageTopShadowBaseObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageTopLeftShadowObj {}; + static tools::DeleteOnDeinit< Bitmap > aPageLeftShadowBaseObj {}; + Bitmap& aPageTopRightShadow = *aPageTopRightShadowObj.get(); + Bitmap& aPageBottomRightShadow = *aPageBottomRightShadowObj.get(); + Bitmap& aPageBottomLeftShadow = *aPageBottomLeftShadowObj.get(); + Bitmap& aPageBottomShadow = *aPageBottomShadowBaseObj.get(); + Bitmap& aPageRightShadow = *aPageRightShadowBaseObj.get(); + Bitmap& aPageTopShadow = *aPageTopShadowBaseObj.get(); + Bitmap& aPageTopLeftShadow = *aPageTopLeftShadowObj.get(); + Bitmap& aPageLeftShadow = *aPageLeftShadowBaseObj.get(); static Color aShadowColor( COL_AUTO ); SwRect aAlignedPageRect( _rPageRect ); @@ -6391,42 +6391,42 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin AlphaMask aMask( shadowMask.getBottomRight().CreateColorBitmap() ); Bitmap aFilledSquare(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageBottomRightShadow = BitmapEx( aFilledSquare, aMask ); + aPageBottomRightShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getBottomLeft().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageBottomLeftShadow = BitmapEx( aFilledSquare, aMask ); + aPageBottomLeftShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getBottom().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageBottomShadow = BitmapEx( aFilledSquare, aMask ); + aPageBottomShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getTop().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageTopShadow = BitmapEx( aFilledSquare, aMask ); + aPageTopShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getTopRight().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageTopRightShadow = BitmapEx( aFilledSquare, aMask ); + aPageTopRightShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getRight().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageRightShadow = BitmapEx( aFilledSquare, aMask ); + aPageRightShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getTopLeft().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageTopLeftShadow = BitmapEx( aFilledSquare, aMask ); + aPageTopLeftShadow = Bitmap( aFilledSquare, aMask ); aMask = AlphaMask( shadowMask.getLeft().CreateColorBitmap() ); aFilledSquare = Bitmap(aMask.GetSizePixel(), vcl::PixelFormat::N24_BPP); aFilledSquare.Erase( aShadowColor ); - aPageLeftShadow = BitmapEx( aFilledSquare, aMask ); + aPageLeftShadow = Bitmap( aFilledSquare, aMask ); } SwRect aPaintRect;
