From 87fbe86b7140a77cc6e38f063b08af9213078ca3 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 17 May 2011 10:03:46 +0200 Subject: generalize ScopedBitmapAccess and simplify usage It can be used for AlphaMask too now. --- canvas/source/directx/dx_vcltools.cxx | 9 +++------ canvas/source/vcl/canvasbitmaphelper.cxx | 20 ++++++++------------ canvas/source/vcl/canvashelper.cxx | 9 +++------ canvas/source/vcl/impltools.cxx | 11 ++++------- 4 files changed, 18 insertions(+), 31 deletions(-) (limited to 'canvas') diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx index 0801ad81c780..aec1b4307791 100644 --- a/canvas/source/directx/dx_vcltools.cxx +++ b/canvas/source/directx/dx_vcltools.cxx @@ -178,8 +178,7 @@ namespace dxcanvas Bitmap aBitmap( rBmpEx.GetBitmap() ); - ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(), - aBitmap ); + Bitmap::ScopedReadAccess pReadAccess( aBitmap ); const sal_Int32 nWidth( aBmpSize.Width() ); const sal_Int32 nHeight( aBmpSize.Height() ); @@ -192,8 +191,7 @@ namespace dxcanvas { Bitmap aAlpha( rBmpEx.GetAlpha().GetBitmap() ); - ScopedBitmapReadAccess pAlphaReadAccess( aAlpha.AcquireReadAccess(), - aAlpha ); + Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha ); // By convention, the access buffer always has // one of the following formats: @@ -335,8 +333,7 @@ namespace dxcanvas { Bitmap aMask( rBmpEx.GetMask() ); - ScopedBitmapReadAccess pMaskReadAccess( aMask.AcquireReadAccess(), - aMask ); + Bitmap::ScopedReadAccess pMaskReadAccess( aMask ); // By convention, the access buffer always has // one of the following formats: diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx index 38dcc9e844e8..2c5a9ff0f220 100644 --- a/canvas/source/vcl/canvasbitmaphelper.cxx +++ b/canvas/source/vcl/canvasbitmaphelper.cxx @@ -149,9 +149,8 @@ namespace vclcanvas Bitmap aBitmap( mpBackBuffer->getBitmapReference().GetBitmap() ); Bitmap aAlpha( mpBackBuffer->getBitmapReference().GetAlpha().GetBitmap() ); - ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(), - aBitmap ); - ScopedBitmapReadAccess pAlphaReadAccess( aAlpha.IsEmpty() ? + Bitmap::ScopedReadAccess pReadAccess( aBitmap ); + Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha.IsEmpty() ? (BitmapReadAccess*)NULL : aAlpha.AcquireReadAccess(), aAlpha ); @@ -229,9 +228,8 @@ namespace vclcanvas // actually changed a pixel { - ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(), - aBitmap ); - ScopedBitmapWriteAccess pAlphaWriteAccess( aAlpha.IsEmpty() ? + Bitmap::ScopedWriteAccess pWriteAccess( aBitmap ); + Bitmap::ScopedWriteAccess pAlphaWriteAccess( aAlpha.IsEmpty() ? (BitmapWriteAccess*)NULL : aAlpha.AcquireWriteAccess(), aAlpha ); @@ -471,9 +469,8 @@ namespace vclcanvas // actually changed a pixel { - ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(), - aBitmap ); - ScopedBitmapWriteAccess pAlphaWriteAccess( aAlpha.IsEmpty() ? + Bitmap::ScopedWriteAccess pWriteAccess( aBitmap ); + Bitmap::ScopedWriteAccess pAlphaWriteAccess( aAlpha.IsEmpty() ? (BitmapWriteAccess*)NULL : aAlpha.AcquireWriteAccess(), aAlpha ); @@ -525,9 +522,8 @@ namespace vclcanvas Bitmap aBitmap( mpBackBuffer->getBitmapReference().GetBitmap() ); Bitmap aAlpha( mpBackBuffer->getBitmapReference().GetAlpha().GetBitmap() ); - ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(), - aBitmap ); - ScopedBitmapReadAccess pAlphaReadAccess( aAlpha.IsEmpty() ? + Bitmap::ScopedReadAccess pReadAccess( aBitmap ); + Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha.IsEmpty() ? (BitmapReadAccess*)NULL : aAlpha.AcquireReadAccess(), aAlpha ); ENSURE_OR_THROW( pReadAccess.get() != NULL, diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 6fb918df8f1c..38185d812fb5 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -948,8 +948,7 @@ namespace vclcanvas Bitmap aBitmap( rOutDev.GetBitmap(aRect.TopLeft(), aRect.GetSize()) ); - ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(), - aBitmap ); + Bitmap::ScopedReadAccess pReadAccess( aBitmap ); ENSURE_OR_THROW( pReadAccess.get() != NULL, "Could not acquire read access to OutDev bitmap" ); @@ -1014,8 +1013,7 @@ namespace vclcanvas Bitmap aTmpBitmap( rOutDev.GetBitmap( aEmptyPoint, aSize ) ); - ScopedBitmapReadAccess pReadAccess( aTmpBitmap.AcquireReadAccess(), - aTmpBitmap ); + Bitmap::ScopedReadAccess pReadAccess( aTmpBitmap ); pPalette = &pReadAccess->GetPalette(); } @@ -1026,8 +1024,7 @@ namespace vclcanvas bool bCopyBack( false ); // only copy something back, if we // actually changed some pixel { - ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(), - aBitmap ); + Bitmap::ScopedWriteAccess pWriteAccess( aBitmap ); ENSURE_OR_THROW( pWriteAccess.get() != NULL, "Could not acquire write access to OutDev bitmap" ); diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx index 24f32aadc237..a8187766e15b 100644 --- a/canvas/source/vcl/impltools.cxx +++ b/canvas/source/vcl/impltools.cxx @@ -277,9 +277,8 @@ namespace vclcanvas aSrcAlpha = rBitmap.GetMask(); } - ScopedBitmapReadAccess pReadAccess( aSrcBitmap.AcquireReadAccess(), - aSrcBitmap ); - ScopedBitmapReadAccess pAlphaReadAccess( rBitmap.IsTransparent() ? + Bitmap::ScopedReadAccess pReadAccess( aSrcBitmap ); + Bitmap::ScopedReadAccess pAlphaReadAccess( rBitmap.IsTransparent() ? aSrcAlpha.AcquireReadAccess() : (BitmapReadAccess*)NULL, aSrcAlpha ); @@ -334,10 +333,8 @@ namespace vclcanvas // copy-constructing the resulting bitmap. This will // rule out the possibility that cached accessor data // is not yet written back. - ScopedBitmapWriteAccess pWriteAccess( aDstBitmap.AcquireWriteAccess(), - aDstBitmap ); - ScopedBitmapWriteAccess pAlphaWriteAccess( aDstAlpha.AcquireWriteAccess(), - aDstAlpha ); + Bitmap::ScopedWriteAccess pWriteAccess( aDstBitmap ); + Bitmap::ScopedWriteAccess pAlphaWriteAccess( aDstAlpha ); if( pWriteAccess.get() != NULL && -- cgit