summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit/canvasbitmaptest.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-12-04 11:17:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-12-07 09:32:14 +0100
commita214ac677481883d31800bc2b67fd3a9c504319d (patch)
tree97598a97a7b0745acaf4dc4e7587871794011227 /vcl/qa/cppunit/canvasbitmaptest.cxx
parent7101c620857cb885076b85cd1447e50d30cab528 (diff)
simplify and modernise ScopedBitmapAccess
(*) Make all of it use a "Scoped" paradigm (*) pass by value, no need to allocate on heap (*) make all of the construction go via the *Access constructors, instead of it being some via the constructors and some via the Acquire*Access methods. (*) take the Bitmap& by const& in the constructor, so we can avoid doing const_cast in random places. Change-Id: Ie03a9145c0965980ee8df9a89b8714a425e18f74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160293 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/qa/cppunit/canvasbitmaptest.cxx')
-rw-r--r--vcl/qa/cppunit/canvasbitmaptest.cxx20
1 files changed, 7 insertions, 13 deletions
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index d2a62ad8bfce..91db2e4f73f3 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -36,7 +36,7 @@
#include <vcl/bitmapex.hxx>
#include <canvasbitmap.hxx>
-#include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/BitmapWriteAccess.hxx>
#include <algorithm>
@@ -87,7 +87,7 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
int extraBpp = 0;
{
- Bitmap::ScopedReadAccess pAcc( aContainedBmp );
+ BitmapScopedReadAccess pAcc( aContainedBmp );
nDepth = pAcc->GetBitCount();
if( pAcc->GetScanlineFormat() == ScanlineFormat::N32BitTcMask )
extraBpp = 8; // the format has 8 unused bits
@@ -675,7 +675,7 @@ void CanvasBitmapTest::runTest()
AlphaMask aMask(Size(200,200));
aMask.Erase(255);
{
- AlphaMask::ScopedWriteAccess pAcc(aMask);
+ BitmapScopedWriteAccess pAcc(aMask);
if( pAcc.get() )
{
pAcc->SetFillColor(COL_ALPHA_OPAQUE);
@@ -693,7 +693,7 @@ void CanvasBitmapTest::runTest()
AlphaMask aAlpha(Size(200,200));
aAlpha.Erase(0);
{
- BitmapWriteAccess* pAcc = aAlpha.AcquireAlphaWriteAccess();
+ BitmapScopedWriteAccess pAcc(aAlpha);
if( pAcc )
{
pAcc->SetFillColor(COL_ALPHA_OPAQUE);
@@ -701,7 +701,6 @@ void CanvasBitmapTest::runTest()
pAcc->SetPixel(0,0,BitmapColor(0));
pAcc->SetPixel(0,1,BitmapColor(255));
pAcc->SetPixel(0,2,BitmapColor(0));
- Bitmap::ReleaseAccess(pAcc);
}
}
@@ -724,7 +723,7 @@ void CanvasBitmapTest::runTest()
vcl::PixelFormat::N8_BPP, aBmp.getPixelFormat());
{
Bitmap aBitmap = aBmp.GetBitmap();
- BitmapReadAccess* pBmpAcc = aBitmap.AcquireReadAccess();
+ BitmapScopedReadAccess pBmpAcc(aBitmap);
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
pBmpAcc );
@@ -735,8 +734,6 @@ void CanvasBitmapTest::runTest()
BitmapColor(2), pBmpAcc->GetPixel(2,2));
CPPUNIT_ASSERT_EQUAL_MESSAGE("(9,2) incorrect content",
BitmapColor(9), pBmpAcc->GetPixel(2,9));
-
- Bitmap::ReleaseAccess(pBmpAcc);
}
xTestBmp.set( new TestBitmap( geometry::IntegerSize2D(10,10), false ));
@@ -750,9 +747,9 @@ void CanvasBitmapTest::runTest()
vcl::PixelFormat::N24_BPP, aBmp.getPixelFormat());
{
Bitmap aBitmap = aBmp.GetBitmap();
- BitmapReadAccess* pBmpAcc = aBitmap.AcquireReadAccess();
+ BitmapScopedReadAccess pBmpAcc(aBitmap);
AlphaMask aBitmapAlpha = aBmp.GetAlphaMask();
- BitmapReadAccess* pAlphaAcc = aBitmapAlpha.AcquireReadAccess();
+ BitmapScopedReadAccess pAlphaAcc(aBitmapAlpha);
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
pBmpAcc);
@@ -771,9 +768,6 @@ void CanvasBitmapTest::runTest()
BitmapColor(0,3,9), pBmpAcc->GetPixel(2,9));
CPPUNIT_ASSERT_EQUAL_MESSAGE("(9,2) correct alpha content",
BitmapColor(2), pAlphaAcc->GetPixel(2,9));
-
- Bitmap::ReleaseAccess(pAlphaAcc);
- Bitmap::ReleaseAccess(pBmpAcc);
}
}