diff options
author | Mark Page <aptitude@btconnect.com> | 2016-12-05 09:59:25 +0000 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-05 07:45:25 -0500 |
commit | 3a6a28492882a93676060880faf72d87c7f6fcbc (patch) | |
tree | 4ed370b89a72b79a94534d6e88381e3bddc5b82f /vcl | |
parent | f16b388f6eeb2910422be7fd70c0b655a144ce59 (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>
(cherry picked from commit 7006568138b5b2d2c11dd558049cd4085c449c9e)
(cherry picked from commit b8ddfc7a4980f02907b8b7acbe8596e7f522c905)
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 6bc8b7dfa551..c265da3be3da 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -1549,8 +1549,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) { @@ -1571,8 +1571,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 b5641b82857d..a7ac32d52e94 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; @@ -467,7 +466,7 @@ bool Bitmap::Erase(const Color& rFillColor) bool Bitmap::Invert() { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); bool bRet = false; if( pAcc ) @@ -493,7 +492,7 @@ bool Bitmap::Invert() } mxImpBmp->ImplInvalidateChecksum(); - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } @@ -508,7 +507,7 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) if( bHorz && !bVert ) { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -528,13 +527,13 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } else if( bVert && !bHorz ) { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -551,13 +550,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 ) { @@ -588,7 +587,7 @@ bool Bitmap::Mirror( BmpMirrorFlags nMirrorFlags ) } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } @@ -611,7 +610,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 ) @@ -622,7 +621,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 ) { @@ -646,7 +645,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) pWriteAcc->SetPixel( nY, nX, pReadAcc->GetPixel( nOtherY--, nOtherX ) ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } aRotatedBmp = aNewBmp; @@ -661,7 +660,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 ) { @@ -716,13 +715,13 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) } } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } aRotatedBmp = aNewBmp; } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); } if( ( bRet = !!aRotatedBmp ) ) @@ -742,14 +741,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 ) { @@ -762,11 +761,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 ); @@ -814,8 +813,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 ) { @@ -841,12 +840,6 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, pDstAcc->SetPaletteColor( (sal_uInt16) nNextIndex++, rSrcCol ); } } - - if( pSrcAcc ) - ReleaseAccess( pSrcAcc ); - - if( pDstAcc ) - ReleaseAccess( pDstAcc ); } } @@ -854,11 +847,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 ) { @@ -893,11 +886,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(); } } } @@ -909,7 +902,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, if( !aRectSrc.IsEmpty() && ( aRectSrc != aRectDst ) ) { - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -949,7 +942,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } } @@ -982,11 +975,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 ) { @@ -1000,11 +993,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(); } } } @@ -1016,7 +1009,7 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl if( !aRectSrc.IsEmpty() && ( aRectSrc != aRectDst ) ) { - BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(*this); if( pWriteAcc ) { @@ -1056,7 +1049,7 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) ); } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); bRet = true; } } @@ -1077,13 +1070,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 ) { @@ -1112,11 +1105,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 ); @@ -1129,12 +1122,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 ) { @@ -1298,11 +1291,11 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const } } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); bRet = true; } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } if( bRet ) @@ -1318,9 +1311,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(); @@ -1413,7 +1406,7 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) //aRegion.ImplEndAddRect(); //aRegion.SetRegionRectangles(aRectangles); - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); } else aRegion = aRect; @@ -1423,8 +1416,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 ) @@ -1487,18 +1480,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 ) @@ -1519,9 +1509,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 ) { @@ -1557,7 +1547,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 ) @@ -1604,7 +1594,7 @@ bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } @@ -1619,7 +1609,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 ) @@ -1703,7 +1693,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, if( !_pTols ) delete[] pTols; - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } @@ -1728,8 +1718,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 ) @@ -1857,9 +1847,6 @@ bool Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) bRet = true; } - ReleaseAccess( pMaskAcc ); - ReleaseAccess( pAcc ); - return bRet; } @@ -1872,8 +1859,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 ) @@ -1890,9 +1878,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 e4f7acd8bb6e..d602f6321dd4 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; } } @@ -809,7 +809,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 ) @@ -827,12 +827,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; } } @@ -840,7 +839,7 @@ bool Bitmap::ImplConvertGhosted() { aNewBmp = Bitmap( GetSizePixel(), 24 ); - BitmapWriteAccess* pW = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pW(aNewBmp); if( pW ) { @@ -858,12 +857,11 @@ bool Bitmap::ImplConvertGhosted() } } - ReleaseAccess( pW ); bRet = true; } } - ReleaseAccess( pR ); + pR.reset(); } if( bRet ) @@ -1081,12 +1079,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 ) { @@ -1127,9 +1125,9 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) bRet = true; } - ReleaseAccess( pWriteAcc ); + pWriteAcc.reset(); } - ReleaseAccess( pReadAcc ); + pReadAcc.reset(); if( bRet ) ImplAssignWithSize( aNewBmp ); @@ -1148,13 +1146,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 ) { @@ -1231,8 +1229,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1240,8 +1238,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 ) { @@ -1304,8 +1302,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1344,9 +1342,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 ) @@ -1393,8 +1391,8 @@ bool Bitmap::ImplDitherMatrix() bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1417,9 +1415,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 ) { @@ -1528,8 +1526,8 @@ bool Bitmap::ImplDitherFloyd() bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1548,9 +1546,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 ) @@ -1618,8 +1616,8 @@ bool Bitmap::ImplDitherFloyd16() bRet = true; } - ReleaseAccess( pReadAcc ); - ReleaseAccess( pWriteAcc ); + pReadAcc.reset(); + pWriteAcc.reset(); if( bRet ) { @@ -1659,7 +1657,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; @@ -1675,10 +1673,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 ) { @@ -1698,11 +1695,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 ) @@ -1740,7 +1737,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; @@ -1819,7 +1816,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) } Bitmap aNewBmp( GetSizePixel(), nBitCount, &aNewPal ); - BitmapWriteAccess* pWAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWAcc(aNewBmp); if( pWAcc ) { @@ -1860,12 +1857,12 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) } } - ReleaseAccess( pWAcc ); + pWAcc.reset(); bRet = true; } pCountTable.reset(); - ReleaseAccess( pRAcc ); + pRAcc.reset(); if( bRet ) { @@ -1883,7 +1880,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; @@ -1901,7 +1898,7 @@ bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount ) if( pRAcc ) { Bitmap aNewBmp( GetSizePixel(), nBitCount ); - BitmapWriteAccess* pWAcc = aNewBmp.AcquireWriteAccess(); + ScopedWriteAccess pWAcc(aNewBmp); if( pWAcc ) { @@ -1950,11 +1947,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 ) { @@ -2129,7 +2126,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, } else { - BitmapWriteAccess* pAcc = AcquireWriteAccess(); + ScopedWriteAccess pAcc(*this); if( pAcc ) { @@ -2252,7 +2249,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, } } - ReleaseAccess( pAcc ); + pAcc.reset(); bRet = true; } } @@ -2265,7 +2262,7 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess* pReadAcc, if (!pReadAcc) return false; - BitmapWriteAccess* pWriteAcc = aNewBitmap.AcquireWriteAccess(); + ScopedWriteAccess pWriteAcc(aNewBitmap); if (!pWriteAcc) return false; @@ -2309,7 +2306,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 808886f9fbb8..e33d0bd0e757 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 7047fcf5209b..dd7a15c07fb6 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -892,16 +892,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) @@ -923,7 +922,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 @@ -943,7 +942,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) { @@ -958,11 +957,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) { @@ -1611,8 +1610,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()); @@ -1622,7 +1621,7 @@ bool ImplWriteDIB( if(aSizePixAlpha == aSizePix) { - pAccAlpha = const_cast< Bitmap* >(pSourceAlpha)->AcquireReadAccess(); + pAccAlpha = Bitmap::ScopedReadAccess(const_cast< Bitmap& >(*pSourceAlpha)); } else { @@ -1638,21 +1637,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 ) ) |