diff options
author | Mark Page <aptitude@btconnect.com> | 2016-12-05 09:59:25 +0000 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-05 19:23:06 +0000 |
commit | 7006568138b5b2d2c11dd558049cd4085c449c9e (patch) | |
tree | 7138ef172ffd1d7fa72cbfaac71225a9bbc29151 /vcl | |
parent | 8725c011de34206a91aa4d422a0b67a845cf2e1c (diff) |
Change Read/Write access to Scoped Read/Write access
Change-Id: I2259af0d169f850ceb39f22424197912dfd20171
Reviewed-on: https://gerrit.libreoffice.org/31624
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/wmf/winmtf.cxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap.cxx | 137 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap3.cxx | 116 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap4.cxx | 81 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 35 | ||||
-rw-r--r-- | vcl/source/gdi/dibtools.cxx | 30 | ||||
-rw-r--r-- | vcl/source/gdi/impvect.cxx | 13 | ||||
-rw-r--r-- | vcl/source/gdi/print2.cxx | 4 |
8 files changed, 193 insertions, 231 deletions
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx index 1c66a1b8bfd8..43f23ece94af 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -1552,8 +1552,8 @@ void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const B // need to blend in AlphaMask quality (8Bit) AlphaMask fromVDev(aVDevMask); AlphaMask fromBmpEx(aBmpEx.GetAlpha()); - BitmapReadAccess* pR = fromVDev.AcquireReadAccess(); - BitmapWriteAccess* pW = fromBmpEx.AcquireWriteAccess(); + AlphaMask::ScopedReadAccess pR(fromVDev); + AlphaMask::ScopedWriteAccess pW(fromBmpEx); if(pR && pW) { @@ -1574,8 +1574,8 @@ void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const B } } - fromVDev.ReleaseAccess(pR); - fromBmpEx.ReleaseAccess(pW); + pR.reset(); + pW.reset(); aBmpEx = BitmapEx(aBmpEx.GetBitmap(), fromBmpEx); } else diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index f5ce79857b96..ec382f267612 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -267,12 +267,11 @@ bool Bitmap::HasGreyPalette() const const sal_uInt16 nBitCount = GetBitCount(); bool bRet = nBitCount == 1; - BitmapInfoAccess* pIAcc = const_cast<Bitmap*>(this)->AcquireInfoAccess(); + ScopedInfoAccess pIAcc(const_cast<Bitmap&>(*this)); if( pIAcc ) { bRet = pIAcc->HasPalette() && pIAcc->GetPalette().IsGreyPalette(); - ReleaseAccess( pIAcc ); } return bRet; @@ -452,7 +451,7 @@ bool Bitmap::Erase(const Color& rFillColor) bool Bitmap::Invert() { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pAcc ) @@ -478,7 +477,7 @@ bool Bitmap::Invert() } mxImpBmp->ImplInvalidateChecksum(); - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } @@ -493,7 +492,7 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) if( bHorz && !bVert ) { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -513,13 +512,13 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } else if( bVert && !bHorz ) { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -536,13 +535,13 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) memcpy( pAcc->GetScanline( nOther ), pBuffer.get(), nScanSize ); } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } else if( bHorz && bVert ) { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -573,7 +572,7 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } @@ -596,7 +595,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) bRet = Mirror( BmpMirrorFlags::Horizontal | BmpMirrorFlags::Vertical ); else { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); Bitmap aRotatedBmp; if( pReadAcc ) @@ -607,7 +606,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) { const Size aNewSizePix( aSizePix.Height(), aSizePix.Width() ); Bitmap aNewBmp( aNewSizePix, GetBitCount(), &pReadAcc->GetPalette() ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -631,7 +630,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) pWriteAcc->SetPixel( nY, nX, pReadAcc->GetPixel( nOtherY--, nOtherX ) ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } aRotatedBmp = aNewBmp; @@ -646,7 +645,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) Rectangle aNewBound( aPoly.GetBoundRect() ); const Size aNewSizePix( aNewBound.GetSize() ); Bitmap aNewBmp( aNewSizePix, GetBitCount(), &pReadAcc->GetPalette() ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -701,13 +700,13 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) } } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } aRotatedBmp = aNewBmp; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); } bRet = !!aRotatedBmp; @@ -728,14 +727,14 @@ bool Bitmap::Crop( const Rectangle& rRectPixel ) if( !aRect.IsEmpty() && aSizePix != aRect.GetSize()) { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); if( pReadAcc ) { Point aTmpPoint; const Rectangle aNewRect( aTmpPoint, aRect.GetSize() ); Bitmap aNewBmp( aNewRect.GetSize(), GetBitCount(), &pReadAcc->GetPalette() ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -748,11 +747,11 @@ bool Bitmap::Crop( const Rectangle& rRectPixel ) for( long nX = 0, nX2 = nOldX; nX < nNewWidth; nX++, nX2++ ) pWriteAcc->SetPixel( nY, nX, pReadAcc->GetPixel( nY2, nX2 ) ); - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) ImplAssignWithSize( aNewBmp ); @@ -800,8 +799,8 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, if( nNextIndex ) { - BitmapReadAccess* pSrcAcc = pSrc->AcquireReadAccess(); - BitmapWriteAccess* pDstAcc = AcquireWriteAccess(); + ScopedReadAccess pSrcAcc(*pSrc); + ScopedWriteAccess pDstAcc(*this); if( pSrcAcc && pDstAcc ) { @@ -827,12 +826,6 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, pDstAcc->SetPaletteColor( (sal_uInt16) nNextIndex++, rSrcCol ); } } - - if( pSrcAcc ) - ReleaseAccess( pSrcAcc ); - - if( pDstAcc ) - ReleaseAccess( pDstAcc ); } } @@ -840,11 +833,11 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, if( !aRectSrc.IsEmpty() ) { - BitmapReadAccess* pReadAcc = pSrc->AcquireReadAccess(); + ScopedReadAccess pReadAcc(*pSrc); if( pReadAcc ) { - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -879,11 +872,11 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ ) pWriteAcc->SetPixel( nDstY, nDstX, pReadAcc->GetPixel( nSrcY, nSrcX ) ); - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = ( nWidth > 0L ) && ( nHeight > 0L ); } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); } } } @@ -895,7 +888,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, if( !aRectSrc.IsEmpty() && ( aRectSrc != aRectDst ) ) { - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -935,7 +928,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } } @@ -968,11 +961,11 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl if( !aRectSrc.IsEmpty() ) { - BitmapReadAccess* pReadAcc = pSrc->AcquireReadAccess(); + ScopedReadAccess pReadAcc(*pSrc); if( pReadAcc ) { - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -986,11 +979,11 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ ) pWriteAcc->SetPixel( nDstY, nDstX, pReadAcc->GetPixel( nSrcY, nSrcX ) ); - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = ( nWidth > 0L ) && ( nHeight > 0L ); } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); } } } @@ -1002,7 +995,7 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl if( !aRectSrc.IsEmpty() && ( aRectSrc != aRectDst ) ) { - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -1042,7 +1035,7 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } } @@ -1063,13 +1056,13 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor ) const long nWidth = aSizePixel.Width(); const long nHeight = aSizePixel.Height(); const Size aNewSize( nWidth + nDX, nHeight + nDY ); - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); if( pReadAcc ) { BitmapPalette aBmpPal( pReadAcc->GetPalette() ); Bitmap aNewBmp( aNewSize, GetBitCount(), &aBmpPal ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -1098,11 +1091,11 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor ) for( nX = 0; nX < nNewWidth; nX++ ) pWriteAcc->SetPixel( nY, nX, aColor ); - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) ImplAssignWithSize( aNewBmp ); @@ -1115,12 +1108,12 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor ) Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const { Bitmap aNewBmp( GetSizePixel(), 1 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); bool bRet = false; if( pWriteAcc ) { - BitmapReadAccess* pReadAcc = const_cast<Bitmap*>(this)->AcquireReadAccess(); + ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); if( pReadAcc ) { @@ -1284,11 +1277,11 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const } } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); bRet = true; } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } if( bRet ) @@ -1304,9 +1297,9 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) const { - vcl::Region aRegion; + vcl::Region aRegion; Rectangle aRect( rRect ); - BitmapReadAccess* pReadAcc = const_cast<Bitmap*>(this)->AcquireReadAccess(); + ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); aRect.Intersection( Rectangle( Point(), GetSizePixel() ) ); aRect.Justify(); @@ -1399,7 +1392,7 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) //aRegion.ImplEndAddRect(); //aRegion.SetRegionRectangles(aRectangles); - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); } else aRegion = aRect; @@ -1409,8 +1402,8 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) { - BitmapReadAccess* pMaskAcc = ( (Bitmap&) rMask ).AcquireReadAccess(); - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedReadAccess pMaskAcc( const_cast<Bitmap&>(rMask) ); + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pMaskAcc && pAcc ) @@ -1473,18 +1466,15 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) bRet = true; } - ReleaseAccess( pMaskAcc ); - ReleaseAccess( pAcc ); - return bRet; } bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) { Bitmap aNewBmp( GetSizePixel(), 24 ); - BitmapReadAccess* pAcc = AcquireReadAccess(); - BitmapReadAccess* pAlphaAcc = ( (AlphaMask&) rAlpha ).AcquireReadAccess(); - BitmapWriteAccess* pNewAcc = aNewBmp.AcquireWriteAccess(); + ScopedReadAccess pAcc(*this); + AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlpha)); + ScopedWriteAccess pNewAcc(aNewBmp); bool bRet = false; if( pAcc && pAlphaAcc && pNewAcc ) @@ -1505,9 +1495,9 @@ bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) bRet = true; } - ReleaseAccess( pAcc ); - ReleaseAccess( pAlphaAcc ); - ReleaseAccess( pNewAcc ); + pAcc.reset(); + pAlphaAcc.reset(); + pNewAcc.reset(); if( bRet ) { @@ -1543,7 +1533,7 @@ bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal if( 1 == GetBitCount() ) Convert( BMP_CONVERSION_4BIT_COLORS ); - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pAcc ) @@ -1590,7 +1580,7 @@ bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } @@ -1605,7 +1595,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, if( 1 == GetBitCount() ) Convert( BMP_CONVERSION_4BIT_COLORS ); - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pAcc ) @@ -1689,7 +1679,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, if( !_pTols ) delete[] pTols; - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } @@ -1714,8 +1704,8 @@ Bitmap Bitmap::CreateDisplayBitmap( OutputDevice* pDisplay ) bool Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) { - BitmapReadAccess* pMaskAcc = ( (Bitmap&) rMask ).AcquireReadAccess(); - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedReadAccess pMaskAcc(const_cast<Bitmap&>(rMask)); + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pMaskAcc && pAcc ) @@ -1843,9 +1833,6 @@ bool Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) bRet = true; } - ReleaseAccess( pMaskAcc ); - ReleaseAccess( pAcc ); - return bRet; } @@ -1858,8 +1845,9 @@ bool Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) if( GetBitCount() <= 8 ) Convert( BMP_CONVERSION_24BIT ); - BitmapReadAccess* pAlphaAcc = const_cast<AlphaMask&>(rAlpha).AcquireReadAccess(); - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlpha)); + + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pAlphaAcc && pAcc ) @@ -1876,9 +1864,6 @@ bool Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) bRet = true; } - ReleaseAccess( pAlphaAcc ); - ReleaseAccess( pAcc ); - return bRet; } diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index faaa65315e36..3fd517379d05 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -346,13 +346,13 @@ bool Bitmap::Convert( BmpConversion eConversion ) bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold ) { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); bool bRet = false; if( pReadAcc ) { Bitmap aNewBmp( GetSizePixel(), 1 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -395,11 +395,11 @@ bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold ) } } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -418,13 +418,13 @@ bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold ) bool Bitmap::ImplMakeMonoDither() { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); bool bRet = false; if( pReadAcc ) { Bitmap aNewBmp( GetSizePixel(), 1 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -470,11 +470,11 @@ bool Bitmap::ImplMakeMonoDither() } } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -495,7 +495,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) { SAL_WARN_IF( nGreys != 16 && nGreys != 256, "vcl", "Only 16 or 256 greyscales are supported!" ); - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); bool bRet = false; if( pReadAcc ) @@ -510,7 +510,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) if( bPalDiffers ) { Bitmap aNewBmp( GetSizePixel(), ( nGreys == 16 ) ? 4 : 8, &rPal ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -576,11 +576,11 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) pWriteAcc->SetPixelIndex( nY, nX, (pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >> nShift ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -595,7 +595,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) } else { - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); bRet = true; } } @@ -810,7 +810,7 @@ bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color* pExtColor) bool Bitmap::ImplConvertGhosted() { Bitmap aNewBmp; - BitmapReadAccess* pR = AcquireReadAccess(); + ScopedReadAccess pR(*this); bool bRet = false; if( pR ) @@ -828,12 +828,11 @@ bool Bitmap::ImplConvertGhosted() } aNewBmp = Bitmap( GetSizePixel(), GetBitCount(), &aNewPal ); - BitmapWriteAccess* pW = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pW(aNewBmp); if( pW ) { pW->CopyBuffer( *pR ); - ReleaseAccess( pW ); bRet = true; } } @@ -841,7 +840,7 @@ bool Bitmap::ImplConvertGhosted() { aNewBmp = Bitmap( GetSizePixel(), 24 ); - BitmapWriteAccess* pW = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pW(aNewBmp); if( pW ) { @@ -859,12 +858,11 @@ bool Bitmap::ImplConvertGhosted() } } - ReleaseAccess( pW ); bRet = true; } } - ReleaseAccess( pR ); + pR.reset(); } if( bRet ) @@ -1082,12 +1080,12 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) if( nNewWidth && nNewHeight ) { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); if(pReadAcc) { Bitmap aNewBmp( Size( nNewWidth, nNewHeight ), GetBitCount(), &pReadAcc->GetPalette() ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -1128,9 +1126,9 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) bRet = true; } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) ImplAssignWithSize( aNewBmp ); @@ -1149,13 +1147,13 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY if( ( nNewWidth > 1 ) && ( nNewHeight > 1 ) ) { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); if( pReadAcc ) { long nWidth = pReadAcc->Width(); long nHeight = pReadAcc->Height(); Bitmap aNewBmp( Size( nNewWidth, nHeight ), 24 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -1232,8 +1230,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1241,8 +1239,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY const Bitmap aOriginal(*this); *this = aNewBmp; aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 ); - pReadAcc = AcquireReadAccess(); - pWriteAcc = aNewBmp.AcquireWriteAccess(); + pReadAcc = ScopedReadAccess(*this); + pWriteAcc = ScopedWriteAccess(aNewBmp); if( pReadAcc && pWriteAcc ) { @@ -1305,8 +1303,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1345,9 +1343,9 @@ bool Bitmap::Dither( BmpDitherFlags nDitherFlags ) bool Bitmap::ImplDitherMatrix() { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); Bitmap aNewBmp( GetSizePixel(), 8 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); bool bRet = false; if( pReadAcc && pWriteAcc ) @@ -1394,8 +1392,8 @@ bool Bitmap::ImplDitherMatrix() bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1418,9 +1416,9 @@ bool Bitmap::ImplDitherFloyd() if( ( aSize.Width() > 3 ) && ( aSize.Height() > 2 ) ) { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); Bitmap aNewBmp( GetSizePixel(), 8 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pReadAcc && pWriteAcc ) { @@ -1529,8 +1527,8 @@ bool Bitmap::ImplDitherFloyd() bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1549,9 +1547,9 @@ bool Bitmap::ImplDitherFloyd() bool Bitmap::ImplDitherFloyd16() { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); Bitmap aNewBmp( GetSizePixel(), 24 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); bool bRet = false; if( pReadAcc && pWriteAcc ) @@ -1620,8 +1618,8 @@ bool Bitmap::ImplDitherFloyd16() bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1661,7 +1659,7 @@ bool Bitmap::ReduceColors( sal_uInt16 nColorCount, BmpReduce eReduce ) bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount ) { Bitmap aNewBmp; - BitmapReadAccess* pRAcc = AcquireReadAccess(); + ScopedReadAccess pRAcc(*this); const sal_uInt16 nColCount = std::min( nColorCount, (sal_uInt16) 256 ); sal_uInt16 nBitCount; bool bRet = false; @@ -1677,10 +1675,9 @@ bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount ) { Octree aOct( *pRAcc, nColCount ); const BitmapPalette& rPal = aOct.GetPalette(); - BitmapWriteAccess* pWAcc; aNewBmp = Bitmap( GetSizePixel(), nBitCount, &rPal ); - pWAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWAcc(aNewBmp); if( pWAcc ) { @@ -1700,11 +1697,11 @@ bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount ) pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>(aOct.GetBestPaletteIndex( pRAcc->GetPixel( nY, nX ) )) ); } - ReleaseAccess( pWAcc ); + pWAcc.reset(); bRet = true; } - ReleaseAccess( pRAcc ); + pRAcc.reset(); } if( bRet ) @@ -1742,7 +1739,7 @@ extern "C" int SAL_CALL ImplPopularCmpFnc( const void* p1, const void* p2 ) bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) { - BitmapReadAccess* pRAcc = AcquireReadAccess(); + ScopedReadAccess pRAcc(*this); sal_uInt16 nBitCount; bool bRet = false; @@ -1821,7 +1818,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) } Bitmap aNewBmp( GetSizePixel(), nBitCount, &aNewPal ); - BitmapWriteAccess* pWAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWAcc(aNewBmp); if( pWAcc ) { @@ -1862,12 +1859,12 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) } } - ReleaseAccess( pWAcc ); + pWAcc.reset(); bRet = true; } pCountTable.reset(); - ReleaseAccess( pRAcc ); + pRAcc.reset(); if( bRet ) { @@ -1885,7 +1882,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount ) { - BitmapReadAccess* pRAcc = AcquireReadAccess(); + ScopedReadAccess pRAcc(*this); sal_uInt16 nBitCount; bool bRet = false; @@ -1903,7 +1900,7 @@ bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount ) if( pRAcc ) { Bitmap aNewBmp( GetSizePixel(), nBitCount ); - BitmapWriteAccess* pWAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWAcc(aNewBmp); if( pWAcc ) { @@ -1952,11 +1949,11 @@ bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount ) pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>( aMap.GetBestPaletteIndex( pRAcc->GetColor( nY, nX ) )) ); rtl_freeMemory( pColBuf ); - ReleaseAccess( pWAcc ); + pWAcc.reset(); bRet = true; } - ReleaseAccess( pRAcc ); + pRAcc.reset(); if( bRet ) { @@ -2131,7 +2128,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, } else { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -2254,7 +2251,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } @@ -2267,7 +2264,7 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess* pReadAcc, if (!pReadAcc) return false; - BitmapWriteAccess* pWriteAcc = aNewBitmap.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBitmap); if (!pWriteAcc) return false; @@ -2311,7 +2308,6 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess* pReadAcc, pWriteAcc->SetPixel(nDestY, nDestX, aResultColor); } } - ReleaseAccess( pWriteAcc ); return true; } diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index 256832883a0a..63940bd73f7f 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -113,13 +113,13 @@ bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) bool Bitmap::ImplConvolute3( const long* pMatrix ) { const long nDivisor = 8; - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); bool bRet = false; if( pReadAcc ) { Bitmap aNewBmp( GetSizePixel(), 24 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -246,12 +246,12 @@ bool Bitmap::ImplConvolute3( const long* pMatrix ) delete[] pColm; delete[] pRows; - Bitmap::ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -270,13 +270,13 @@ bool Bitmap::ImplConvolute3( const long* pMatrix ) bool Bitmap::ImplMedianFilter() { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); bool bRet = false; if( pReadAcc ) { Bitmap aNewBmp( GetSizePixel(), 24 ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -405,12 +405,12 @@ bool Bitmap::ImplMedianFilter() delete[] pColm; delete[] pRows; - Bitmap::ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -435,12 +435,12 @@ bool Bitmap::ImplSobelGrey() { bRet = false; - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); if( pReadAcc ) { Bitmap aNewBmp( GetSizePixel(), 8, &pReadAcc->GetPalette() ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -531,11 +531,11 @@ bool Bitmap::ImplSobelGrey() delete[] pHMap; delete[] pVMap; - Bitmap::ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -561,12 +561,12 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) { bRet = false; - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); if( pReadAcc ) { Bitmap aNewBmp( GetSizePixel(), 8, &pReadAcc->GetPalette() ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -643,11 +643,11 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) delete[] pHMap; delete[] pVMap; - Bitmap::ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -668,7 +668,7 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) bool Bitmap::ImplSolarize( const BmpFilterParam* pFilterParam ) { bool bRet = false; - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -706,7 +706,7 @@ bool Bitmap::ImplSolarize( const BmpFilterParam* pFilterParam ) } } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } @@ -715,7 +715,7 @@ bool Bitmap::ImplSolarize( const BmpFilterParam* pFilterParam ) bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) { - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); bool bRet = false; if( pReadAcc ) @@ -736,7 +736,7 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) } Bitmap aNewBmp( GetSizePixel(), 8, &aSepiaPal ); - BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBmp); if( pWriteAcc ) { @@ -775,11 +775,11 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) } } - Bitmap::ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) { @@ -961,6 +961,7 @@ bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam ) return bRet; } + struct PopArtEntry { sal_uInt32 mnIndex; @@ -990,7 +991,7 @@ bool Bitmap::ImplPopArt() { bRet = false; - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -1034,7 +1035,7 @@ bool Bitmap::ImplPopArt() // cleanup delete[] pPopArtTable; - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } } @@ -1135,15 +1136,15 @@ bool Bitmap::ImplSeparableBlurFilter(const double radius) // Do horizontal filtering ImplBlurContributions( nWidth, aNumberOfContributions, pBlurVector, pWeights, pPixels, pCount); - BitmapReadAccess* pReadAcc = AcquireReadAccess(); + ScopedReadAccess pReadAcc(*this); // switch coordinates as convolution pass transposes result Bitmap aNewBitmap( Size( nHeight, nWidth ), 24 ); - bool bResult = ImplConvolutionPass( aNewBitmap, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount ); + bool bResult = ImplConvolutionPass( aNewBitmap, pReadAcc.get(), aNumberOfContributions, pWeights, pPixels, pCount ); // Cleanup - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); delete[] pWeights; delete[] pPixels; delete[] pCount; @@ -1160,12 +1161,12 @@ bool Bitmap::ImplSeparableBlurFilter(const double radius) // Do vertical filtering ImplBlurContributions(nHeight, aNumberOfContributions, pBlurVector, pWeights, pPixels, pCount ); - pReadAcc = AcquireReadAccess(); + pReadAcc = ScopedReadAccess(*this); aNewBitmap = Bitmap( Size( nWidth, nHeight ), 24 ); - bResult = ImplConvolutionPass( aNewBitmap, pReadAcc, aNumberOfContributions, pWeights, pPixels, pCount ); + bResult = ImplConvolutionPass( aNewBitmap, pReadAcc.get(), aNumberOfContributions, pWeights, pPixels, pCount ); // Cleanup - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); delete[] pWeights; delete[] pCount; delete[] pPixels; @@ -1194,9 +1195,9 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) { Bitmap aResultBitmap( Size( nWidth, nHeight ), 24); - BitmapReadAccess* pReadAccBlur = aBlur.AcquireReadAccess(); - BitmapReadAccess* pReadAcc = AcquireReadAccess(); - BitmapWriteAccess* pWriteAcc = aResultBitmap.AcquireWriteAccess(); + ScopedReadAccess pReadAccBlur(aBlur); + ScopedReadAccess pReadAcc(*this); + ScopedWriteAccess pWriteAcc(aResultBitmap); BitmapColor aColor, aColorBlur; @@ -1217,9 +1218,9 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) { } } - ReleaseAccess( pWriteAcc ); - ReleaseAccess( pReadAcc ); - ReleaseAccess( pReadAccBlur ); + pWriteAcc.reset(); + pReadAcc.reset(); + pReadAccBlur.reset(); ImplAssignWithSize ( aResultBitmap ); return true; } @@ -1230,8 +1231,8 @@ bool Bitmap::ImplDuotoneFilter( const sal_uLong nColorOne, const sal_uLong nColo const long nHeight = GetSizePixel().Height(); Bitmap aResultBitmap( GetSizePixel(), 24); - BitmapReadAccess* pReadAcc = AcquireReadAccess(); - BitmapWriteAccess* pWriteAcc = aResultBitmap.AcquireWriteAccess(); + ScopedReadAccess pReadAcc(*this); + ScopedWriteAccess pWriteAcc(aResultBitmap); const BitmapColor aColorOne( static_cast< sal_uInt8 >( nColorOne >> 16 ), static_cast< sal_uInt8 >( nColorOne >> 8 ), static_cast< sal_uInt8 >( nColorOne ) ); const BitmapColor aColorTwo( static_cast< sal_uInt8 >( nColorTwo >> 16 ), static_cast< sal_uInt8 >( nColorTwo >> 8 ), static_cast< sal_uInt8 >( nColorTwo ) ); @@ -1249,8 +1250,8 @@ bool Bitmap::ImplDuotoneFilter( const sal_uLong nColorOne, const sal_uLong nColo } } - ReleaseAccess( pWriteAcc ); - ReleaseAccess( pReadAcc ); + pWriteAcc.reset(); + pReadAcc.reset(); ImplAssignWithSize ( aResultBitmap ); return true; } diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 7bde2ffc5f84..1a67c6952d10 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -728,7 +728,7 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const case TransparentType::Color: { Bitmap aTestBitmap(aBitmap); - BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess(); + Bitmap::ScopedReadAccess pRead(aTestBitmap); if(pRead) { @@ -740,7 +740,6 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const nTransparency = 0x00; } - Bitmap::ReleaseAccess(pRead); } break; } @@ -749,7 +748,7 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const if(!aMask.IsEmpty()) { Bitmap aTestBitmap(aMask); - BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess(); + Bitmap::ScopedReadAccess pRead(aTestBitmap); if(pRead) { @@ -766,8 +765,6 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const nTransparency = 0x00; } } - - Bitmap::ReleaseAccess(pRead); } } break; @@ -832,11 +829,11 @@ namespace bool bSmooth) { Bitmap aDestination(rDestinationSize, 24); - std::unique_ptr<BitmapWriteAccess> xWrite(aDestination.AcquireWriteAccess()); + Bitmap::ScopedWriteAccess xWrite(aDestination); if(xWrite) { - std::unique_ptr<BitmapReadAccess> xRead((const_cast< Bitmap& >(rSource)).AcquireReadAccess()); + Bitmap::ScopedReadAccess xRead(const_cast< Bitmap& >(rSource)); if (xRead) { @@ -1016,7 +1013,7 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod // do NOT use erase; for e.g. 8bit Bitmaps, the nearest color to the given // erase color is determined and used -> this may be different from what is // wanted here. Better create a new bitmap with the needed color explicitely - std::unique_ptr<BitmapReadAccess> xReadAccess(aChangedBitmap.AcquireReadAccess()); + Bitmap::ScopedReadAccess xReadAccess(aChangedBitmap); OSL_ENSURE(xReadAccess, "Got no Bitmap ReadAccess ?!?"); if(xReadAccess) @@ -1044,7 +1041,7 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else { - std::unique_ptr<BitmapWriteAccess> xContent(aChangedBitmap.AcquireWriteAccess()); + Bitmap::ScopedWriteAccess xContent(aChangedBitmap); if(xContent) { @@ -1211,8 +1208,8 @@ BitmapEx createBlendFrame( aContent.Erase(COL_BLACK); - BitmapWriteAccess* pContent = aContent.AcquireWriteAccess(); - BitmapWriteAccess* pAlpha = aAlpha.AcquireWriteAccess(); + Bitmap::ScopedWriteAccess pContent(aContent); + AlphaMask::ScopedWriteAccess pAlpha(aAlpha); if(pContent && pAlpha) { @@ -1287,23 +1284,11 @@ BitmapEx createBlendFrame( } } - Bitmap::ReleaseAccess(pContent); - Bitmap::ReleaseAccess(pAlpha); + pContent.reset(); + pAlpha.reset(); pBlendFrameCache->m_aLastResult = BitmapEx(aContent, aAlpha); } - else - { - if(pContent) - { - Bitmap::ReleaseAccess(pContent); - } - - if(pAlpha) - { - Bitmap::ReleaseAccess(pAlpha); - } - } } return pBlendFrameCache->m_aLastResult; diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index ebe9d895e20f..2561b25dcefe 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -887,16 +887,15 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u const Size aSizePixel(aHeader.nWidth, aHeader.nHeight); BitmapPalette aDummyPal; Bitmap aNewBmp(aSizePixel, nBitCount, &aDummyPal); - BitmapWriteAccess* pAcc = aNewBmp.AcquireWriteAccess(); + Bitmap::ScopedWriteAccess pAcc(aNewBmp); if (!pAcc) return false; if (pAcc->Width() != aHeader.nWidth || pAcc->Height() != aHeader.nHeight) { - Bitmap::ReleaseAccess(pAcc); return false; } AlphaMask aNewBmpAlpha; - BitmapWriteAccess* pAccAlpha = nullptr; + AlphaMask::ScopedWriteAccess pAccAlpha; bool bAlphaPossible(pBmpAlpha && aHeader.nBitCount == 32); if (bAlphaPossible) @@ -918,7 +917,7 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u if (bAlphaPossible) { aNewBmpAlpha = AlphaMask(aSizePixel); - pAccAlpha = aNewBmpAlpha.AcquireWriteAccess(); + pAccAlpha = AlphaMask::ScopedWriteAccess(aNewBmpAlpha); } // read palette @@ -938,7 +937,7 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u pIStm->SeekRel(nOffset - (pIStm->Tell() - nStmPos)); } - bRet = ImplReadDIBBits(*pIStm, aHeader, *pAcc, pAccAlpha, bTopDown, bAlphaUsed, nAlignedWidth); + bRet = ImplReadDIBBits(*pIStm, aHeader, *pAcc, pAccAlpha.get(), bTopDown, bAlphaUsed, nAlignedWidth); if(bRet && aHeader.nXPelsPerMeter && aHeader.nYPelsPerMeter) { @@ -953,11 +952,11 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u } } - Bitmap::ReleaseAccess(pAcc); + pAcc.reset(); if(bAlphaPossible) { - Bitmap::ReleaseAccess(pAccAlpha); + pAccAlpha.reset(); if(!bAlphaUsed) { @@ -1606,8 +1605,8 @@ bool ImplWriteDIB( if(aSizePix.Width() && aSizePix.Height()) { - BitmapReadAccess* pAcc = const_cast< Bitmap& >(rSource).AcquireReadAccess(); - BitmapReadAccess* pAccAlpha = nullptr; + Bitmap::ScopedReadAccess pAcc(const_cast< Bitmap& >(rSource)); + Bitmap::ScopedReadAccess pAccAlpha; const SvStreamEndian nOldFormat(rOStm.GetEndian()); const sal_uLong nOldPos(rOStm.Tell()); @@ -1617,7 +1616,7 @@ bool ImplWriteDIB( if(aSizePixAlpha == aSizePix) { - pAccAlpha = const_cast< Bitmap* >(pSourceAlpha)->AcquireReadAccess(); + pAccAlpha = Bitmap::ScopedReadAccess(const_cast< Bitmap& >(*pSourceAlpha)); } else { @@ -1633,21 +1632,18 @@ bool ImplWriteDIB( { if(ImplWriteDIBFileHeader(rOStm, *pAcc, nullptr != pSourceAlpha)) { - bRet = ImplWriteDIBBody(rSource, rOStm, *pAcc, pAccAlpha, bCompressed); + bRet = ImplWriteDIBBody(rSource, rOStm, *pAcc, pAccAlpha.get(), bCompressed); } } else { - bRet = ImplWriteDIBBody(rSource, rOStm, *pAcc, pAccAlpha, bCompressed); + bRet = ImplWriteDIBBody(rSource, rOStm, *pAcc, pAccAlpha.get(), bCompressed); } - Bitmap::ReleaseAccess(pAcc); + pAcc.reset(); } - if (pAccAlpha) - { - Bitmap::ReleaseAccess(pAccAlpha); - } + pAccAlpha.reset(); if(!bRet) { diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index d3b97e9ec35a..50fdf6f76830 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -639,7 +639,7 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, VECT_PROGRESS( pProgress, 0 ); std::unique_ptr<Bitmap> xBmp(new Bitmap( rColorBmp )); - BitmapReadAccess* pRAcc = xBmp->AcquireReadAccess(); + Bitmap::ScopedReadAccess pRAcc(*xBmp); if( pRAcc ) { @@ -681,7 +681,7 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, { const BitmapColor aBmpCol( pRAcc->GetPaletteColor( pColorSet[ i ].mnIndex ) ); const Color aFindColor( aBmpCol.GetRed(), aBmpCol.GetGreen(), aBmpCol.GetBlue() ); - std::unique_ptr<ImplVectMap> xMap(ImplExpand( pRAcc, aFindColor )); + std::unique_ptr<ImplVectMap> xMap(ImplExpand( pRAcc.get(), aFindColor )); VECT_PROGRESS( pProgress, FRound( fPercent += fPercentStep_2 ) ); @@ -725,7 +725,7 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, } } - Bitmap::ReleaseAccess( pRAcc ); + pRAcc.reset(); xBmp.reset(); VECT_PROGRESS( pProgress, 100 ); @@ -736,15 +736,14 @@ bool ImplVectorize( const Bitmap& rMonoBmp, tools::PolyPolygon& rPolyPoly ) { std::unique_ptr<Bitmap> xBmp(new Bitmap( rMonoBmp )); - BitmapReadAccess* pRAcc; bool bRet = false; if( xBmp->GetBitCount() > 1 ) xBmp->Convert( BMP_CONVERSION_1BIT_THRESHOLD ); - pRAcc = xBmp->AcquireReadAccess(); - std::unique_ptr <ImplVectMap> xMap(ImplExpand( pRAcc, COL_BLACK )); - Bitmap::ReleaseAccess( pRAcc ); + Bitmap::ScopedReadAccess pRAcc(*xBmp); + std::unique_ptr <ImplVectMap> xMap(ImplExpand( pRAcc.get(), COL_BLACK )); + pRAcc.reset(); xBmp.reset(); if( xMap ) diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index dbd07513906f..53fab0f9f15f 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -215,7 +215,7 @@ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf, if( !aBmpEx.IsAlpha() ) { // blend with mask - BitmapReadAccess* pRA = aBmp.AcquireReadAccess(); + Bitmap::ScopedReadAccess pRA(aBmp); if( !pRA ) return; // what else should I do? @@ -225,7 +225,7 @@ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf, if( pRA->HasPalette() ) aActualColor = pRA->GetBestPaletteColor( aBgColor ).operator Color(); - Bitmap::ReleaseAccess(pRA); + pRA.reset(); // did we get true white? if( aActualColor.GetColorError( aBgColor ) ) |