summaryrefslogtreecommitdiff
path: root/canvas
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 /canvas
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 'canvas')
-rw-r--r--canvas/qa/cppunit/canvastest.cxx4
-rw-r--r--canvas/source/directx/dx_vcltools.cxx8
-rw-r--r--canvas/source/vcl/canvashelper.cxx2
3 files changed, 6 insertions, 8 deletions
diff --git a/canvas/qa/cppunit/canvastest.cxx b/canvas/qa/cppunit/canvastest.cxx
index d4cba860db43..922888b4894a 100644
--- a/canvas/qa/cppunit/canvastest.cxx
+++ b/canvas/qa/cppunit/canvastest.cxx
@@ -95,7 +95,7 @@ public:
mRenderState);
exportDevice("test-draw-line.png", mVclDevice);
Bitmap bitmap = mVclDevice->GetBitmap(Point(), mVclDevice->GetOutputSizePixel());
- Bitmap::ScopedReadAccess access(bitmap);
+ BitmapScopedReadAccess access(bitmap);
// Canvas uses AA, which blurs the line, and it cannot be turned off,
// so do not check the end points.
CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), access->GetPixel(0, 0));
@@ -130,7 +130,7 @@ public:
exportDevice("test-tdf134053.png", mVclDevice);
Bitmap bitmap = mVclDevice->GetBitmap(Point(), mVclDevice->GetOutputSizePixel());
- Bitmap::ScopedReadAccess access(bitmap);
+ BitmapScopedReadAccess access(bitmap);
struct Check
{
tools::Long start;
diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx
index fb5e5c5e93db..31b05be58e9c 100644
--- a/canvas/source/directx/dx_vcltools.cxx
+++ b/canvas/source/directx/dx_vcltools.cxx
@@ -100,7 +100,7 @@ namespace dxcanvas::tools
{
// first of all, ensure that Bitmap contains a DIB, by
// acquiring a read access
- BitmapReadAccess* pReadAcc = rBmp.AcquireReadAccess();
+ BitmapScopedReadAccess pReadAcc(rBmp);
// TODO(P2): Acquiring a read access can actually
// force a read from VRAM, thus, avoiding this
@@ -116,8 +116,6 @@ namespace dxcanvas::tools
return drawDIBits( rGraphics,
aBmpSysData.pDIB );
}
-
- Bitmap::ReleaseAccess( pReadAcc );
}
}
else
@@ -156,7 +154,7 @@ namespace dxcanvas::tools
Bitmap aBitmap( rBmpEx.GetBitmap() );
- Bitmap::ScopedReadAccess pReadAccess( aBitmap );
+ BitmapScopedReadAccess pReadAccess( aBitmap );
const sal_Int32 nWidth( aBmpSize.Width() );
const sal_Int32 nHeight( aBmpSize.Height() );
@@ -167,7 +165,7 @@ namespace dxcanvas::tools
Bitmap aAlpha( rBmpEx.GetAlphaMask().GetBitmap() );
- Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha );
+ BitmapScopedReadAccess pAlphaReadAccess( aAlpha );
// By convention, the access buffer always has
// one of the following formats:
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 0e4dfdbf633f..1e47b02c84fc 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -971,7 +971,7 @@ namespace vclcanvas
Bitmap aBitmap( rOutDev.GetBitmapEx(aRect.TopLeft(),
aRect.GetSize()).GetBitmap() );
- Bitmap::ScopedReadAccess pReadAccess( aBitmap );
+ BitmapScopedReadAccess pReadAccess( aBitmap );
ENSURE_OR_THROW( pReadAccess.get() != nullptr,
"Could not acquire read access to OutDev bitmap" );