diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-12-04 11:17:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-12-07 09:32:14 +0100 |
commit | a214ac677481883d31800bc2b67fd3a9c504319d (patch) | |
tree | 97598a97a7b0745acaf4dc4e7587871794011227 /drawinglayer | |
parent | 7101c620857cb885076b85cd1447e50d30cab528 (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 'drawinglayer')
-rw-r--r-- | drawinglayer/inc/texture/texture3d.hxx | 5 | ||||
-rw-r--r-- | drawinglayer/qa/unit/vclmetafileprocessor2d.cxx | 2 | ||||
-rw-r--r-- | drawinglayer/qa/unit/vclpixelprocessor2d.cxx | 2 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/cairopixelprocessor2d.cxx | 6 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx | 8 | ||||
-rw-r--r-- | drawinglayer/source/texture/texture3d.cxx | 4 |
6 files changed, 14 insertions, 13 deletions
diff --git a/drawinglayer/inc/texture/texture3d.hxx b/drawinglayer/inc/texture/texture3d.hxx index 88d13ed03b7c..07f4b181b2ad 100644 --- a/drawinglayer/inc/texture/texture3d.hxx +++ b/drawinglayer/inc/texture/texture3d.hxx @@ -21,6 +21,7 @@ #include <texture/texture.hxx> #include <vcl/bitmapex.hxx> +#include <vcl/BitmapReadAccess.hxx> namespace drawinglayer::primitive3d { class HatchTexturePrimitive3D; @@ -53,9 +54,9 @@ namespace drawinglayer::texture protected: BitmapEx maBitmapEx; Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope - Bitmap::ScopedReadAccess mpReadBitmap; + BitmapScopedReadAccess mpReadBitmap; Bitmap maTransparence; - Bitmap::ScopedReadAccess mpReadTransparence; + BitmapScopedReadAccess mpReadTransparence; basegfx::B2DPoint maTopLeft; basegfx::B2DVector maSize; double mfMulX; diff --git a/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx b/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx index 478645cbf5b1..f34ef8a1bb6f 100644 --- a/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx +++ b/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx @@ -133,7 +133,7 @@ public: CPPUNIT_ASSERT(renderer->draw()); exportDevice("test-tdf136957", mVclDevice); Bitmap bitmap = mVclDevice->GetBitmap(Point(), Size(1920, 1080)); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); // There should be a dotted line, without the fix it wouldn't be there, so check // there's a sufficient amount of non-white pixels and that's the line. int nonWhiteCount = 0; diff --git a/drawinglayer/qa/unit/vclpixelprocessor2d.cxx b/drawinglayer/qa/unit/vclpixelprocessor2d.cxx index 4362d3e55f19..c132d0927408 100644 --- a/drawinglayer/qa/unit/vclpixelprocessor2d.cxx +++ b/drawinglayer/qa/unit/vclpixelprocessor2d.cxx @@ -117,7 +117,7 @@ public: exportDevice("test-tdf139000.png", device); Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); // The upper half should keep its red background color. CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_RED), access->GetColor(Point(0, 99))); // First line of the gradient should not be the start color, but something halfway. diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx index 53261229a0d7..89cb21ddcb74 100644 --- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx @@ -174,8 +174,8 @@ std::vector<sal_uInt8> createBitmapData(const BitmapEx& rBitmapEx) if (bAlpha) { Bitmap aSrcAlpha(rBitmapEx.GetAlphaMask().GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(const_cast<Bitmap&>(rBitmapEx.GetBitmap())); - Bitmap::ScopedReadAccess pAlphaReadAccess(aSrcAlpha.AcquireReadAccess(), aSrcAlpha); + BitmapScopedReadAccess pReadAccess(rBitmapEx.GetBitmap()); + BitmapScopedReadAccess pAlphaReadAccess(aSrcAlpha); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); @@ -198,7 +198,7 @@ std::vector<sal_uInt8> createBitmapData(const BitmapEx& rBitmapEx) } else { - Bitmap::ScopedReadAccess pReadAccess(const_cast<Bitmap&>(rBitmapEx.GetBitmap())); + BitmapScopedReadAccess pReadAccess(rBitmapEx.GetBitmap()); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); diff --git a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx index 7671e0c29a05..6bfc95878332 100644 --- a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx @@ -399,8 +399,8 @@ sal::systools::COMReference<ID2D1Bitmap> createB2DBitmap(const BitmapEx& rBitmap if (bAlpha) { Bitmap aSrcAlpha(rBitmapEx.GetAlphaMask().GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(const_cast<Bitmap&>(rBitmapEx.GetBitmap())); - Bitmap::ScopedReadAccess pAlphaReadAccess(aSrcAlpha.AcquireReadAccess(), aSrcAlpha); + BitmapScopedReadAccess pReadAccess(rBitmapEx.GetBitmap()); + BitmapScopedReadAccess pAlphaReadAccess(aSrcAlpha); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); @@ -421,7 +421,7 @@ sal::systools::COMReference<ID2D1Bitmap> createB2DBitmap(const BitmapEx& rBitmap } else { - Bitmap::ScopedReadAccess pReadAccess(const_cast<Bitmap&>(rBitmapEx.GetBitmap())); + BitmapScopedReadAccess pReadAccess(const_cast<Bitmap&>(rBitmapEx.GetBitmap())); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); @@ -1076,7 +1076,7 @@ sal::systools::COMReference<ID2D1Bitmap> D2DPixelProcessor2D::implCreateAlpha_B2 std::unique_ptr<sal_uInt8[]> aData(new sal_uInt8[nPixelCount]); sal_uInt8* pTarget = aData.get(); Bitmap aSrcAlpha(aAlpha.GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(aSrcAlpha.AcquireReadAccess(), aSrcAlpha); + BitmapScopedReadAccess pReadAccess(aSrcAlpha); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx index 85870f70cc85..3ee751cbbda4 100644 --- a/drawinglayer/source/texture/texture3d.cxx +++ b/drawinglayer/source/texture/texture3d.cxx @@ -76,11 +76,11 @@ namespace drawinglayer::texture if(mbIsAlpha) { maTransparence = rBitmapEx.GetAlphaMask().GetBitmap(); - mpReadTransparence = Bitmap::ScopedReadAccess(maTransparence); + mpReadTransparence = maTransparence; } if (!maBitmap.IsEmpty()) - mpReadBitmap = Bitmap::ScopedReadAccess(maBitmap); + mpReadBitmap = maBitmap; SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap"); if (mpReadBitmap) { |