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 /vcl | |
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 'vcl')
96 files changed, 386 insertions, 546 deletions
diff --git a/vcl/backendtest/outputdevice/bitmap.cxx b/vcl/backendtest/outputdevice/bitmap.cxx index 9ea1a6f08d84..517be3968eb4 100644 --- a/vcl/backendtest/outputdevice/bitmap.cxx +++ b/vcl/backendtest/outputdevice/bitmap.cxx @@ -11,7 +11,7 @@ #include <test/outputdevice.hxx> #include <vcl/bitmapex.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> namespace vcl::test { @@ -104,7 +104,7 @@ Bitmap OutputDeviceTestBitmap::setupDrawBitmapExWithAlpha(vcl::PixelFormat aBitm AlphaMask aAlpha(aBitmapSize); { - AlphaScopedWriteAccess aWriteAccess(aAlpha); + BitmapScopedWriteAccess aWriteAccess(aAlpha); aWriteAccess->Erase(COL_ALPHA_TRANSPARENT); aWriteAccess->SetLineColor(Color(0xBB, 0xBB, 0xBB)); aWriteAccess->DrawRect(tools::Rectangle(0, 0, 8, 8)); @@ -153,7 +153,7 @@ BitmapEx OutputDeviceTestBitmap::setupDrawBlend(vcl::PixelFormat aBitmapFormat) AlphaMask aAlpha(aBitmapSize); { - AlphaScopedWriteAccess aWriteAccess(aAlpha); + BitmapScopedWriteAccess aWriteAccess(aAlpha); aWriteAccess->Erase(COL_ALPHA_TRANSPARENT); aWriteAccess->SetLineColor(Color(0xBB, 0xBB, 0xBB)); aWriteAccess->DrawRect(tools::Rectangle(0, 0, 8, 8)); diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index 38c616bf3c93..bd8b905f647f 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -10,7 +10,7 @@ #include <test/outputdevice.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <salgdi.hxx> #include <map> diff --git a/vcl/inc/bitmap/BitmapWriteAccess.hxx b/vcl/inc/bitmap/BitmapWriteAccess.hxx deleted file mode 100644 index bc903769d679..000000000000 --- a/vcl/inc/bitmap/BitmapWriteAccess.hxx +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - */ - -#ifndef INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX -#define INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX - -#include <vcl/alpha.hxx> -#include <vcl/bitmap.hxx> -#include <vcl/BitmapReadAccess.hxx> -#include <optional> - -typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess> - BitmapScopedWriteAccess; - -typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireAlphaWriteAccess> - AlphaScopedWriteAccess; - -class VCL_DLLPUBLIC BitmapWriteAccess final : public BitmapReadAccess -{ -public: - BitmapWriteAccess(Bitmap& rBitmap); - virtual ~BitmapWriteAccess() override; - - void CopyScanline(tools::Long nY, const BitmapReadAccess& rReadAcc); - void CopyScanline(tools::Long nY, ConstScanline aSrcScanline, ScanlineFormat nSrcScanlineFormat, - sal_uInt32 nSrcScanlineSize); - - void SetPalette(const BitmapPalette& rPalette) - { - assert(mpBuffer && "Access is not valid!"); - - mpBuffer->maPalette = rPalette; - } - - void SetPaletteEntryCount(sal_uInt16 nCount) - { - assert(mpBuffer && "Access is not valid!"); - - mpBuffer->maPalette.SetEntryCount(nCount); - } - - void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor) - { - assert(mpBuffer && "Access is not valid!"); - assert(HasPalette() && "Bitmap has no palette!"); - - mpBuffer->maPalette[nColor] = rBitmapColor; - } - - void SetPixel(tools::Long nY, tools::Long nX, const BitmapColor& rBitmapColor) - { - assert(mpBuffer && "Access is not valid!"); - assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!"); - assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!"); - - mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask); - } - - void SetPixelIndex(tools::Long nY, tools::Long nX, sal_uInt8 cIndex) - { - SetPixel(nY, nX, BitmapColor(cIndex)); - } - - void SetLineColor(const Color& rColor); - - void SetFillColor(); - void SetFillColor(const Color& rColor); - - void Erase(const Color& rColor); - - void DrawLine(const Point& rStart, const Point& rEnd); - - void FillRect(const tools::Rectangle& rRect); - void DrawRect(const tools::Rectangle& rRect); - -private: - std::optional<BitmapColor> mpLineColor; - std::optional<BitmapColor> mpFillColor; - - BitmapWriteAccess() = delete; - BitmapWriteAccess(const BitmapWriteAccess&) = delete; - BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/canvasbitmap.hxx b/vcl/inc/canvasbitmap.hxx index 54586a1ad60e..9460dcec96fc 100644 --- a/vcl/inc/canvasbitmap.hxx +++ b/vcl/inc/canvasbitmap.hxx @@ -26,6 +26,7 @@ #include <com/sun/star/rendering/XBitmapPalette.hpp> #include <vcl/bitmapex.hxx> +#include <vcl/BitmapReadAccess.hxx> namespace vcl::unotools { @@ -38,10 +39,10 @@ namespace vcl::unotools BitmapEx m_aBmpEx; ::Bitmap m_aBitmap; ::Bitmap m_aAlpha; - Bitmap::ScopedInfoAccess m_pBmpAcc; - Bitmap::ScopedInfoAccess m_pAlphaAcc; - std::optional<Bitmap::ScopedReadAccess> m_pBmpReadAcc; - std::optional<Bitmap::ScopedReadAccess> m_pAlphaReadAcc; + BitmapScopedInfoAccess m_pBmpAcc; + BitmapScopedInfoAccess m_pAlphaAcc; + std::optional<BitmapScopedReadAccess> m_pBmpReadAcc; + std::optional<BitmapScopedReadAccess> m_pAlphaReadAcc; css::uno::Sequence<sal_Int8> m_aComponentTags; css::uno::Sequence<sal_Int32> m_aComponentBitCounts; css::rendering::IntegerBitmapLayout m_aLayout; @@ -55,8 +56,8 @@ namespace vcl::unotools bool m_bPalette; SAL_DLLPRIVATE void setComponentInfo( sal_uInt32 redShift, sal_uInt32 greenShift, sal_uInt32 blueShift ); - Bitmap::ScopedReadAccess& getBitmapReadAccess(); - Bitmap::ScopedReadAccess& getAlphaReadAccess(); + BitmapScopedReadAccess& getBitmapReadAccess(); + BitmapScopedReadAccess& getAlphaReadAccess(); virtual ~VclCanvasBitmap() override; diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index eace78ec0d85..fac11693cfa0 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -145,7 +145,7 @@ #include <basegfx/vector/b2enums.hxx> #include <basegfx/vector/b2isize.hxx> #include <basegfx/vector/b2ivector.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/datatransfer/XTransferable2.hpp> diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx index c4cc184fb7ad..b45f5ee33fba 100644 --- a/vcl/qa/cppunit/BackendTest.cxx +++ b/vcl/qa/cppunit/BackendTest.cxx @@ -14,7 +14,7 @@ #include <tools/stream.hxx> #include <vcl/graphicfilter.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <svdata.hxx> #include <salinst.hxx> @@ -1180,9 +1180,9 @@ public: // as the alpha mask. device->Erase(); alpha.Erase(255); // transparent - BitmapWriteAccess* alphaWrite = alpha.AcquireAlphaWriteAccess(); + BitmapScopedWriteAccess alphaWrite(alpha); alphaWrite->SetPixelIndex(0, 0, 255); // opaque - Bitmap::ReleaseAccess(alphaWrite); + alphaWrite.reset(); device->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap, alpha)); exportDevice("blend_extended_04.png", device); CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(2, 2))); diff --git a/vcl/qa/cppunit/BitmapExTest.cxx b/vcl/qa/cppunit/BitmapExTest.cxx index 8313de37fc60..9b40df6cafbe 100644 --- a/vcl/qa/cppunit/BitmapExTest.cxx +++ b/vcl/qa/cppunit/BitmapExTest.cxx @@ -13,7 +13,7 @@ #include <vcl/bitmapex.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <svdata.hxx> #include <salinst.hxx> @@ -47,7 +47,7 @@ void BitmapExTest::testGetPixelColor24_8() } AlphaMask aMask(Size(3, 3)); { - AlphaScopedWriteAccess pWriteAccess(aMask); + BitmapScopedWriteAccess pWriteAccess(aMask); pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0xAA, 0xAA, 0xAA)); } @@ -95,7 +95,7 @@ void BitmapExTest::testTransformBitmapEx() aMatrix.rotate(M_PI / 2); BitmapEx aTransformed = aBitmapEx.TransformBitmapEx(16, 16, aMatrix); aBitmap = aTransformed.GetBitmap(); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) @@ -126,49 +126,49 @@ void BitmapExTest::testAlphaBlendWith() bitmap.Erase(64); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 112), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(12); bitmap.Erase(64); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 73), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(12); bitmap.Erase(12); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 24), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(127); bitmap.Erase(13); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 134), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(255); bitmap.Erase(255); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 255), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(0); bitmap.Erase(255); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 255), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(255); bitmap.Erase(0); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 255), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); alpha.Erase(0); bitmap.Erase(0); alpha.BlendWith(bitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255 - 0), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); } void BitmapExTest::testCreateMask() @@ -181,7 +181,7 @@ void BitmapExTest::testCreateMask() pWriteAccess->SetPixel(i, i, COL_RED); } aBitmap = aBitmap.CreateMask(COL_RED, 1); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); // the output is a greyscale palette bitmap CPPUNIT_ASSERT_EQUAL(sal_uInt8(0xff), pAccess->GetPixelIndex(0, 0)); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x00), pAccess->GetPixelIndex(0, 1)); @@ -205,7 +205,7 @@ void BitmapExTest::testCombineMaskOr() } AlphaMask aAlphaBitmap(Size(3, 3)); { - AlphaMask::ScopedWriteAccess pWriteAccess(aAlphaBitmap); + BitmapScopedWriteAccess pWriteAccess(aAlphaBitmap); pWriteAccess->Erase(Color(0xff, 0xff, 0xff)); for (int i = 1; i < 3; ++i) { @@ -217,7 +217,7 @@ void BitmapExTest::testCombineMaskOr() { AlphaMask aMask = aBitmap.CreateAlphaMask(COL_RED, 1); - AlphaMask::ScopedReadAccess pAccess(aMask); + BitmapScopedReadAccess pAccess(aMask); // the output is a greyscale palette bitmap CPPUNIT_ASSERT_EQUAL(sal_uInt8(0xff), pAccess->GetPixelIndex(0, 0)); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0xff), pAccess->GetPixelIndex(0, 1)); diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx index a2aa37ceb900..0432041cac7c 100644 --- a/vcl/qa/cppunit/BitmapFilterTest.cxx +++ b/vcl/qa/cppunit/BitmapFilterTest.cxx @@ -10,7 +10,7 @@ #include <test/bootstrapfixture.hxx> #include <vcl/bitmap.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <tools/stream.hxx> #include <vcl/graphicfilter.hxx> @@ -130,7 +130,7 @@ void BitmapFilterTest::testBlurCorrectness() CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit)); { - Bitmap::ScopedReadAccess aReadAccess(aBitmap24Bit); + BitmapScopedReadAccess aReadAccess(aBitmap24Bit); CPPUNIT_ASSERT_EQUAL(scanlineFormat, aReadAccess->GetScanlineFormat()); } } diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx index 0852a33914b0..874419092d30 100644 --- a/vcl/qa/cppunit/BitmapProcessorTest.cxx +++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx @@ -16,7 +16,7 @@ #include <vcl/alpha.hxx> #include <bitmap/BitmapDisabledImageFilter.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> namespace { @@ -42,7 +42,7 @@ void BitmapProcessorTest::testDisabledImage() BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx)); Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap()); { - Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap); + BitmapScopedReadAccess pReadAccess(aDisabledBitmap); Color aColor(pReadAccess->GetPixel(0, 0)); CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor); } @@ -56,7 +56,7 @@ void BitmapProcessorTest::testDisabledImage() } AlphaMask aMask(Size(3, 3)); { - AlphaScopedWriteAccess pWriteAccess(aMask); + BitmapScopedWriteAccess pWriteAccess(aMask); pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0xAA, 0xAA, 0xAA)); } @@ -66,13 +66,13 @@ void BitmapProcessorTest::testDisabledImage() Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap()); { - Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap); + BitmapScopedReadAccess pReadAccess(aDisabledBitmap); Color aColor(pReadAccess->GetPixel(0, 0)); CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor); } AlphaMask aDisabledAlphaMask(aDisabledBitmapEx.GetAlphaMask()); { - AlphaMask::ScopedReadAccess pReadAccess(aDisabledAlphaMask); + BitmapScopedReadAccess pReadAccess(aDisabledAlphaMask); Color aColor(pReadAccess->GetPixel(0, 0)); CPPUNIT_ASSERT_EQUAL(Color(0x0000AA), aColor); } diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx index ce8f67437d9d..9bb6a48e4872 100644 --- a/vcl/qa/cppunit/BitmapScaleTest.cxx +++ b/vcl/qa/cppunit/BitmapScaleTest.cxx @@ -17,7 +17,7 @@ #include <vcl/graphicfilter.hxx> #include <BitmapSymmetryCheck.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> namespace { @@ -38,7 +38,7 @@ bool checkBitmapColor(Bitmap const& rBitmap, Color const& rExpectedColor) { bool bResult = true; Bitmap aBitmap(rBitmap); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); tools::Long nHeight = pReadAccess->Height(); tools::Long nWidth = pReadAccess->Width(); for (tools::Long y = 0; y < nHeight; ++y) diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index dfcf44a8f6a7..e00f2e0dc873 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -21,7 +21,7 @@ #include <vcl/skia/SkiaHelper.hxx> #include <vcl/BitmapMonochromeFilter.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/Octree.hxx> #include <salinst.hxx> #include <svdata.hxx> @@ -271,7 +271,7 @@ void BitmapTest::testConvert() CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat()); { - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pReadAccess->GetBitCount()); #if defined MACOSX || defined IOS if (SkiaHelper::isVCLSkiaEnabled()) @@ -293,7 +293,7 @@ void BitmapTest::testConvert() CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aBitmap.getPixelFormat()); { - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); // 24 bit Bitmap on SVP backend can now use 24bit RGB everywhere. CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), pReadAccess->GetBitCount()); @@ -450,7 +450,7 @@ void BitmapTest::testCustom8BitPalette() } { - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); CPPUNIT_ASSERT_EQUAL(0, int(pAccess->GetPixelIndex(0, 0))); CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0xCC, 0x22), pAccess->GetColor(0, 0)); @@ -479,7 +479,7 @@ void BitmapTest::testErase() pWriteAccess->Erase(Color(0x11, 0x22, 0x33)); } { - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); BitmapColor aColor(pReadAccess->GetPixel(0, 0)); CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x11, 0x22, 0x33, 0x00), aColor); } @@ -500,7 +500,7 @@ void BitmapTest::testBitmap32() pWriteAccess->SetPixel(2, 2, BitmapColor(ColorTransparency, 0x99, 0x77, 0x66, 0x55)); } { - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); BitmapColor aColor = pReadAccess->GetPixel(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x00, 0x00, 0x00, 0xFF), aColor); @@ -532,7 +532,7 @@ void BitmapTest::testOctree() { // Reduce to 1 color - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Octree aOctree(*pAccess, 1); auto aBitmapPalette = aOctree.GetPalette(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), aBitmapPalette.GetEntryCount()); @@ -541,7 +541,7 @@ void BitmapTest::testOctree() { // Reduce to 4 color - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Octree aOctree(*pAccess, 4); auto aBitmapPalette = aOctree.GetPalette(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), aBitmapPalette.GetEntryCount()); @@ -553,7 +553,7 @@ void BitmapTest::testOctree() { // Reduce to 256 color - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Octree aOctree(*pAccess, 256); auto aBitmapPalette = aOctree.GetPalette(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(74), aBitmapPalette.GetEntryCount()); diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index 94cbd654b5ce..557ac41df2ef 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -123,7 +123,7 @@ bool checkBitmap(Graphic& rGraphic) Bitmap aBitmap(rGraphic.GetBitmapEx().GetBitmap()); { - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); for (tools::Long y = 0; y < rGraphic.GetSizePixel().Height(); y++) { for (tools::Long x = 0; x < rGraphic.GetSizePixel().Width(); x++) diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx index dbe02d455b04..991f202cefe1 100644 --- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx +++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx @@ -260,7 +260,7 @@ void BitmapRenderTest::testTdf116888() Bitmap aBitmap = aGraphic.GetBitmapEx().GetBitmap(); CPPUNIT_ASSERT(!aBitmap.IsEmpty()); aBitmap.Scale(0.8, 0.8); // This scaling discards mpUserData, - Bitmap::ScopedReadAccess pAccess(aBitmap); // forcing ReadTexture() here. + BitmapScopedReadAccess pAccess(aBitmap); // forcing ReadTexture() here. // Check that there is mpUserBuffer content. CPPUNIT_ASSERT(pAccess); const ScanlineFormat eFormat = pAccess->GetScanlineFormat(); 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); } } diff --git a/vcl/qa/cppunit/cjktext.cxx b/vcl/qa/cppunit/cjktext.cxx index 91d14805544d..8dbed792b97c 100644 --- a/vcl/qa/cppunit/cjktext.cxx +++ b/vcl/qa/cppunit/cjktext.cxx @@ -63,7 +63,7 @@ public: static tools::Long getCharacterTopWidth(VirtualDevice* device, const Point& start) { Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); tools::Long y = start.Y(); while (y < bitmap.GetSizePixel().Height() && access->GetColor(y, start.X()) != COL_BLACK) ++y; @@ -82,7 +82,7 @@ static tools::Long getCharacterTopWidth(VirtualDevice* device, const Point& star static tools::Long getCharacterRightSideHeight(VirtualDevice* device, const Point& start) { Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); tools::Long x = start.X(); while (x >= 0 && access->GetColor(start.Y(), x) != COL_BLACK) --x; diff --git a/vcl/qa/cppunit/drawmode.cxx b/vcl/qa/cppunit/drawmode.cxx index 9a1408bb2ec9..3dce4a7af636 100644 --- a/vcl/qa/cppunit/drawmode.cxx +++ b/vcl/qa/cppunit/drawmode.cxx @@ -16,7 +16,7 @@ #include <vcl/metric.hxx> #include <vcl/settings.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <drawmode.hxx> class VclDrawModeTest : public test::BootstrapFixture @@ -340,7 +340,7 @@ void VclDrawModeTest::testDrawModeBitmapEx() { BitmapEx aResultBitmapEx(vcl::drawmode::GetBitmapEx(aBmpEx, DrawModeFlags::GrayBitmap)); Bitmap aResultBitmap(aResultBitmapEx.GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(aResultBitmap); + BitmapScopedReadAccess pReadAccess(aResultBitmap); const BitmapColor& rColor = pReadAccess->GetColor(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(0x26, 0x26, 0x26), rColor); @@ -350,7 +350,7 @@ void VclDrawModeTest::testDrawModeBitmapEx() { BitmapEx aResultBitmapEx(vcl::drawmode::GetBitmapEx(aBmpEx, DrawModeFlags::NoFill)); Bitmap aResultBitmap(aResultBitmapEx.GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(aResultBitmap); + BitmapScopedReadAccess pReadAccess(aResultBitmap); const BitmapColor& rColor = pReadAccess->GetColor(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_RED), rColor); diff --git a/vcl/qa/cppunit/gen/gen.cxx b/vcl/qa/cppunit/gen/gen.cxx index a716711c9ab4..29d950113282 100644 --- a/vcl/qa/cppunit/gen/gen.cxx +++ b/vcl/qa/cppunit/gen/gen.cxx @@ -42,7 +42,7 @@ public: CPPUNIT_TEST_FIXTURE(GenTest, testTdf121120) { Bitmap aBitmap = load("tdf121120.png"); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); const Size& rSize = aBitmap.GetSizePixel(); Color aColor(pAccess->GetPixel(rSize.getHeight() / 2, rSize.getWidth() / 2)); // Without the accompanying fix in place, this test would have failed with 'Expected: 255; @@ -79,7 +79,7 @@ CPPUNIT_TEST_FIXTURE(GenTest, testTdf107966) // Make sure that the polygon is visible. Bitmap aBitmap = pVirtualDevice->GetBitmap(Point(), Size(1350, 15)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Color aPixel(pAccess->GetPixel(0, 0)); // Without the accompanying fix in place, this test would have failed with 'Expected: 000000; // Actual: ffffff', i.e. the top left pixel was white, not black. diff --git a/vcl/qa/cppunit/gradient.cxx b/vcl/qa/cppunit/gradient.cxx index 2f33f4b1a6d0..4af26d0be5d1 100644 --- a/vcl/qa/cppunit/gradient.cxx +++ b/vcl/qa/cppunit/gradient.cxx @@ -26,7 +26,7 @@ #include <vcl/gdimtf.hxx> #include <vcl/metaact.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bufferdevice.hxx> #include <window.h> diff --git a/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx index 56b2f1c5b087..4e7585398e19 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx @@ -13,7 +13,7 @@ #include <tools/stream.hxx> #include <vcl/graph.hxx> #include <vcl/graphicfilter.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <graphic/GraphicFormatDetector.hxx> #include <filter/TiffReader.hxx> @@ -165,7 +165,7 @@ void TiffFilterTest::testTdf74331() CPPUNIT_ASSERT_EQUAL(tools::Long(200), aSize.Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(200), aSize.Height()); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); // Check the image contains different kinds of grays int nGrayCount = 0; @@ -223,7 +223,7 @@ void TiffFilterTest::testRoundtrip() CPPUNIT_ASSERT_EQUAL(Size(2, 2), aResultBitmap.GetSizePixel()); { - Bitmap::ScopedReadAccess pAccess(aResultBitmap); + BitmapScopedReadAccess pAccess(aResultBitmap); CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAccess->GetPixel(0, 0))); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(pAccess->GetPixel(0, 1))); CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(pAccess->GetPixel(1, 0))); @@ -262,7 +262,7 @@ void TiffFilterTest::testRGB8bits() CPPUNIT_ASSERT_EQUAL(tools::Long(10), aSize.Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(10), aSize.Height()); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); const Color aColor = pReadAccess->GetColor(5, 5); if (rName == u"red8.tif") @@ -297,7 +297,7 @@ void TiffFilterTest::testRGB16bits() CPPUNIT_ASSERT_EQUAL(tools::Long(10), aSize.Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(10), aSize.Height()); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); const Color aColor = pReadAccess->GetColor(5, 5); if (rName == u"red16.tif") diff --git a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx index 0244c388ead8..d3c43f48191f 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx @@ -10,7 +10,7 @@ #include <unotest/filters-test.hxx> #include <test/bootstrapfixture.hxx> #include <vcl/FilterConfigItem.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <tools/stream.hxx> #include <vcl/graph.hxx> #include <vcl/graphicfilter.hxx> @@ -94,7 +94,7 @@ void WebpFilterTest::testRoundtrip(bool lossy) pAccess->FillRect(tools::Rectangle(Point(0, 10), Size(10, 10))); pAccess->SetFillColor(COL_BLUE); pAccess->FillRect(tools::Rectangle(Point(10, 10), Size(10, 10))); - AlphaScopedWriteAccess pAccessAlpha(aAlpha); + BitmapScopedWriteAccess pAccessAlpha(aAlpha); pAccessAlpha->SetFillColor(BitmapColor(0)); // opaque pAccessAlpha->FillRect(tools::Rectangle(Point(0, 0), Size(10, 10))); pAccessAlpha->FillRect(tools::Rectangle(Point(10, 0), Size(10, 10))); @@ -124,7 +124,7 @@ void WebpFilterTest::testRoundtrip(bool lossy) { Bitmap tmpBitmap = aResultBitmap.GetBitmap(); - Bitmap::ScopedReadAccess pAccess(tmpBitmap); + BitmapScopedReadAccess pAccess(tmpBitmap); // Note that x,y are swapped. CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAccess->GetPixel(0, 0))); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(pAccess->GetPixel(0, 19))); @@ -140,7 +140,7 @@ void WebpFilterTest::testRoundtrip(bool lossy) CPPUNIT_ASSERT_EQUAL(COL_BLUE, Color(pAccess->GetPixel(19, 19))); } AlphaMask tmpAlpha = aResultBitmap.GetAlphaMask(); - AlphaMask::ScopedReadAccess pAccessAlpha(tmpAlpha); + BitmapScopedReadAccess pAccessAlpha(tmpAlpha); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 0)); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 19)); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(19, 0)); @@ -181,7 +181,7 @@ void WebpFilterTest::testRead(std::u16string_view rName, bool lossy, bool alpha) { Bitmap tmpBitmap = aResultBitmap.GetBitmap(); - Bitmap::ScopedReadAccess pAccess(tmpBitmap); + BitmapScopedReadAccess pAccess(tmpBitmap); // Note that x,y are swapped. if (lossy) CPPUNIT_ASSERT_LESS(sal_uInt16(2), pAccess->GetPixel(0, 0).GetColorError(COL_LIGHTRED)); @@ -191,7 +191,7 @@ void WebpFilterTest::testRead(std::u16string_view rName, bool lossy, bool alpha) if (alpha) { AlphaMask tmpAlpha = aResultBitmap.GetAlphaMask(); - AlphaMask::ScopedReadAccess pAccessAlpha(tmpAlpha); + BitmapScopedReadAccess pAccessAlpha(tmpAlpha); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 0)); CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(0, 9)); } diff --git a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx index 0900c02d4bb5..f83d58d51d73 100644 --- a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx +++ b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx @@ -14,7 +14,7 @@ #include <unotest/bootstrapfixturebase.hxx> #include <vcl/graphicfilter.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <tools/stream.hxx> constexpr OUStringLiteral gaDataUrl(u"/vcl/qa/cppunit/jpeg/data/"); @@ -176,7 +176,7 @@ void JpegReaderTest::testTdf138950() CPPUNIT_ASSERT_EQUAL(tools::Long(720), aSize.Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(1280), aSize.Height()); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); int nBlackCount = 0; for (tools::Long nY = 0; nY < aSize.Height(); ++nY) { diff --git a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx index f9b58c30843b..c20dd9e8bcdb 100644 --- a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx +++ b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx @@ -79,7 +79,7 @@ BitmapEx JpegWriterTest::roundtripJPG(const BitmapEx& bitmap) void JpegWriterTest::testWrite8BitGrayscale() { Bitmap bitmap = roundtripJPG(getFullUrl(u"8BitGrayscale.jpg")).GetBitmap(); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); const ScanlineFormat format = access->GetScanlineFormat(); // Check that it's still 8bit grayscale. CPPUNIT_ASSERT_EQUAL(ScanlineFormat::N8BitPal, format); @@ -95,7 +95,7 @@ void JpegWriterTest::testWrite8BitGrayscale() void JpegWriterTest::testWrite8BitNonGrayscale() { Bitmap bitmap = roundtripJPG(getFullUrl(u"8BitNonGrayscale.gif")).GetBitmap(); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); const ScanlineFormat format = access->GetScanlineFormat(); // Check that it's still 8bit grayscale. CPPUNIT_ASSERT_EQUAL(ScanlineFormat::N8BitPal, format); diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 83325db08b60..12f1dea4e582 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -26,7 +26,7 @@ #include <vcl/gdimtf.hxx> #include <vcl/metaact.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bufferdevice.hxx> #include <window.h> @@ -110,7 +110,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testVirtualDevice) CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(30, 31))); // Gotcha: y and x swap for BitmapReadAccess: deep joy. - Bitmap::ScopedReadAccess pAcc(aBmp); + BitmapScopedReadAccess pAcc(aBmp); CPPUNIT_ASSERT_EQUAL(COL_WHITE, static_cast<Color>(pAcc->GetPixel(0, 0))); #if !defined _WIN32 //TODO: various failures on Windows tinderboxes CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<Color>(pAcc->GetPixel(2, 1))); @@ -204,7 +204,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDrawBlackBitmap) // test to see if the color is black Bitmap aBlackBmp(pVDev->GetBitmap(Point(0, 0), Size(10, 10))); - Bitmap::ScopedReadAccess pReadAccess(aBlackBmp); + BitmapScopedReadAccess pReadAccess(aBlackBmp); const BitmapColor& rColor = pReadAccess->GetColor(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_BLACK), rColor); } @@ -248,7 +248,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDrawWhiteBitmap) // test to see if the color is white Bitmap aWhiteBmp(pVDev->GetBitmap(Point(0, 0), Size(10, 10))); - Bitmap::ScopedReadAccess pReadAccess(aWhiteBmp); + BitmapScopedReadAccess pReadAccess(aWhiteBmp); const BitmapColor& rColor = pReadAccess->GetColor(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), rColor); } @@ -319,7 +319,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDrawGrayBitmap) // check to ensure that the bitmap is red { - Bitmap::ScopedReadAccess pReadAccess(aBmp); + BitmapScopedReadAccess pReadAccess(aBmp); const BitmapColor& rColor = pReadAccess->GetColor(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_RED), rColor); } @@ -332,7 +332,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDrawGrayBitmap) // should be a grey Bitmap aVDevBmp(pVDev->GetBitmap(Point(), Size(1, 1))); { - Bitmap::ScopedReadAccess pReadAccess(aVDevBmp); + BitmapScopedReadAccess pReadAccess(aVDevBmp); const BitmapColor& rColor = pReadAccess->GetColor(0, 0); CPPUNIT_ASSERT_EQUAL(BitmapColor(0x26, 0x26, 0x26), rColor); } @@ -379,7 +379,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDrawTransformedBitmapEx) CPPUNIT_ASSERT_EQUAL(Size(16, 16), aTransformedSize); aBitmap = rBitmapEx.GetBitmap(); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) @@ -438,7 +438,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDrawTransformedBitmapExFlip) const BitmapEx& rBitmapEx = pBitmapAction->GetBitmapEx(); aBitmap = rBitmapEx.GetBitmap(); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); int nX = 8 * 0.25; int nY = 8 * 0.25; BitmapColor aColor = pAccess->GetPixel(nY, nX); diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 51833b870d05..2e900ec41d4c 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -27,7 +27,7 @@ #include <vcl/filter/PngImageWriter.hxx> #include <vcl/BitmapReadAccess.hxx> #include <vcl/BitmapMonochromeFilter.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <vcl/alpha.hxx> #include <vcl/graphicfilter.hxx> #include <unotools/tempfile.hxx> @@ -64,7 +64,7 @@ void checkImportExportPng(const OUString& sFilePath, const Case& aCase) CPPUNIT_ASSERT_MESSAGE(OString("Failed to read png from: " + sFilePath.toUtf8()).getStr(), bReadOk); Bitmap aImportedBitmap = aImportedBitmapEx.GetBitmap(); - Bitmap::ScopedInfoAccess pAccess(aImportedBitmap); + BitmapScopedInfoAccess pAccess(aImportedBitmap); auto nActualWidth = aImportedBitmapEx.GetSizePixel().Width(); auto nActualHeight = aImportedBitmapEx.GetSizePixel().Height(); auto nActualBpp = vcl::pixelFormatBitCount(aImportedBitmapEx.GetBitmap().getPixelFormat()); @@ -103,7 +103,7 @@ void checkImportExportPng(const OUString& sFilePath, const Case& aCase) CPPUNIT_ASSERT_MESSAGE( OString("Failed to read exported png: " + sFilePath.toUtf8()).getStr(), bReadOk); Bitmap aExportedImportedBitmap = aExportedImportedBitmapEx.GetBitmap(); - Bitmap::ScopedInfoAccess pAccess(aExportedImportedBitmap); + BitmapScopedInfoAccess pAccess(aExportedImportedBitmap); auto nActualWidth = aExportedImportedBitmapEx.GetSizePixel().Width(); auto nActualHeight = aExportedImportedBitmapEx.GetSizePixel().Height(); auto nActualBpp @@ -208,7 +208,7 @@ void PngFilterTest::testPng() Bitmap aBitmap = aBitmapEx.GetBitmap(); { - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Height()); @@ -255,7 +255,7 @@ void PngFilterTest::testPng() Bitmap aBitmap = aBitmapEx.GetBitmap(); { - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Height()); if (pAccess->GetBitCount() == 24 || pAccess->GetBitCount() == 32) @@ -294,7 +294,7 @@ void PngFilterTest::testPng() Bitmap aBitmap = aBitmapEx.GetBitmap(); { - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAccess->Height()); @@ -320,7 +320,7 @@ void PngFilterTest::testPng() AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); { - AlphaMask::ScopedReadAccess pAlphaAccess(aAlpha); + BitmapScopedReadAccess pAlphaAccess(aAlpha); CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), pAlphaAccess->GetBitCount()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAlphaAccess->Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), pAlphaAccess->Height()); @@ -1920,7 +1920,7 @@ void PngFilterTest::testPngRoundtrip24_8() AlphaMask aAlpha(Size(16, 16)); { BitmapScopedWriteAccess pWriteAccessBitmap(aBitmap); - AlphaScopedWriteAccess pWriteAccessAlpha(aAlpha); + BitmapScopedWriteAccess pWriteAccessAlpha(aAlpha); pWriteAccessAlpha->Erase(Color(0xAA, 0xAA, 0xAA)); pWriteAccessBitmap->Erase(COL_BLACK); for (int i = 0; i < 8; ++i) diff --git a/vcl/qa/cppunit/skia/skia.cxx b/vcl/qa/cppunit/skia/skia.cxx index 0caa1922280e..cb4223a4f8f5 100644 --- a/vcl/qa/cppunit/skia/skia.cxx +++ b/vcl/qa/cppunit/skia/skia.cxx @@ -18,7 +18,7 @@ #include <skia/salbmp.hxx> #include <skia/utils.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> using namespace SkiaHelper; @@ -248,17 +248,17 @@ void SkiaTest::testAlphaBlendWith() CPPUNIT_ASSERT(skiaAlpha->unittestHasEraseColor()); CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, alpha.getPixelFormat()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(208), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); // Test with images set. alpha.Erase(64); - AlphaMask::ScopedReadAccess(alpha)->GetColor(0, 0); // Reading a pixel will create pixel data. + BitmapScopedReadAccess(alpha)->GetColor(0, 0); // Reading a pixel will create pixel data. skiaAlpha = dynamic_cast<SkiaSalBitmap*>(alpha.GetBitmap().ImplGetSalBitmap().get()); skiaAlpha->GetSkImage(); CPPUNIT_ASSERT(!skiaAlpha->unittestHasEraseColor()); CPPUNIT_ASSERT(skiaAlpha->unittestHasImage()); bitmap.Erase(64); - AlphaMask::ScopedReadAccess(bitmap)->GetColor(0, 0); // Reading a pixel will create pixel data. + BitmapScopedReadAccess(bitmap)->GetColor(0, 0); // Reading a pixel will create pixel data. skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.GetBitmap().ImplGetSalBitmap().get()); skiaBitmap->GetSkImage(); CPPUNIT_ASSERT(!skiaBitmap->unittestHasEraseColor()); @@ -268,14 +268,14 @@ void SkiaTest::testAlphaBlendWith() CPPUNIT_ASSERT(skiaAlpha->unittestHasImage()); CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, alpha.getPixelFormat()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(207), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); // Test with erase color for alpha and image for other bitmap. alpha.Erase(64); skiaAlpha = dynamic_cast<SkiaSalBitmap*>(alpha.GetBitmap().ImplGetSalBitmap().get()); CPPUNIT_ASSERT(skiaAlpha->unittestHasEraseColor()); bitmap.Erase(64); - AlphaMask::ScopedReadAccess(bitmap)->GetColor(0, 0); // Reading a pixel will create pixel data. + BitmapScopedReadAccess(bitmap)->GetColor(0, 0); // Reading a pixel will create pixel data. skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.GetBitmap().ImplGetSalBitmap().get()); skiaBitmap->GetSkImage(); CPPUNIT_ASSERT(!skiaBitmap->unittestHasEraseColor()); @@ -285,7 +285,7 @@ void SkiaTest::testAlphaBlendWith() CPPUNIT_ASSERT(skiaAlpha->unittestHasImage()); CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, alpha.getPixelFormat()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(207), - AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0)); + BitmapScopedReadAccess(alpha)->GetPixelIndex(0, 0)); } void SkiaTest::testBitmapCopyOnWrite() diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 92b7b71f408e..d339e80b2fa3 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -28,7 +28,7 @@ #include <salhelper/simplereferenceobject.hxx> #include <sal/log.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> @@ -1126,7 +1126,7 @@ void SvmTest::testBitmapExs() BitmapScopedWriteAccess pAccess(aBitmap); pAccess->Erase(COL_MAGENTA); - AlphaScopedWriteAccess pAlphaAccess(aAlpha); + BitmapScopedWriteAccess pAlphaAccess(aAlpha); pAlphaAccess->Erase(Color(127, 127, 127)); } pVirtualDev->DrawBitmapEx(Point(6, 6), BitmapEx(aBitmap, aAlpha)); diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx index b2e837a32c40..cabe502db462 100644 --- a/vcl/qa/cppunit/text.cxx +++ b/vcl/qa/cppunit/text.cxx @@ -68,7 +68,7 @@ static bool isBlack(Color col) static tools::Long getCharacterBaseWidth(VirtualDevice* device, const Point& start) { Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); tools::Long y = start.Y(); while (y >= 0 && !isBlack(access->GetColor(y, start.X()))) --y; @@ -87,7 +87,7 @@ static tools::Long getCharacterBaseWidth(VirtualDevice* device, const Point& sta static tools::Long getCharacterTopWidth(VirtualDevice* device, const Point& start) { Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); tools::Long y = start.Y(); while (y < bitmap.GetSizePixel().Height() && !isBlack(access->GetColor(y, start.X()))) ++y; @@ -108,7 +108,7 @@ static tools::Long getCharacterTopWidth(VirtualDevice* device, const Point& star static tools::Long getCharacterLeftSideHeight(VirtualDevice* device, const Point& start) { Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); tools::Long x = start.X(); while (x < bitmap.GetSizePixel().Width() && !isBlack(access->GetColor(start.Y(), x))) ++x; diff --git a/vcl/source/bitmap/BitmapAlphaClampFilter.cxx b/vcl/source/bitmap/BitmapAlphaClampFilter.cxx index 820bdbdde34b..d36261b2eb4d 100644 --- a/vcl/source/bitmap/BitmapAlphaClampFilter.cxx +++ b/vcl/source/bitmap/BitmapAlphaClampFilter.cxx @@ -10,8 +10,7 @@ #include <vcl/bitmapex.hxx> #include <vcl/BitmapAlphaClampFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapAlphaClampFilter::execute(BitmapEx const& rBitmapEx) const { @@ -20,7 +19,7 @@ BitmapEx BitmapAlphaClampFilter::execute(BitmapEx const& rBitmapEx) const AlphaMask aBitmapAlpha(rBitmapEx.GetAlphaMask()); { - AlphaScopedWriteAccess pWriteAlpha(aBitmapAlpha); + BitmapScopedWriteAccess pWriteAlpha(aBitmapAlpha); const Size aSize(rBitmapEx.GetSizePixel()); for (sal_Int32 nY = 0; nY < sal_Int32(aSize.Height()); ++nY) diff --git a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx index dcaacdad8bcb..e4285cb53a9f 100644 --- a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx +++ b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx @@ -13,8 +13,7 @@ #include <comphelper/threadpool.hxx> #include <sal/log.hxx> #include <vcl/BitmapBasicMorphologyFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <algorithm> @@ -26,16 +25,16 @@ namespace { struct FilterSharedData { - BitmapReadAccess* mpReadAccess; - BitmapWriteAccess* mpWriteAccess; + BitmapScopedReadAccess& mpReadAccess; + BitmapScopedWriteAccess& mpWriteAccess; sal_Int32 mnRadius; sal_uInt8 mnOutsideVal; Color maOutsideColor; - FilterSharedData(Bitmap::ScopedReadAccess& rReadAccess, BitmapScopedWriteAccess& rWriteAccess, + FilterSharedData(BitmapScopedReadAccess& rReadAccess, BitmapScopedWriteAccess& rWriteAccess, sal_Int32 nRadius, sal_uInt8 nOutsideVal) - : mpReadAccess(rReadAccess.get()) - , mpWriteAccess(rWriteAccess.get()) + : mpReadAccess(rReadAccess) + , mpWriteAccess(rWriteAccess) , mnRadius(nRadius) , mnOutsideVal(nOutsideVal) , maOutsideColor(ColorTransparency, nOutsideVal, nOutsideVal, nOutsideVal, nOutsideVal) @@ -73,14 +72,14 @@ template <typename MorphologyOp, int nComponentWidth> struct Value bLookOutside ? rShared.mnOutsideVal : MorphologyOp::initVal); } - void apply(const BitmapReadAccess* pReadAccess, sal_Int32 x, sal_Int32 y, + void apply(BitmapScopedReadAccess& pReadAccess, sal_Int32 x, sal_Int32 y, sal_uInt8* pHint = nullptr) { sal_uInt8* pSource = (pHint ? pHint : pReadAccess->GetScanline(y)) + nWidthBytes * x; std::transform(pSource, pSource + nWidthBytes, aResult, aResult, MorphologyOp::apply); } - void copy(const BitmapWriteAccess* pWriteAccess, sal_Int32 x, sal_Int32 y, + void copy(BitmapScopedWriteAccess& pWriteAccess, sal_Int32 x, sal_Int32 y, sal_uInt8* pHint = nullptr) { sal_uInt8* pDest = (pHint ? pHint : pWriteAccess->GetScanline(y)) + nWidthBytes * x; @@ -104,7 +103,7 @@ template <typename MorphologyOp> struct Value<MorphologyOp, 0> { } - void apply(const BitmapReadAccess* pReadAccess, sal_Int32 x, sal_Int32 y, + void apply(const BitmapScopedReadAccess& pReadAccess, sal_Int32 x, sal_Int32 y, sal_uInt8* /*pHint*/ = nullptr) { const auto& rSource = pReadAccess->GetColor(y, x); @@ -114,7 +113,7 @@ template <typename MorphologyOp> struct Value<MorphologyOp, 0> MorphologyOp::apply(rSource.GetBlue(), aResult.GetBlue())); } - void copy(BitmapWriteAccess* pWriteAccess, sal_Int32 x, sal_Int32 y, + void copy(BitmapScopedWriteAccess& pWriteAccess, sal_Int32 x, sal_Int32 y, sal_uInt8* /*pHint*/ = nullptr) { pWriteAccess->SetPixel(y, x, aResult); @@ -145,8 +144,8 @@ template <typename MorphologyOp, int nComponentWidth> struct pass static void Horizontal(FilterSharedData const& rShared, const sal_Int32 nStart, const sal_Int32 nEnd) { - BitmapReadAccess* pReadAccess = rShared.mpReadAccess; - BitmapWriteAccess* pWriteAccess = rShared.mpWriteAccess; + BitmapScopedReadAccess& pReadAccess = rShared.mpReadAccess; + BitmapScopedWriteAccess& pWriteAccess = rShared.mpWriteAccess; const sal_Int32 nLastIndex = pReadAccess->Width() - 1; @@ -173,8 +172,8 @@ template <typename MorphologyOp, int nComponentWidth> struct pass static void Vertical(FilterSharedData const& rShared, const sal_Int32 nStart, const sal_Int32 nEnd) { - BitmapReadAccess* pReadAccess = rShared.mpReadAccess; - BitmapWriteAccess* pWriteAccess = rShared.mpWriteAccess; + BitmapScopedReadAccess& pReadAccess = rShared.mpReadAccess; + BitmapScopedWriteAccess& pWriteAccess = rShared.mpWriteAccess; const sal_Int32 nLastIndex = pReadAccess->Height() - 1; @@ -235,7 +234,7 @@ void runFilter(Bitmap& rBitmap, const sal_Int32 nRadius, const bool bParallel, auto pTag = comphelper::ThreadPool::createThreadTaskTag(); { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); FilterSharedData aSharedData(pReadAccess, pWriteAccess, nRadius, nOutsideVal); @@ -253,7 +252,7 @@ void runFilter(Bitmap& rBitmap, const sal_Int32 nRadius, const bool bParallel, rShared.waitUntilDone(pTag); } { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); FilterSharedData aSharedData(pReadAccess, pWriteAccess, nRadius, nOutsideVal); @@ -279,7 +278,7 @@ void runFilter(Bitmap& rBitmap, const sal_Int32 nRadius, const bool bParallel, else { { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); FilterSharedData aSharedData(pReadAccess, pWriteAccess, nRadius, nOutsideVal); sal_Int32 nFirstIndex = 0; @@ -287,7 +286,7 @@ void runFilter(Bitmap& rBitmap, const sal_Int32 nRadius, const bool bParallel, myPass::Horizontal(aSharedData, nFirstIndex, nLastIndex); } { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); FilterSharedData aSharedData(pReadAccess, pWriteAccess, nRadius, nOutsideVal); sal_Int32 nFirstIndex = 0; @@ -341,7 +340,7 @@ Bitmap BitmapBasicMorphologyFilter::filter(Bitmap const& rBitmap) const Bitmap bitmapCopy(rBitmap); ScanlineFormat nScanlineFormat; { - Bitmap::ScopedReadAccess pReadAccess(bitmapCopy); + BitmapScopedReadAccess pReadAccess(bitmapCopy); nScanlineFormat = pReadAccess ? pReadAccess->GetScanlineFormat() : ScanlineFormat::NONE; } diff --git a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx index cef8fb60b6f9..9014bfe5dd3f 100644 --- a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx +++ b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx @@ -13,8 +13,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapColorQuantizationFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <algorithm> #include <cstdlib> @@ -26,7 +25,7 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const if (vcl::numberOfColors(aBitmap.getPixelFormat()) <= sal_Int64(mnNewColorCount)) return BitmapEx(aBitmap); - Bitmap::ScopedReadAccess pRAcc(aBitmap); + BitmapScopedReadAccess pRAcc(aBitmap); if (!pRAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapColorizeFilter.cxx b/vcl/source/bitmap/BitmapColorizeFilter.cxx index b006ddcdc1c0..21e996193eee 100644 --- a/vcl/source/bitmap/BitmapColorizeFilter.cxx +++ b/vcl/source/bitmap/BitmapColorizeFilter.cxx @@ -11,7 +11,7 @@ #include <tools/color.hxx> #include <tools/helpers.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapColorizeFilter.hxx> BitmapEx BitmapColorizeFilter::execute(BitmapEx const& rBitmapEx) const diff --git a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx index dc6b7e1fee70..4a0d3d89a8db 100644 --- a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx +++ b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx @@ -14,8 +14,7 @@ #include <vcl/bitmapex.hxx> #include <vcl/BitmapConvolutionMatrixFilter.hxx> #include <vcl/BitmapSharpenFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <array> @@ -24,7 +23,7 @@ BitmapEx BitmapConvolutionMatrixFilter::execute(BitmapEx const& rBitmapEx) const Bitmap aBitmap(rBitmapEx.GetBitmap()); const sal_Int32 nDivisor = 8; - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx index 05251b63e0b6..e38c450d7949 100644 --- a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx +++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx @@ -8,7 +8,7 @@ * */ -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapDisabledImageFilter.hxx> BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx) const @@ -28,7 +28,7 @@ BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx) const BitmapEx aReturnBitmap; Bitmap aReadBitmap(rBitmapEx.GetBitmap()); - Bitmap::ScopedReadAccess pRead(aReadBitmap); + BitmapScopedReadAccess pRead(aReadBitmap); if (pRead && pGrey) { for (sal_Int32 nY = 0; nY < sal_Int32(aSize.Height()); ++nY) diff --git a/vcl/source/bitmap/BitmapDuoToneFilter.cxx b/vcl/source/bitmap/BitmapDuoToneFilter.cxx index 41c3f60fc24d..c9cc10b1d1a4 100644 --- a/vcl/source/bitmap/BitmapDuoToneFilter.cxx +++ b/vcl/source/bitmap/BitmapDuoToneFilter.cxx @@ -11,8 +11,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapDuoToneFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> static sal_uInt8 lcl_getDuotoneColorComponent(sal_uInt8 base, sal_uInt16 color1, sal_uInt16 color2) { @@ -30,7 +29,7 @@ BitmapEx BitmapDuoToneFilter::execute(BitmapEx const& rBitmapEx) const const sal_Int32 nHeight = aBitmap.GetSizePixel().Height(); Bitmap aResultBitmap(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); BitmapScopedWriteAccess pWriteAcc(aResultBitmap); const BitmapColor aColorOne(mnColorOne); const BitmapColor aColorTwo(mnColorTwo); diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx index 405a9056b954..6fa5dd5c12b3 100644 --- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx +++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx @@ -15,8 +15,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapEmbossGreyFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <algorithm> @@ -27,7 +26,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const if (!aBitmap.ImplMakeGreyscales()) return BitmapEx(); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index b4d48b0dfc0d..40feacbf66dd 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -38,7 +38,7 @@ #include <salbmp.hxx> #include <salinst.hxx> #include <svdata.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapMaskToAlphaFilter.hxx> #include <o3tl/any.hxx> @@ -578,7 +578,7 @@ sal_uInt8 BitmapEx::GetAlpha(sal_Int32 nX, sal_Int32 nY) const } else { - AlphaMask::ScopedReadAccess pRead(const_cast<AlphaMask&>(maAlphaMask)); + BitmapScopedReadAccess pRead(maAlphaMask); if(pRead) { const BitmapColor aBitmapColor(pRead->GetPixel(nY, nX)); @@ -591,7 +591,7 @@ sal_uInt8 BitmapEx::GetAlpha(sal_Int32 nX, sal_Int32 nY) const Color BitmapEx::GetPixelColor(sal_Int32 nX, sal_Int32 nY) const { - Bitmap::ScopedReadAccess pReadAccess( const_cast<Bitmap&>(maBitmap) ); + BitmapScopedReadAccess pReadAccess( maBitmap ); assert(pReadAccess); BitmapColor aColor = pReadAccess->GetColor(nY, nX); @@ -599,7 +599,7 @@ Color BitmapEx::GetPixelColor(sal_Int32 nX, sal_Int32 nY) const if (IsAlpha()) { AlphaMask aAlpha = GetAlphaMask(); - AlphaMask::ScopedReadAccess pAlphaReadAccess(aAlpha); + BitmapScopedReadAccess pAlphaReadAccess(aAlpha); aColor.SetAlpha(pAlphaReadAccess->GetPixel(nY, nX).GetIndex()); } else if (maBitmap.getPixelFormat() != vcl::PixelFormat::N32_BPP) @@ -664,7 +664,7 @@ namespace if(xWrite) { - Bitmap::ScopedReadAccess xRead(const_cast< Bitmap& >(rSource)); + BitmapScopedReadAccess xRead(rSource); if (xRead) { @@ -873,7 +873,7 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod // 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 explicitly. - Bitmap::ScopedReadAccess xReadAccess(aChangedBitmap); + BitmapScopedReadAccess xReadAccess(aChangedBitmap); OSL_ENSURE(xReadAccess, "Got no Bitmap ReadAccess ?!?"); if(xReadAccess) @@ -1062,7 +1062,7 @@ BitmapEx createBlendFrame( aContent.Erase(COL_BLACK); BitmapScopedWriteAccess pContent(aContent); - AlphaScopedWriteAccess pAlpha(aAlpha); + BitmapScopedWriteAccess pAlpha(aAlpha); if(pContent && pAlpha) { @@ -1191,7 +1191,7 @@ static Bitmap DetectEdges( const Bitmap& rBmp ) ScopedVclPtr<VirtualDevice> pVirDev(VclPtr<VirtualDevice>::Create()); pVirDev->SetOutputSizePixel(aSize); - Bitmap::ScopedReadAccess pReadAcc(aWorkBmp); + BitmapScopedReadAccess pReadAcc(aWorkBmp); if( !pReadAcc ) return rBmp; @@ -1282,7 +1282,7 @@ tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect, else aWorkBmp = maBitmap; - BitmapReadAccess* pAcc = aWorkBmp.AcquireReadAccess(); + BitmapScopedReadAccess pAcc(aWorkBmp); const tools::Long nWidth = pAcc ? pAcc->Width() : 0; const tools::Long nHeight = pAcc ? pAcc->Height() : 0; @@ -1351,8 +1351,6 @@ tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect, if( ( fFactorX != 0. ) && ( fFactorY != 0. ) ) aRetPoly.Scale( fFactorX, fFactorY ); } - - Bitmap::ReleaseAccess(pAcc); } return aRetPoly; @@ -1361,8 +1359,8 @@ tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect, void BitmapEx::ChangeColorAlpha( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo ) { AlphaMask aAlphaMask(GetAlphaMask()); - AlphaMask::ScopedWriteAccess pAlphaWriteAccess(aAlphaMask); - Bitmap::ScopedReadAccess pReadAccess(maBitmap); + BitmapScopedWriteAccess pAlphaWriteAccess(aAlphaMask); + BitmapScopedReadAccess pReadAccess(maBitmap); assert( pReadAccess.get() && pAlphaWriteAccess.get() ); if ( !(pReadAccess.get() && pAlphaWriteAccess.get()) ) return; @@ -1392,7 +1390,7 @@ void BitmapEx::AdjustTransparency(sal_uInt8 cTrans) else { aAlpha = GetAlphaMask(); - AlphaMask::ScopedWriteAccess pA(aAlpha); + BitmapScopedWriteAccess pA(aAlpha); assert(pA); if( !pA ) @@ -1453,7 +1451,7 @@ void BitmapEx::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette, sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex, sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount) { - Bitmap::ScopedReadAccess pReadAccess( maBitmap ); + BitmapScopedReadAccess pReadAccess( maBitmap ); assert( pReadAccess ); if( pReadAccess->HasPalette() ) diff --git a/vcl/source/bitmap/BitmapFastScaleFilter.cxx b/vcl/source/bitmap/BitmapFastScaleFilter.cxx index b8a8617d606f..431211369f98 100644 --- a/vcl/source/bitmap/BitmapFastScaleFilter.cxx +++ b/vcl/source/bitmap/BitmapFastScaleFilter.cxx @@ -21,8 +21,8 @@ #include <tools/helpers.hxx> #include <vcl/bitmapex.hxx> +#include <vcl/BitmapWriteAccess.hxx> -#include <bitmap/BitmapWriteAccess.hxx> #include <bitmap/BitmapFastScaleFilter.hxx> BitmapEx BitmapFastScaleFilter::execute(BitmapEx const& rBitmapEx) const @@ -40,7 +40,7 @@ BitmapEx BitmapFastScaleFilter::execute(BitmapEx const& rBitmapEx) const if (nNewWidth > 0 && nNewHeight > 0) { - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (pReadAcc) { diff --git a/vcl/source/bitmap/BitmapFilterStackBlur.cxx b/vcl/source/bitmap/BitmapFilterStackBlur.cxx index dc8b33e64243..6e3b1ef555a8 100644 --- a/vcl/source/bitmap/BitmapFilterStackBlur.cxx +++ b/vcl/source/bitmap/BitmapFilterStackBlur.cxx @@ -9,7 +9,7 @@ */ #include <vcl/BitmapFilterStackBlur.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <sal/log.hxx> #include <comphelper/threadpool.hxx> @@ -484,7 +484,7 @@ void runStackBlur(Bitmap& rBitmap, const sal_Int32 nRadius, const sal_Int32 nCom auto pTag = comphelper::ThreadPool::createThreadTaskTag(); { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); BlurSharedData aSharedData(pReadAccess.get(), pWriteAccess.get(), nRadius, nComponentWidth, nColorChannels); @@ -507,7 +507,7 @@ void runStackBlur(Bitmap& rBitmap, const sal_Int32 nRadius, const sal_Int32 nCom rShared.waitUntilDone(pTag); } { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); BlurSharedData aSharedData(pReadAccess.get(), pWriteAccess.get(), nRadius, nComponentWidth, nColorChannels); @@ -539,7 +539,7 @@ void runStackBlur(Bitmap& rBitmap, const sal_Int32 nRadius, const sal_Int32 nCom else { { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); BlurSharedData aSharedData(pReadAccess.get(), pWriteAccess.get(), nRadius, nComponentWidth, nColorChannels); @@ -548,7 +548,7 @@ void runStackBlur(Bitmap& rBitmap, const sal_Int32 nRadius, const sal_Int32 nCom pBlurHorizontalFn(aSharedData, nFirstIndex, nLastIndex); } { - Bitmap::ScopedReadAccess pReadAccess(rBitmap); + BitmapScopedReadAccess pReadAccess(rBitmap); BitmapScopedWriteAccess pWriteAccess(rBitmap); BlurSharedData aSharedData(pReadAccess.get(), pWriteAccess.get(), nRadius, nComponentWidth, nColorChannels); @@ -629,7 +629,7 @@ Bitmap BitmapFilterStackBlur::filter(Bitmap const& rBitmap) const Bitmap bitmapCopy(rBitmap); ScanlineFormat nScanlineFormat; { - Bitmap::ScopedReadAccess pReadAccess(bitmapCopy); + BitmapScopedReadAccess pReadAccess(bitmapCopy); nScanlineFormat = pReadAccess ? pReadAccess->GetScanlineFormat() : ScanlineFormat::NONE; } diff --git a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx index 0b3662e67ce8..d1bc188c95a7 100644 --- a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx +++ b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx @@ -13,8 +13,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapGaussianSeparableBlurFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx) const { @@ -33,7 +32,7 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx) c // Do horizontal filtering blurContributions(nWidth, aNumberOfContributions, aBlurVector, aWeights, aPixels, aCounts); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); // switch coordinates as convolution pass transposes result Bitmap aNewBitmap(Size(nHeight, nWidth), vcl::PixelFormat::N24_BPP); @@ -59,7 +58,7 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx) c // Do vertical filtering blurContributions(nHeight, aNumberOfContributions, aBlurVector, aWeights, aPixels, aCounts); - pReadAcc = Bitmap::ScopedReadAccess(aBitmap); + pReadAcc = aBitmap; aNewBitmap = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N24_BPP); bResult = convolutionPass(aBitmap, aNewBitmap, pReadAcc.get(), aNumberOfContributions, aWeights.data(), aPixels.data(), aCounts.data()); diff --git a/vcl/source/bitmap/BitmapInfoAccess.cxx b/vcl/source/bitmap/BitmapInfoAccess.cxx index 318317519928..817d5187c3f6 100644 --- a/vcl/source/bitmap/BitmapInfoAccess.cxx +++ b/vcl/source/bitmap/BitmapInfoAccess.cxx @@ -23,7 +23,12 @@ #include <svdata.hxx> #include <salinst.hxx> -BitmapInfoAccess::BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode) +BitmapInfoAccess::BitmapInfoAccess(const AlphaMask& rBitmap, BitmapAccessMode nMode) + : BitmapInfoAccess(rBitmap.GetBitmap(), nMode) +{ +} + +BitmapInfoAccess::BitmapInfoAccess(const Bitmap& rBitmap, BitmapAccessMode nMode) : mpBuffer(nullptr) , mnAccessMode(nMode) { @@ -39,7 +44,7 @@ BitmapInfoAccess::BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode) if (xImpBmp.use_count() > 2) { xImpBmp.reset(); - rBitmap.ImplMakeUnique(); + const_cast<Bitmap&>(rBitmap).ImplMakeUnique(); xImpBmp = rBitmap.ImplGetSalBitmap(); } } @@ -52,7 +57,7 @@ BitmapInfoAccess::BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode) if (xNewImpBmp->Create(*xImpBmp, rBitmap.getPixelFormat())) { xImpBmp = xNewImpBmp; - rBitmap.ImplSetSalBitmap(xImpBmp); + const_cast<Bitmap&>(rBitmap).ImplSetSalBitmap(xImpBmp); mpBuffer = xImpBmp->AcquireBuffer(mnAccessMode); } } diff --git a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx index 701c91298a80..c0c866b53d67 100644 --- a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx +++ b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx @@ -22,7 +22,7 @@ #include <vcl/bitmapex.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapFastScaleFilter.hxx> #include <bitmap/BitmapInterpolateScaleFilter.hxx> @@ -37,7 +37,7 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const if ((nNewWidth > 1) && (nNewHeight > 1)) { - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (pReadAcc) { sal_Int32 nWidth = pReadAcc->Width(); @@ -143,8 +143,8 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const const Bitmap aOriginal(aBitmap); aBitmap = aNewBmp; aNewBmp = Bitmap(Size(nNewWidth, nNewHeight), vcl::PixelFormat::N24_BPP); - pReadAcc = Bitmap::ScopedReadAccess(aBitmap); - pWriteAcc = BitmapScopedWriteAccess(aNewBmp); + pReadAcc = aBitmap; + pWriteAcc = aNewBmp; if (pReadAcc && pWriteAcc) { diff --git a/vcl/source/bitmap/BitmapLightenFilter.cxx b/vcl/source/bitmap/BitmapLightenFilter.cxx index 5054e3cae662..a5c4f71e6388 100644 --- a/vcl/source/bitmap/BitmapLightenFilter.cxx +++ b/vcl/source/bitmap/BitmapLightenFilter.cxx @@ -10,7 +10,7 @@ #include <basegfx/color/bcolortools.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapLightenFilter.hxx> BitmapEx BitmapLightenFilter::execute(BitmapEx const& rBitmapEx) const @@ -20,7 +20,7 @@ BitmapEx BitmapLightenFilter::execute(BitmapEx const& rBitmapEx) const Bitmap aBitmap(rBitmapEx.GetBitmap()); Bitmap aDarkBitmap(aSize, vcl::PixelFormat::N24_BPP); - Bitmap::ScopedReadAccess pRead(aBitmap); + BitmapScopedReadAccess pRead(aBitmap); BitmapScopedWriteAccess pWrite(aDarkBitmap); if (pRead && pWrite) diff --git a/vcl/source/bitmap/BitmapMaskToAlphaFilter.cxx b/vcl/source/bitmap/BitmapMaskToAlphaFilter.cxx index c5f1cda1d9cb..acae8f516edf 100644 --- a/vcl/source/bitmap/BitmapMaskToAlphaFilter.cxx +++ b/vcl/source/bitmap/BitmapMaskToAlphaFilter.cxx @@ -10,7 +10,7 @@ #include <basegfx/color/bcolortools.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapMaskToAlphaFilter.hxx> /** @@ -23,7 +23,7 @@ BitmapEx BitmapMaskToAlphaFilter::execute(BitmapEx const& rBitmapEx) const Bitmap aBitmap(rBitmapEx.GetBitmap()); Bitmap aOutBitmap(aSize, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); - Bitmap::ScopedReadAccess pRead(aBitmap); + BitmapScopedReadAccess pRead(aBitmap); BitmapScopedWriteAccess pWrite(aOutBitmap); if (pRead && pWrite) diff --git a/vcl/source/bitmap/BitmapMedianFilter.cxx b/vcl/source/bitmap/BitmapMedianFilter.cxx index a820158fa5a0..222451d0a9b7 100644 --- a/vcl/source/bitmap/BitmapMedianFilter.cxx +++ b/vcl/source/bitmap/BitmapMedianFilter.cxx @@ -11,8 +11,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapMedianFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #define S2(a, b) \ { \ @@ -53,7 +52,7 @@ BitmapEx BitmapMedianFilter::execute(BitmapEx const& rBitmapEx) const { Bitmap aBitmap(rBitmapEx.GetBitmap()); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapMonochromeFilter.cxx b/vcl/source/bitmap/BitmapMonochromeFilter.cxx index e45ae12fa6d0..00f7b99ef155 100644 --- a/vcl/source/bitmap/BitmapMonochromeFilter.cxx +++ b/vcl/source/bitmap/BitmapMonochromeFilter.cxx @@ -11,13 +11,12 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapMonochromeFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapMonochromeFilter::execute(BitmapEx const& aBitmapEx) const { Bitmap aBitmap = aBitmapEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapMosaicFilter.cxx b/vcl/source/bitmap/BitmapMosaicFilter.cxx index f9292838df11..0f89b23b9a6d 100644 --- a/vcl/source/bitmap/BitmapMosaicFilter.cxx +++ b/vcl/source/bitmap/BitmapMosaicFilter.cxx @@ -11,8 +11,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapMosaicFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const { @@ -23,18 +22,19 @@ BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const if (mnTileWidth > 1 || mnTileHeight > 1) { std::optional<Bitmap> pNewBmp; - BitmapReadAccess* pReadAcc; - BitmapWriteAccess* pWriteAcc; + BitmapScopedReadAccess pReadAcc; + BitmapScopedWriteAccess pWriteAcc; if (!isPalettePixelFormat(aBitmap.getPixelFormat())) { - pReadAcc = pWriteAcc = aBitmap.AcquireWriteAccess(); + pReadAcc = aBitmap; + pWriteAcc = aBitmap; } else { pNewBmp.emplace(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP); - pReadAcc = aBitmap.AcquireReadAccess(); - pWriteAcc = pNewBmp->AcquireWriteAccess(); + pReadAcc = aBitmap; + pWriteAcc = *pNewBmp; } bool bConditionsMet = false; @@ -156,10 +156,8 @@ BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const bRet = true; } - if (pWriteAcc == pReadAcc) - pWriteAcc = nullptr; - Bitmap::ReleaseAccess(pReadAcc); - Bitmap::ReleaseAccess(pWriteAcc); + pReadAcc.reset(); + pWriteAcc.reset(); if (pNewBmp) { diff --git a/vcl/source/bitmap/BitmapPopArtFilter.cxx b/vcl/source/bitmap/BitmapPopArtFilter.cxx index 91039feffddf..ee2cf716c93e 100644 --- a/vcl/source/bitmap/BitmapPopArtFilter.cxx +++ b/vcl/source/bitmap/BitmapPopArtFilter.cxx @@ -12,8 +12,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapPopArtFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapPopArtFilter::execute(BitmapEx const& rBitmapEx) const { diff --git a/vcl/source/bitmap/BitmapReadAccess.cxx b/vcl/source/bitmap/BitmapReadAccess.cxx index 66b03be38667..5dc3c944d9a3 100644 --- a/vcl/source/bitmap/BitmapReadAccess.cxx +++ b/vcl/source/bitmap/BitmapReadAccess.cxx @@ -24,7 +24,12 @@ #include <svdata.hxx> #include <salinst.hxx> -BitmapReadAccess::BitmapReadAccess(Bitmap& rBitmap, BitmapAccessMode nMode) +BitmapReadAccess::BitmapReadAccess(const AlphaMask& rBitmap, BitmapAccessMode nMode) + : BitmapReadAccess(rBitmap.GetBitmap(), nMode) +{ +} + +BitmapReadAccess::BitmapReadAccess(const Bitmap& rBitmap, BitmapAccessMode nMode) : BitmapInfoAccess(rBitmap, nMode) , mFncGetPixel(nullptr) , mFncSetPixel(nullptr) diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx index 5bec5810cb5f..27df45f7bab1 100644 --- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx @@ -20,7 +20,7 @@ #include <osl/diagnose.h> #include <tools/helpers.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapScaleConvolutionFilter.hxx> #include <algorithm> @@ -97,7 +97,7 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc return true; } - Bitmap::ScopedReadAccess pReadAcc(rSource); + BitmapScopedReadAccess pReadAcc(rSource); if(pReadAcc) { @@ -187,7 +187,7 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc return true; } - Bitmap::ScopedReadAccess pReadAcc(rSource); + BitmapScopedReadAccess pReadAcc(rSource); if(!pReadAcc) return false; diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx index 3389195aceec..3c844c690e7e 100644 --- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx @@ -21,7 +21,7 @@ #include <comphelper/threadpool.hxx> #include <tools/helpers.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/BitmapScaleSuperFilter.hxx> #include <algorithm> @@ -894,7 +894,7 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const } { - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); // If source format is less than 24BPP, use 24BPP auto eSourcePixelFormat = aBitmap.getPixelFormat(); diff --git a/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx b/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx index 641725cb32d1..a65cd6ee5606 100644 --- a/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx +++ b/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx @@ -14,8 +14,7 @@ #include <vcl/bitmapex.hxx> #include <vcl/BitmapGaussianSeparableBlurFilter.hxx> #include <vcl/BitmapSeparableUnsharpenFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapSeparableUnsharpenFilter::execute(BitmapEx const& rBitmapEx) const { @@ -35,8 +34,8 @@ BitmapEx BitmapSeparableUnsharpenFilter::execute(BitmapEx const& rBitmapEx) cons Bitmap aResultBitmap(Size(nWidth, nHeight), vcl::PixelFormat::N24_BPP); - Bitmap::ScopedReadAccess pReadAccBlur(aBlur); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAccBlur(aBlur); + BitmapScopedReadAccess pReadAcc(aBitmap); BitmapScopedWriteAccess pWriteAcc(aResultBitmap); BitmapColor aColor, aColorBlur; diff --git a/vcl/source/bitmap/BitmapSepiaFilter.cxx b/vcl/source/bitmap/BitmapSepiaFilter.cxx index 714250932be8..fdc5a8a722d9 100644 --- a/vcl/source/bitmap/BitmapSepiaFilter.cxx +++ b/vcl/source/bitmap/BitmapSepiaFilter.cxx @@ -13,15 +13,14 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapSepiaFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <algorithm> BitmapEx BitmapSepiaFilter::execute(BitmapEx const& rBitmapEx) const { Bitmap aBitmap(rBitmapEx.GetBitmap()); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapShadowFilter.cxx b/vcl/source/bitmap/BitmapShadowFilter.cxx index 3dd48556bffa..76da85b3bf0b 100644 --- a/vcl/source/bitmap/BitmapShadowFilter.cxx +++ b/vcl/source/bitmap/BitmapShadowFilter.cxx @@ -11,8 +11,7 @@ #include <vcl/bitmapex.hxx> #include <vcl/BitmapColor.hxx> #include <vcl/BitmapShadowFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapShadowFilter::execute(BitmapEx const& rBitmapEx) const { diff --git a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx index ec4004879651..4dc045be2d64 100644 --- a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx +++ b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx @@ -11,8 +11,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapSimpleColorQuantizationFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/Octree.hxx> BitmapEx BitmapSimpleColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const @@ -23,7 +22,7 @@ BitmapEx BitmapSimpleColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) return BitmapEx(aBitmap); Bitmap aNewBmp; - Bitmap::ScopedReadAccess pRAcc(aBitmap); + BitmapScopedReadAccess pRAcc(aBitmap); if (!pRAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx index 043f9ad12fee..c1c6822757ac 100644 --- a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx +++ b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx @@ -13,8 +13,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapSobelGreyFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <algorithm> @@ -25,7 +24,7 @@ BitmapEx BitmapSobelGreyFilter::execute(BitmapEx const& rBitmapEx) const if (!aBitmap.ImplMakeGreyscales()) return BitmapEx(); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); + BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapSolarizeFilter.cxx b/vcl/source/bitmap/BitmapSolarizeFilter.cxx index bfc502fe0ca8..ca2485a7f4e0 100644 --- a/vcl/source/bitmap/BitmapSolarizeFilter.cxx +++ b/vcl/source/bitmap/BitmapSolarizeFilter.cxx @@ -11,8 +11,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapSolarizeFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> BitmapEx BitmapSolarizeFilter::execute(BitmapEx const& rBitmapEx) const { diff --git a/vcl/source/bitmap/BitmapSymmetryCheck.cxx b/vcl/source/bitmap/BitmapSymmetryCheck.cxx index 1bd16e815400..26e035e8dabc 100644 --- a/vcl/source/bitmap/BitmapSymmetryCheck.cxx +++ b/vcl/source/bitmap/BitmapSymmetryCheck.cxx @@ -17,7 +17,7 @@ BitmapSymmetryCheck::BitmapSymmetryCheck() bool BitmapSymmetryCheck::check(Bitmap& rBitmap) { - Bitmap::ScopedReadAccess aReadAccess(rBitmap); + BitmapScopedReadAccess aReadAccess(rBitmap); return checkImpl(aReadAccess.get()); } diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 1b67ea06ac1a..ee0134a90010 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -39,7 +39,7 @@ #include <comphelper/diagnose_ex.hxx> #include <tools/fract.hxx> #include <tools/stream.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> using namespace css; @@ -161,11 +161,11 @@ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHei if( !pWrite ) return BitmapEx(); std::optional<AlphaMask> pAlphaMask; - AlphaScopedWriteAccess xMaskAcc; + BitmapScopedWriteAccess xMaskAcc; if (nBitCount == 32) { pAlphaMask.emplace( Size(nWidth, nHeight) ); - xMaskAcc = AlphaScopedWriteAccess(*pAlphaMask); + xMaskAcc = *pAlphaMask; } if (nBitCount == 1) { @@ -246,11 +246,11 @@ BitmapEx CreateFromData( RawBitmap&& rawBitmap ) if( !pWrite ) return BitmapEx(); std::optional<AlphaMask> pAlphaMask; - AlphaScopedWriteAccess xMaskAcc; + BitmapScopedWriteAccess xMaskAcc; if (nBitCount == 32) { pAlphaMask.emplace( rawBitmap.maSize ); - xMaskAcc = AlphaScopedWriteAccess(*pAlphaMask); + xMaskAcc = *pAlphaMask; } auto nHeight = rawBitmap.maSize.getHeight(); @@ -314,7 +314,7 @@ BitmapEx* CreateFromCairoSurface(Size aSize, cairo_surface_t * pSurface) if (!pRGBWrite) return nullptr; - AlphaScopedWriteAccess pMaskWrite(aMask); + BitmapScopedWriteAccess pMaskWrite(aMask); assert(pMaskWrite); if (!pMaskWrite) return nullptr; @@ -387,14 +387,12 @@ BitmapEx CanvasTransformBitmap( const BitmapEx& rBitmap, aSrcAlpha = rBitmap.GetAlphaMask().GetBitmap(); } - Bitmap::ScopedReadAccess pReadAccess( aSrcBitmap ); - Bitmap::ScopedReadAccess pAlphaReadAccess( rBitmap.IsAlpha() ? - aSrcAlpha.AcquireReadAccess() : - nullptr, - aSrcAlpha ); + BitmapScopedReadAccess pReadAccess( aSrcBitmap ); + BitmapScopedReadAccess pAlphaReadAccess; + if (rBitmap.IsAlpha()) + pAlphaReadAccess = aSrcAlpha; - if( pReadAccess.get() == nullptr || - (pAlphaReadAccess.get() == nullptr && rBitmap.IsAlpha()) ) + if( !pReadAccess || (!pAlphaReadAccess && rBitmap.IsAlpha()) ) { // TODO(E2): Error handling! ENSURE_OR_THROW( false, @@ -527,7 +525,7 @@ void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparen { - AlphaScopedWriteAccess pOld(aOldMask); + BitmapScopedWriteAccess pOld(aOldMask); assert(pOld && "Got no access to old alpha mask (!)"); @@ -551,7 +549,7 @@ void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparen } else { - AlphaMask::ScopedReadAccess pNew(rNewMask); + BitmapScopedReadAccess pNew(rNewMask); assert(pNew && "Got no access to new alpha mask (!)"); @@ -608,8 +606,8 @@ void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBi // need to blend in AlphaMask quality (8Bit) AlphaMask fromVDev(aVDevMask); AlphaMask fromBmpEx(aBmpEx.GetAlphaMask()); - AlphaMask::ScopedReadAccess pR(fromVDev); - AlphaScopedWriteAccess pW(fromBmpEx); + BitmapScopedReadAccess pR(fromVDev); + BitmapScopedWriteAccess pW(fromBmpEx); if(pR && pW) { @@ -707,15 +705,15 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un { AlphaMask aAlpha = aBmpEx.GetAlphaMask(); - ::BitmapReadAccess* pBitmapReadAcc = aBitmap.AcquireReadAccess(); - ::BitmapReadAccess* pAlphaReadAcc = nullptr; + BitmapScopedReadAccess pBitmapReadAcc( aBitmap ); + BitmapScopedReadAccess pAlphaReadAcc; const tools::Long nWidth = rnWidth = pBitmapReadAcc->Width(); const tools::Long nHeight = rnHeight = pBitmapReadAcc->Height(); tools::Long nX, nY; bool bIsAlpha = false; if( aBmpEx.IsAlpha() ) - pAlphaReadAcc = aAlpha.AcquireReadAccess(); + pAlphaReadAcc = aAlpha; data = static_cast<unsigned char*>(malloc( nWidth*nHeight*4 )); @@ -735,7 +733,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un case ScanlineFormat::N8BitPal: pReadScan = pBitmapReadAcc->GetScanline( nY ); if( pAlphaReadAcc ) - if( readAlpha( pAlphaReadAcc, nY, nWidth, data, nOff ) ) + if( readAlpha( pAlphaReadAcc.get(), nY, nWidth, data, nOff ) ) bIsAlpha = true; for( nX = 0; nX < nWidth; nX++ ) @@ -780,7 +778,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un case ScanlineFormat::N24BitTcBgr: pReadScan = pBitmapReadAcc->GetScanline( nY ); if( pAlphaReadAcc ) - if( readAlpha( pAlphaReadAcc, nY, nWidth, data, nOff ) ) + if( readAlpha( pAlphaReadAcc.get(), nY, nWidth, data, nOff ) ) bIsAlpha = true; for( nX = 0; nX < nWidth; nX++ ) @@ -821,7 +819,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un case ScanlineFormat::N24BitTcRgb: pReadScan = pBitmapReadAcc->GetScanline( nY ); if( pAlphaReadAcc ) - if( readAlpha( pAlphaReadAcc, nY, nWidth, data, nOff ) ) + if( readAlpha( pAlphaReadAcc.get(), nY, nWidth, data, nOff ) ) bIsAlpha = true; for( nX = 0; nX < nWidth; nX++ ) @@ -862,7 +860,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un case ScanlineFormat::N32BitTcBgra: pReadScan = pBitmapReadAcc->GetScanline( nY ); if( pAlphaReadAcc ) - if( readAlpha( pAlphaReadAcc, nY, nWidth, data, nOff ) ) + if( readAlpha( pAlphaReadAcc.get(), nY, nWidth, data, nOff ) ) bIsAlpha = true; for( nX = 0; nX < nWidth; nX++ ) @@ -904,7 +902,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un case ScanlineFormat::N32BitTcRgba: pReadScan = pBitmapReadAcc->GetScanline( nY ); if( pAlphaReadAcc ) - if( readAlpha( pAlphaReadAcc, nY, nWidth, data, nOff ) ) + if( readAlpha( pAlphaReadAcc.get(), nY, nWidth, data, nOff ) ) bIsAlpha = true; for( nX = 0; nX < nWidth; nX++ ) @@ -947,7 +945,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un SAL_INFO( "canvas.cairo", "fallback to GetColor - slow, format: " << static_cast<int>(pBitmapReadAcc->GetScanlineFormat()) ); if( pAlphaReadAcc ) - if( readAlpha( pAlphaReadAcc, nY, nWidth, data, nOff ) ) + if( readAlpha( pAlphaReadAcc.get(), nY, nWidth, data, nOff ) ) bIsAlpha = true; for( nX = 0; nX < nWidth; nX++ ) @@ -990,10 +988,6 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un } } - ::Bitmap::ReleaseAccess( pBitmapReadAcc ); - if( pAlphaReadAcc ) - ::Bitmap::ReleaseAccess( pAlphaReadAcc ); - bHasAlpha = bIsAlpha; } @@ -1003,10 +997,10 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un Bitmap aBitmap( rBitmapEx.GetBitmap() ); Bitmap aAlpha( rBitmapEx.GetAlphaMask().GetBitmap() ); - Bitmap::ScopedReadAccess pReadAccess( aBitmap ); - Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha.IsEmpty() ? - nullptr : aAlpha.AcquireReadAccess(), - aAlpha ); + BitmapScopedReadAccess pReadAccess( aBitmap ); + BitmapScopedReadAccess pAlphaReadAccess; + if (!aAlpha.IsEmpty()) + pAlphaReadAccess = aAlpha; assert( pReadAccess ); @@ -1095,7 +1089,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un // assumption that any 2-color 1bpp bitmap is a pattern, and so it would // get confused by RGB. Try to detect if this image is really // just two colors and say it's a pattern bitmap if so. - Bitmap::ScopedReadAccess access(aBitmap); + BitmapScopedReadAccess access(aBitmap); o_rBack = access->GetColor(0,0); bool foundSecondColor = false;; for(tools::Long y = 0; y < access->Height(); ++y) @@ -1207,9 +1201,9 @@ bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult) AlphaMask aResultAlpha(aSize); { BitmapScopedWriteAccess pResultBitmapAccess(aResultBitmap); - AlphaScopedWriteAccess pResultAlphaAccess(aResultAlpha); + BitmapScopedWriteAccess pResultAlphaAccess(aResultAlpha); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); for (tools::Long nY = 0; nY < aSize.Height(); ++nY) { diff --git a/vcl/source/bitmap/BitmapWriteAccess.cxx b/vcl/source/bitmap/BitmapWriteAccess.cxx index c6996b26383c..610cb2cc260b 100644 --- a/vcl/source/bitmap/BitmapWriteAccess.cxx +++ b/vcl/source/bitmap/BitmapWriteAccess.cxx @@ -21,7 +21,7 @@ #include <sal/log.hxx> #include <tools/debug.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/bmpfast.hxx> BitmapWriteAccess::BitmapWriteAccess(Bitmap& rBitmap) @@ -29,6 +29,11 @@ BitmapWriteAccess::BitmapWriteAccess(Bitmap& rBitmap) { } +BitmapWriteAccess::BitmapWriteAccess(AlphaMask& rBitmap) + : BitmapReadAccess(rBitmap, BitmapAccessMode::Write) +{ +} + BitmapWriteAccess::~BitmapWriteAccess() {} void BitmapWriteAccess::CopyScanline(tools::Long nY, const BitmapReadAccess& rReadAcc) diff --git a/vcl/source/bitmap/alpha.cxx b/vcl/source/bitmap/alpha.cxx index 2b0d544624b5..634fc3cdd609 100644 --- a/vcl/source/bitmap/alpha.cxx +++ b/vcl/source/bitmap/alpha.cxx @@ -20,7 +20,7 @@ #include <tools/color.hxx> #include <vcl/alpha.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <salinst.hxx> #include <svdata.hxx> #include <salbmp.hxx> @@ -98,8 +98,8 @@ void AlphaMask::BlendWith(const AlphaMask& rOther) assert( maBitmap.HasGreyPalette8Bit() && "alpha bitmap should have greyscale palette" ); return; } - AlphaMask::ScopedReadAccess pOtherAcc(const_cast<AlphaMask&>(rOther)); - AlphaScopedWriteAccess pAcc(*this); + BitmapScopedReadAccess pOtherAcc(rOther); + BitmapScopedWriteAccess pAcc(*this); assert (pOtherAcc && pAcc && pOtherAcc->GetBitCount() == 8 && pAcc->GetBitCount() == 8 && "cannot BlendWith this combination"); if (!(pOtherAcc && pAcc && pOtherAcc->GetBitCount() == 8 && pAcc->GetBitCount() == 8)) { @@ -143,7 +143,7 @@ bool AlphaMask::hasAlpha() const if(IsEmpty()) return false; - ScopedReadAccess pAcc(const_cast<AlphaMask&>(*this)); + BitmapScopedReadAccess pAcc(*this); const tools::Long nHeight(pAcc->Height()); const tools::Long nWidth(pAcc->Width()); @@ -167,8 +167,8 @@ bool AlphaMask::hasAlpha() const bool AlphaMask::AlphaCombineOr(const AlphaMask& rMask) { - ScopedReadAccess pMaskAcc(const_cast<AlphaMask&>(rMask)); - AlphaScopedWriteAccess pAcc(*this); + BitmapScopedReadAccess pMaskAcc(rMask); + BitmapScopedWriteAccess pAcc(*this); if (!pMaskAcc || !pAcc) return false; diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index 0bcd581f62d8..53b30d0b3114 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -40,7 +40,7 @@ #include <bitmap/BitmapScaleConvolutionFilter.hxx> #include <bitmap/BitmapFastScaleFilter.hxx> #include <bitmap/BitmapInterpolateScaleFilter.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/impoctree.hxx> #include <bitmap/Octree.hxx> @@ -275,7 +275,7 @@ bool Bitmap::HasGreyPaletteAny() const { bool bRet = false; - ScopedInfoAccess pIAcc(const_cast<Bitmap&>(*this)); + BitmapScopedInfoAccess pIAcc(*this); if( pIAcc ) { @@ -288,7 +288,7 @@ bool Bitmap::HasGreyPaletteAny() const bool Bitmap::HasGreyPalette8Bit() const { bool bRet = false; - ScopedInfoAccess pIAcc(const_cast<Bitmap&>(*this)); + BitmapScopedInfoAccess pIAcc(*this); if( pIAcc ) { @@ -360,47 +360,6 @@ void Bitmap::ImplSetSalBitmap(const std::shared_ptr<SalBitmap>& xImpBmp) mxSalBmp = xImpBmp; } -BitmapInfoAccess* Bitmap::AcquireInfoAccess() -{ - std::unique_ptr<BitmapInfoAccess> pInfoAccess(new BitmapInfoAccess( *this )); - - if( !*pInfoAccess ) - { - return nullptr; - } - - return pInfoAccess.release(); -} - -BitmapReadAccess* Bitmap::AcquireReadAccess() -{ - std::unique_ptr<BitmapReadAccess> pReadAccess(new BitmapReadAccess( *this )); - - if( !*pReadAccess ) - { - return nullptr; - } - - return pReadAccess.release(); -} - -BitmapWriteAccess* Bitmap::AcquireWriteAccess() -{ - std::unique_ptr<BitmapWriteAccess> pWriteAccess(new BitmapWriteAccess( *this )); - - if( !*pWriteAccess ) - { - return nullptr; - } - - return pWriteAccess.release(); -} - -void Bitmap::ReleaseAccess( BitmapInfoAccess* pBitmapAccess ) -{ - delete pBitmapAccess; -} - bool Bitmap::Crop( const tools::Rectangle& rRectPixel ) { const Size aSizePix( GetSizePixel() ); @@ -411,7 +370,7 @@ bool Bitmap::Crop( const tools::Rectangle& rRectPixel ) if( aRect.IsEmpty() || aSizePix == aRect.GetSize()) return false; - ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); if( !pReadAcc ) return false; @@ -557,7 +516,7 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, if( nNextIndex ) { - ScopedReadAccess pSrcAcc(*pSrc); + BitmapScopedReadAccess pSrcAcc(*pSrc); BitmapScopedWriteAccess pDstAcc(*this); if( pSrcAcc && pDstAcc ) @@ -592,7 +551,7 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, if( aRectSrc.IsEmpty() ) return false; - ScopedReadAccess pReadAcc(*pSrc); + BitmapScopedReadAccess pReadAcc(*pSrc); if( !pReadAcc ) return false; @@ -751,7 +710,7 @@ bool Bitmap::CopyPixel_AlphaOptimized( const tools::Rectangle& rRectDst, const t if( aRectSrc.IsEmpty() ) return false; - ScopedReadAccess pReadAcc(*pSrc); + BitmapScopedReadAccess pReadAcc(*pSrc); if( !pReadAcc ) return false; @@ -787,7 +746,7 @@ bool Bitmap::Expand( sal_Int32 nDX, sal_Int32 nDY, const Color* pInitColor ) const tools::Long nWidth = aSizePixel.Width(); const tools::Long nHeight = aSizePixel.Height(); const Size aNewSize( nWidth + nDX, nHeight + nDY ); - ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); if( !pReadAcc ) return false; @@ -957,7 +916,7 @@ bool Bitmap::Convert( BmpConversion eConversion ) bool Bitmap::ImplMakeGreyscales() { - ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); if( !pReadAcc ) return false; @@ -1062,7 +1021,7 @@ bool Bitmap::ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const * pExtColo { SAL_WARN_IF(ePixelFormat <= getPixelFormat(), "vcl", "New pixel format must be greater!" ); - Bitmap::ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return false; @@ -1144,7 +1103,7 @@ bool Bitmap::ImplConvertDown8BPP(Color const * pExtColor) { SAL_WARN_IF(vcl::PixelFormat::N8_BPP > getPixelFormat(), "vcl", "New pixelformat must be lower ( or equal when pExtColor is set )!"); - Bitmap::ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return false; @@ -1397,7 +1356,7 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const } } -static void shiftColors(sal_Int32* pColorArray, const Bitmap::ScopedReadAccess& pReadAcc) +static void shiftColors(sal_Int32* pColorArray, const BitmapScopedReadAccess& pReadAcc) { Scanline pScanlineRead = pReadAcc->GetScanline(0); // Why always 0? for (tools::Long n = 0; n < pReadAcc->Width(); ++n) @@ -1417,7 +1376,7 @@ bool Bitmap::Dither() if( ( aSize.Width() <= 3 ) || ( aSize.Height() <= 2 ) ) return false; - ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); Bitmap aNewBmp(GetSizePixel(), vcl::PixelFormat::N8_BPP); BitmapScopedWriteAccess pWriteAcc(aNewBmp); if( !pReadAcc || !pWriteAcc ) @@ -1673,7 +1632,7 @@ void Bitmap::RemoveBlendedStartColor( if(0 == nHeight || 0 == nWidth) return; - AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlphaMask)); + BitmapScopedReadAccess pAlphaAcc(rAlphaMask); // inequal sizes of content and alpha, avoid change (maybe assert?) if(pAlphaAcc->Height() != nHeight || pAlphaAcc->Width() != nWidth) diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx index 64c42bec3b44..fa1e8486c2e3 100644 --- a/vcl/source/bitmap/bitmappaint.cxx +++ b/vcl/source/bitmap/bitmappaint.cxx @@ -23,7 +23,7 @@ #include <vcl/bitmap.hxx> #include <vcl/alpha.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <salbmp.hxx> #include <svdata.hxx> #include <salinst.hxx> @@ -323,7 +323,7 @@ bool Bitmap::Rotate(Degree10 nAngle10, const Color& rFillColor) if (nAngle10 == 1800_deg10) return Mirror(BmpMirrorFlags::Horizontal | BmpMirrorFlags::Vertical); - ScopedReadAccess pReadAcc(*this); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return false; @@ -459,7 +459,7 @@ bool Bitmap::Rotate(Degree10 nAngle10, const Color& rFillColor) Bitmap Bitmap::CreateMask(const Color& rTransColor) const { - ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return Bitmap(); @@ -551,7 +551,7 @@ Bitmap Bitmap::CreateMask(const Color& rTransColor, sal_uInt8 nTol) const if (nTol == 0) return CreateMask(rTransColor); - ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return Bitmap(); @@ -642,7 +642,7 @@ Bitmap Bitmap::CreateMask(const Color& rTransColor, sal_uInt8 nTol) const AlphaMask Bitmap::CreateAlphaMask(const Color& rTransColor) const { - ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return AlphaMask(); @@ -660,7 +660,7 @@ AlphaMask Bitmap::CreateAlphaMask(const Color& rTransColor) const } AlphaMask aNewBmp(GetSizePixel()); - AlphaMask::ScopedWriteAccess pWriteAcc(aNewBmp); + BitmapScopedWriteAccess pWriteAcc(aNewBmp); if (!pWriteAcc) return AlphaMask(); @@ -720,7 +720,7 @@ AlphaMask Bitmap::CreateAlphaMask(const Color& rTransColor, sal_uInt8 nTol) cons if (nTol == 0) return CreateAlphaMask(rTransColor); - ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); + BitmapScopedReadAccess pReadAcc(*this); if (!pReadAcc) return AlphaMask(); @@ -730,7 +730,7 @@ AlphaMask Bitmap::CreateAlphaMask(const Color& rTransColor, sal_uInt8 nTol) cons // TODO: Possibly remove the 1bpp code later. AlphaMask aNewBmp(GetSizePixel()); - AlphaMask::ScopedWriteAccess pWriteAcc(aNewBmp); + BitmapScopedWriteAccess pWriteAcc(aNewBmp); if (!pWriteAcc) return AlphaMask(); @@ -811,7 +811,7 @@ AlphaMask Bitmap::CreateAlphaMask(const Color& rTransColor, sal_uInt8 nTol) cons vcl::Region Bitmap::CreateRegion(const Color& rColor, const tools::Rectangle& rRect) const { tools::Rectangle aRect(rRect); - ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); + BitmapScopedReadAccess pReadAcc(*this); aRect.Intersection(tools::Rectangle(Point(), GetSizePixel())); aRect.Normalize(); @@ -903,7 +903,7 @@ vcl::Region Bitmap::CreateRegion(const Color& rColor, const tools::Rectangle& rR bool Bitmap::ReplaceMask(const AlphaMask& rMask, const Color& rReplaceColor) { - AlphaMask::ScopedReadAccess pMaskAcc(const_cast<AlphaMask&>(rMask)); + BitmapScopedReadAccess pMaskAcc(rMask); BitmapScopedWriteAccess pAcc(*this); if (!pMaskAcc || !pAcc) @@ -942,8 +942,8 @@ bool Bitmap::ReplaceMask(const AlphaMask& rMask, const Color& rReplaceColor) bool Bitmap::Replace(const AlphaMask& rAlpha, const Color& rMergeColor) { Bitmap aNewBmp(GetSizePixel(), vcl::PixelFormat::N24_BPP); - ScopedReadAccess pAcc(*this); - AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlpha)); + BitmapScopedReadAccess pAcc(*this); + BitmapScopedReadAccess pAlphaAcc(rAlpha); BitmapScopedWriteAccess pNewAcc(aNewBmp); if (!pAcc || !pAlphaAcc || !pNewAcc) @@ -1151,7 +1151,7 @@ bool Bitmap::Blend(const AlphaMask& rAlpha, const Color& rBackgroundColor) if (vcl::isPalettePixelFormat(getPixelFormat())) Convert(BmpConversion::N24Bit); - AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlpha)); + BitmapScopedReadAccess pAlphaAcc(rAlpha); BitmapScopedWriteAccess pAcc(*this); diff --git a/vcl/source/bitmap/bmpfast.cxx b/vcl/source/bitmap/bmpfast.cxx index 356d1a5f9744..53de074adc32 100644 --- a/vcl/source/bitmap/bmpfast.cxx +++ b/vcl/source/bitmap/bmpfast.cxx @@ -19,7 +19,7 @@ #include <vcl/salgtype.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <bitmap/bmpfast.hxx> #include <sal/log.hxx> diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index 6e62191ead0e..4eb15ac2844c 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -33,7 +33,7 @@ #include <unotools/configmgr.hxx> #include <vcl/bitmapex.hxx> #include <vcl/outdev.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <memory> #define DIBCOREHEADERSIZE ( 12UL ) @@ -967,7 +967,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uI const Size aSizePixel(aHeader.nWidth, aHeader.nHeight); AlphaMask aNewBmpAlpha; - AlphaScopedWriteAccess pAccAlpha; + BitmapScopedWriteAccess pAccAlpha; bool bAlphaPossible(pBmpAlpha && aHeader.nBitCount == 32); if (bAlphaPossible) @@ -989,7 +989,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uI if (bAlphaPossible) { aNewBmpAlpha = AlphaMask(aSizePixel); - pAccAlpha = AlphaScopedWriteAccess(aNewBmpAlpha); + pAccAlpha = aNewBmpAlpha; } vcl::PixelFormat ePixelFormat(convertToBPP(aHeader.nBitCount)); @@ -1575,7 +1575,7 @@ bool ImplWriteDIB( if(!aSizePix.Width() || !aSizePix.Height()) return false; - Bitmap::ScopedReadAccess pAcc(const_cast< Bitmap& >(rSource)); + BitmapScopedReadAccess pAcc(rSource); const SvStreamEndian nOldFormat(rOStm.GetEndian()); const sal_uInt64 nOldPos(rOStm.Tell()); @@ -1713,7 +1713,7 @@ bool ReadRawDIB( const int nHeight, const int nStride) { - BitmapScopedWriteAccess pWriteAccess(rTarget.maBitmap.AcquireWriteAccess(), rTarget.maBitmap); + BitmapScopedWriteAccess pWriteAccess(rTarget.maBitmap); for (int nRow = 0; nRow < nHeight; ++nRow) { pWriteAccess->CopyScanline(nRow, pBuf + (nStride * nRow), nFormat, nStride); diff --git a/vcl/source/bitmap/impvect.cxx b/vcl/source/bitmap/impvect.cxx index 81a463727bb3..3f8f8471a6bd 100644 --- a/vcl/source/bitmap/impvect.cxx +++ b/vcl/source/bitmap/impvect.cxx @@ -649,7 +649,7 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, VECT_PROGRESS( pProgress, 0 ); std::optional<Bitmap> xBmp(std::in_place, rColorBmp ); - Bitmap::ScopedReadAccess pRAcc(*xBmp); + BitmapScopedReadAccess pRAcc(*xBmp); if( pRAcc ) { diff --git a/vcl/source/filter/egif/egif.cxx b/vcl/source/filter/egif/egif.cxx index d213c7777178..59ba24cf5ccf 100644 --- a/vcl/source/filter/egif/egif.cxx +++ b/vcl/source/filter/egif/egif.cxx @@ -35,7 +35,7 @@ class GIFWriter { Bitmap aAccBmp; SvStream& m_rGIF; - BitmapReadAccess* m_pAcc; + BitmapScopedReadAccess m_pAcc; sal_uInt32 nMinPercent; sal_uInt32 nMaxPercent; sal_uInt32 nLastPercent; @@ -76,7 +76,6 @@ public: GIFWriter::GIFWriter(SvStream &rStream) : m_rGIF(rStream) - , m_pAcc(nullptr) , nMinPercent(0) , nMaxPercent(0) , nLastPercent(0) @@ -110,7 +109,7 @@ bool GIFWriter::WriteGIF(const Graphic& rGraphic, FilterConfigItem* pFilterConfi bStatus = true; nLastPercent = 0; nInterlaced = 0; - m_pAcc = nullptr; + m_pAcc.reset(); if ( pFilterConfigItem ) nInterlaced = pFilterConfigItem->ReadInt32( "Interlaced", 0 ); @@ -262,7 +261,7 @@ bool GIFWriter::CreateAccess( const BitmapEx& rBmpEx ) else aAccBmp.Convert( BmpConversion::N8BitColors ); - m_pAcc = aAccBmp.AcquireReadAccess(); + m_pAcc = aAccBmp; if( !m_pAcc ) bStatus = false; @@ -274,8 +273,7 @@ bool GIFWriter::CreateAccess( const BitmapEx& rBmpEx ) void GIFWriter::DestroyAccess() { - Bitmap::ReleaseAccess( m_pAcc ); - m_pAcc = nullptr; + m_pAcc.reset(); } diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx index 151ea1f73fc1..88a9df9b8ec0 100644 --- a/vcl/source/filter/eps/eps.cxx +++ b/vcl/source/filter/eps/eps.cxx @@ -474,7 +474,7 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview ) Bitmap aTmpBitmap( pPreview->GetBitmapEx().GetBitmap() ); aTmpBitmap.Scale( aSizeBitmap, BmpScaleFlag::BestQuality ); aTmpBitmap.Convert( BmpConversion::N1BitThreshold ); - BitmapReadAccess* pAcc = aTmpBitmap.AcquireReadAccess(); + BitmapScopedReadAccess pAcc(aTmpBitmap); if ( pAcc ) { mpPS->WriteOString( "%%BeginPreview: " ); // BoundingBox @@ -517,7 +517,7 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview ) nCount2--; } } - Bitmap::ReleaseAccess( pAcc ); + pAcc.reset(); ImplExecMode( PS_RET ); ImplWriteLine( "%%EndPreview" ); } @@ -1725,7 +1725,7 @@ void PSWriter::ImplBmp( Bitmap const * pBitmap, AlphaMask const * pAlphaMaskBitm ImplWriteLine( "eoclip newpath" ); ImplWriteLine( "pom" ); } - BitmapReadAccess* pAcc = aTileBitmap.AcquireReadAccess(); + BitmapScopedReadAccess pAcc(aTileBitmap); if (!bDoTrans ) ImplWriteLine( "pum" ); @@ -1936,7 +1936,7 @@ void PSWriter::ImplBmp( Bitmap const * pBitmap, AlphaMask const * pAlphaMaskBitm else ImplWriteLine( "pom" ); - Bitmap::ReleaseAccess( pAcc ); + pAcc.reset(); nHeightLeft -= nHeight; if ( nHeightLeft ) { diff --git a/vcl/source/filter/etiff/etiff.cxx b/vcl/source/filter/etiff/etiff.cxx index 1f3b2804b497..a6e07c49b32e 100644 --- a/vcl/source/filter/etiff/etiff.cxx +++ b/vcl/source/filter/etiff/etiff.cxx @@ -62,7 +62,7 @@ private: sal_uInt64 mnStreamOfs; bool mbStatus; - BitmapReadAccess* mpAcc; + BitmapScopedReadAccess mpAcc; sal_uInt32 mnWidth, mnHeight, mnColors; sal_uInt32 mnCurAllPictHeight; @@ -117,7 +117,6 @@ TIFFWriter::TIFFWriter(SvStream &rStream) : m_rOStm(rStream) , mnStreamOfs(0) , mbStatus(true) - , mpAcc(nullptr) , mnWidth(0) , mnHeight(0) , mnColors(0) @@ -180,7 +179,7 @@ bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem const * pF mnPalPos = 0; const AnimationFrame& rAnimationFrame = aAnimation.Get( i ); Bitmap aBmp = rAnimationFrame.maBitmapEx.GetBitmap(); - mpAcc = aBmp.AcquireReadAccess(); + mpAcc = aBmp; if ( mpAcc ) { mnBitsPerPixel = vcl::pixelFormatBitCount(aBmp.getPixelFormat()); @@ -209,7 +208,7 @@ bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem const * pF m_rOStm.WriteUInt16( mnTagCount ); m_rOStm.Seek( nCurPos ); - Bitmap::ReleaseAccess( mpAcc ); + mpAcc.reset(); } else mbStatus = false; diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 374645ba9f27..25bcdd201ccd 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -490,7 +490,7 @@ struct GraphicImportContext std::shared_ptr<Graphic> m_pGraphic; /// Write pixel data using this access. std::unique_ptr<BitmapScopedWriteAccess> m_pAccess; - std::unique_ptr<AlphaScopedWriteAccess> m_pAlphaAccess; + std::unique_ptr<BitmapScopedWriteAccess> m_pAlphaAccess; // Need to have an AlphaMask instance to keep its lifetime. AlphaMask mAlphaMask; /// Signals if import finished correctly. @@ -613,7 +613,7 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra // a temporary, and direct access to the Bitmap wouldn't work // with AlphaScopedBitmapAccess. *sigh* rContext.mAlphaMask = rBitmapEx.GetAlphaMask(); - rContext.m_pAlphaAccess = std::make_unique<AlphaScopedWriteAccess>(rContext.mAlphaMask); + rContext.m_pAlphaAccess = std::make_unique<BitmapScopedWriteAccess>(rContext.mAlphaMask); } rContext.m_pStream->Seek(rContext.m_nStreamBegin); if (bThreads) diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index cac966c665f4..8f56edaee77f 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -22,7 +22,7 @@ #include "decode.hxx" #include "gifread.hxx" #include <memory> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <graphic/GraphicReader.hxx> #define NO_PENDING( rStm ) ( ( rStm ).GetError() != ERRCODE_IO_PENDING ) @@ -226,7 +226,7 @@ void GIFReader::CreateBitmaps(tools::Long nWidth, tools::Long nHeight, BitmapPal if (!aAnimation.Count()) aBmp1.Erase(aWhite); - pAcc1 = BitmapScopedWriteAccess(aBmp1); + pAcc1 = aBmp1; if (pAcc1) { @@ -248,7 +248,7 @@ void GIFReader::CreateBitmaps(tools::Long nWidth, tools::Long nHeight, BitmapPal else aBmp8.Erase(COL_WHITE); - pAcc8 = BitmapScopedWriteAccess(aBmp8); + pAcc8 = aBmp8; bStatus = bool(pAcc8); } } @@ -729,13 +729,13 @@ Graphic GIFReader::GetIntermediateGraphic() pAcc1.reset(); aImGraphic = BitmapEx( aBmp8, aBmp1 ); - pAcc1 = BitmapScopedWriteAccess(aBmp1); + pAcc1 = aBmp1; bStatus = bStatus && pAcc1; } else aImGraphic = BitmapEx(aBmp8); - pAcc8 = BitmapScopedWriteAccess(aBmp8); + pAcc8 = aBmp8; bStatus = bStatus && pAcc8; } diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index a75a432b52b4..ac4bceaf45d3 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -12,7 +12,7 @@ #include <pdf/PdfConfig.hxx> #include <vcl/graph.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/datetime.hxx> #include <tools/UnitConversion.hxx> @@ -92,7 +92,7 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r AlphaMask aMask(Size(nPageWidth, nPageHeight)); { BitmapScopedWriteAccess pWriteAccess(aBitmap); - AlphaScopedWriteAccess pMaskAccess(aMask); + BitmapScopedWriteAccess pMaskAccess(aMask); ConstScanline pPdfBuffer = pPdfBitmap->getBuffer(); const int nStride = pPdfBitmap->getStride(); std::vector<sal_uInt8> aScanlineAlpha(nPageWidth); diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx index acd9e6d8e1ae..741be4c5c1d1 100644 --- a/vcl/source/filter/itiff/itiff.cxx +++ b/vcl/source/filter/itiff/itiff.cxx @@ -24,7 +24,7 @@ #include <vcl/graph.hxx> #include <vcl/BitmapTools.hxx> #include <vcl/animate/Animation.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <tools/fract.hxx> #include <tools/stream.hxx> #include <unotools/configmgr.hxx> @@ -242,7 +242,7 @@ bool ImportTiffGraphicImport(SvStream& rTIFF, Graphic& rGraphic) } AlphaMask bitmapAlpha(Size(w, h)); - AlphaScopedWriteAccess accessAlpha(bitmapAlpha); + BitmapScopedWriteAccess accessAlpha(bitmapAlpha); if (!accessAlpha) { SAL_WARN("filter.tiff", "cannot create alpha " << w << " x " << h); diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 7546d44f8681..ceb942d20392 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -23,7 +23,7 @@ #include <rtl/character.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <graphic/GraphicReader.hxx> #include "xbmread.hxx" @@ -331,7 +331,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic ) if ( bStatus && nWidth && nHeight ) { aBmp1 = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); - pAcc1 = BitmapScopedWriteAccess(aBmp1); + pAcc1 = aBmp1; if( pAcc1 ) { diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx index a678f2316ad3..918a75d5a7fb 100644 --- a/vcl/source/filter/ixpm/xpmread.cxx +++ b/vcl/source/filter/ixpm/xpmread.cxx @@ -22,7 +22,7 @@ #include <vcl/graph.hxx> #include <tools/stream.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <graphic/GraphicReader.hxx> #include "rgbtable.hxx" @@ -201,13 +201,13 @@ ReadState XPMReader::ReadXPM( Graphic& rGraphic ) ePixelFormat = vcl::PixelFormat::N8_BPP; maBmp = Bitmap(Size(mnWidth, mnHeight), ePixelFormat); - mpAcc = BitmapScopedWriteAccess(maBmp); + mpAcc = maBmp; // mbTransparent is TRUE if at least one colour is transparent if ( mbTransparent ) { maMaskBmp = Bitmap(Size(mnWidth, mnHeight), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); - mpMaskAcc = BitmapScopedWriteAccess(maMaskBmp); + mpMaskAcc = maMaskBmp; if ( !mpMaskAcc ) mbStatus = false; } diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index d985bbf215e7..186105603904 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -260,7 +260,7 @@ Graphic JPEGReader::CreateIntermediateGraphic(tools::Long nLines) if (nNewLines > 0) { { - AlphaMask::ScopedWriteAccess pAccess(*mpIncompleteAlpha); + BitmapScopedWriteAccess pAccess(*mpIncompleteAlpha); pAccess->SetFillColor(COL_ALPHA_OPAQUE); pAccess->FillRect(tools::Rectangle(Point(0, mnLastLines), Size(pAccess->Width(), nNewLines))); } diff --git a/vcl/source/filter/jpeg/JpegReader.hxx b/vcl/source/filter/jpeg/JpegReader.hxx index 576027237ab8..6282cb4ed069 100644 --- a/vcl/source/filter/jpeg/JpegReader.hxx +++ b/vcl/source/filter/jpeg/JpegReader.hxx @@ -22,7 +22,7 @@ #include <vcl/graph.hxx> #include <vcl/bitmap.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <graphic/GraphicReader.hxx> enum class GraphicFilterImportFlags; diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx index cc2dbf0a0374..ae644884c1f0 100644 --- a/vcl/source/filter/jpeg/JpegWriter.cxx +++ b/vcl/source/filter/jpeg/JpegWriter.cxx @@ -212,7 +212,7 @@ bool JPEGWriter::Write( const Graphic& rGraphic ) aGraphicBmp = rGraphic.GetBitmapEx().GetBitmap(); } - mpReadAccess = Bitmap::ScopedReadAccess(aGraphicBmp); + mpReadAccess = aGraphicBmp; if( mpReadAccess ) { if ( !mbGreys ) // bitmap was not explicitly converted into greyscale, diff --git a/vcl/source/filter/jpeg/JpegWriter.hxx b/vcl/source/filter/jpeg/JpegWriter.hxx index 3159d06ab642..a48d06bd2661 100644 --- a/vcl/source/filter/jpeg/JpegWriter.hxx +++ b/vcl/source/filter/jpeg/JpegWriter.hxx @@ -30,7 +30,7 @@ class JPEGWriter final { SvStream& mrStream; - Bitmap::ScopedReadAccess mpReadAccess; + BitmapScopedReadAccess mpReadAccess; sal_uInt8* mpBuffer; bool mbNative; bool mbGreys; diff --git a/vcl/source/filter/jpeg/jpeg.h b/vcl/source/filter/jpeg/jpeg.h index 2cf600bb6de4..0ab27fb2fb9c 100644 --- a/vcl/source/filter/jpeg/jpeg.h +++ b/vcl/source/filter/jpeg/jpeg.h @@ -23,7 +23,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <basegfx/vector/b2dsize.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <jpeglib.h> diff --git a/vcl/source/filter/jpeg/jpeg.hxx b/vcl/source/filter/jpeg/jpeg.hxx index 1ef39f97903c..f3991dd999ce 100644 --- a/vcl/source/filter/jpeg/jpeg.hxx +++ b/vcl/source/filter/jpeg/jpeg.hxx @@ -21,8 +21,7 @@ #include <vcl/graph.hxx> #include <vcl/graphicfilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <com/sun/star/uno/Sequence.h> diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx index d29c0b90c473..d6a5a219c5e2 100644 --- a/vcl/source/filter/png/PngImageReader.cxx +++ b/vcl/source/filter/png/PngImageReader.cxx @@ -18,8 +18,8 @@ #include <unotools/configmgr.hxx> #include <comphelper/scopeguard.hxx> #include <osl/endian.h> +#include <vcl/BitmapWriteAccess.hxx> -#include <bitmap/BitmapWriteAccess.hxx> #include <svdata.hxx> #include <salinst.hxx> @@ -325,7 +325,7 @@ bool fcTLbeforeIDAT(SvStream& rStream) bool reader(SvStream& rStream, Graphic& rGraphic, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE, BitmapScopedWriteAccess* pAccess = nullptr, - AlphaScopedWriteAccess* pAlphaAccess = nullptr) + BitmapScopedWriteAccess* pAlphaAccess = nullptr) { if (!isPng(rStream)) return false; @@ -356,7 +356,7 @@ bool reader(SvStream& rStream, Graphic& rGraphic, AlphaMask aBitmapAlpha; Size prefSize; BitmapScopedWriteAccess pWriteAccessInstance; - AlphaScopedWriteAccess pWriteAccessAlphaInstance; + BitmapScopedWriteAccess pWriteAccessAlphaInstance; const bool bFuzzing = utl::ConfigManager::IsFuzzing(); const bool bSupportsBitmap32 = bFuzzing || ImplGetSVData()->mpDefInst->supportsBitmap32(); const bool bOnlyCreateBitmap @@ -503,18 +503,18 @@ bool reader(SvStream& rStream, Graphic& rGraphic, return true; } - pWriteAccessInstance = BitmapScopedWriteAccess(aBitmap); + pWriteAccessInstance = aBitmap; if (!pWriteAccessInstance) return false; if (!aBitmapAlpha.IsEmpty()) { - pWriteAccessAlphaInstance = AlphaScopedWriteAccess(aBitmapAlpha); + pWriteAccessAlphaInstance = aBitmapAlpha; if (!pWriteAccessAlphaInstance) return false; } } BitmapScopedWriteAccess& pWriteAccess = pAccess ? *pAccess : pWriteAccessInstance; - AlphaScopedWriteAccess& pWriteAccessAlpha + BitmapScopedWriteAccess& pWriteAccessAlpha = pAlphaAccess ? *pAlphaAccess : pWriteAccessAlphaInstance; if (colorType == PNG_COLOR_TYPE_RGB) @@ -856,7 +856,7 @@ BinaryDataContainer PngImageReader::getMicrosoftGifChunk(SvStream& rStream) } bool ImportPNG(SvStream& rInputStream, Graphic& rGraphic, GraphicFilterImportFlags nImportFlags, - BitmapScopedWriteAccess* pAccess, AlphaScopedWriteAccess* pAlphaAccess) + BitmapScopedWriteAccess* pAccess, BitmapScopedWriteAccess* pAlphaAccess) { // Creating empty bitmaps should be practically a no-op, and thus thread-safe. Graphic aGraphic; diff --git a/vcl/source/filter/png/PngImageWriter.cxx b/vcl/source/filter/png/PngImageWriter.cxx index 6a4bf6340a83..584487fabdd5 100644 --- a/vcl/source/filter/png/PngImageWriter.cxx +++ b/vcl/source/filter/png/PngImageWriter.cxx @@ -9,7 +9,7 @@ #include <vcl/filter/PngImageWriter.hxx> #include <png.h> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapTools.hxx> @@ -161,8 +161,8 @@ static bool pngWrite(SvStream& rStream, const Graphic& rGraphic, int nCompressio Bitmap aBitmap; AlphaMask aAlphaMask; - Bitmap::ScopedReadAccess pAccess; - AlphaMask::ScopedReadAccess pAlphaAccess; + BitmapScopedReadAccess pAccess; + BitmapScopedReadAccess pAlphaAccess; if (setjmp(png_jmpbuf(pPng))) { @@ -181,9 +181,9 @@ static bool pngWrite(SvStream& rStream, const Graphic& rGraphic, int nCompressio { bool bCombineChannels = false; - pAccess = Bitmap::ScopedReadAccess(aBitmap); + pAccess = aBitmap; if (bTranslucent) - pAlphaAccess = AlphaMask::ScopedReadAccess(aAlphaMask); + pAlphaAccess = aAlphaMask; Size aSize = aBitmapEx.GetSizePixel(); int bitDepth = -1; diff --git a/vcl/source/filter/png/png.hxx b/vcl/source/filter/png/png.hxx index b3a1b7b17b1a..01d5cf9f4a8b 100644 --- a/vcl/source/filter/png/png.hxx +++ b/vcl/source/filter/png/png.hxx @@ -21,13 +21,12 @@ #include <vcl/graph.hxx> #include <vcl/graphicfilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> namespace vcl { bool ImportPNG(SvStream& rInputStream, Graphic& rGraphic, GraphicFilterImportFlags nImportFlags, - BitmapScopedWriteAccess* pAccess, AlphaScopedWriteAccess* pAlphaAccess); + BitmapScopedWriteAccess* pAccess, BitmapScopedWriteAccess* pAlphaAccess); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/webp/reader.cxx b/vcl/source/filter/webp/reader.cxx index 3c0b1399cad2..1d75ff79e8d1 100644 --- a/vcl/source/filter/webp/reader.cxx +++ b/vcl/source/filter/webp/reader.cxx @@ -21,7 +21,7 @@ #include <vcl/graph.hxx> #include <tools/stream.hxx> #include <filter/WebpReader.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <salinst.hxx> #include <sal/log.hxx> #include <unotools/configmgr.hxx> @@ -232,7 +232,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic) case PixelMode::Split: { // Split to normal and alpha bitmaps. - AlphaScopedWriteAccess accessAlpha(bitmapAlpha); + BitmapScopedWriteAccess accessAlpha(bitmapAlpha); for (tools::Long y = 0; y < access->Height(); ++y) { const unsigned char* src = tmpRgbaData.data() + width * 4 * y; @@ -266,7 +266,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic) } if (!bitmapAlpha.IsEmpty()) { - AlphaScopedWriteAccess accessAlpha(bitmapAlpha); + BitmapScopedWriteAccess accessAlpha(bitmapAlpha); for (tools::Long y = 0; y < accessAlpha->Height(); ++y) { const unsigned char* src = tmpRgbaData.data() + width * 4 * y; diff --git a/vcl/source/filter/webp/writer.cxx b/vcl/source/filter/webp/writer.cxx index ac993a041b06..c5249b5adf41 100644 --- a/vcl/source/filter/webp/writer.cxx +++ b/vcl/source/filter/webp/writer.cxx @@ -96,8 +96,8 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& bitmapEx, bool lossless AlphaMask bitmapAlpha; if (bitmapEx.IsAlpha()) bitmapAlpha = bitmapEx.GetAlphaMask(); - Bitmap::ScopedReadAccess access(bitmap); - AlphaMask::ScopedReadAccess accessAlpha(bitmapAlpha); + BitmapScopedReadAccess access(bitmap); + BitmapScopedReadAccess accessAlpha(bitmapAlpha); bool dataDone = false; if (!access->IsBottomUp() && bitmapAlpha.IsEmpty()) { diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index a5e0a716c5af..e6b1adc80eac 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -599,7 +599,7 @@ void writeBitmapContentChecksum(tools::XmlWriter& rWriter, Bitmap const& rBitmap Bitmap aBitmap(rBitmap); comphelper::Hash aHashEngine(comphelper::HashType::SHA1); - Bitmap::ScopedReadAccess pReadAccess(aBitmap); + BitmapScopedReadAccess pReadAccess(aBitmap); assert(pReadAccess); for (tools::Long y = 0 ; y < pReadAccess->Height() ; ++y) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index cdf10ab30585..c7ef07ff49cb 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -82,7 +82,7 @@ #include <comphelper/hash.hxx> #include <svdata.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <fontsubset.hxx> #include <font/EmphasisMark.hxx> #include <font/PhysicalFontFace.hxx> @@ -8796,7 +8796,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aDev->DrawGradient( tools::Rectangle( Point( 0, 0 ), rObject.m_aSize ), rObject.m_aGradient ); Bitmap aSample = aDev->GetBitmap( Point( 0, 0 ), rObject.m_aSize ); - Bitmap::ScopedReadAccess pAccess(aSample); + BitmapScopedReadAccess pAccess(aSample); Size aSize = aSample.GetSizePixel(); @@ -9454,7 +9454,7 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject, bool bMask ) } } - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); bool bTrueColor = true; sal_Int32 nBitsPerComponent = 0; diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx index 67e14d4ee9b2..f2e0f7889cb2 100644 --- a/vcl/source/helper/canvasbitmap.cxx +++ b/vcl/source/helper/canvasbitmap.cxx @@ -94,7 +94,7 @@ void VclCanvasBitmap::setComponentInfo( sal_uInt32 redShift, sal_uInt32 greenShi pCounts[bluePos] = bitcount(blueShift); } -Bitmap::ScopedReadAccess& VclCanvasBitmap::getBitmapReadAccess() +BitmapScopedReadAccess& VclCanvasBitmap::getBitmapReadAccess() { // BitmapReadAccess is more expensive than BitmapInfoAccess, // as the latter requires also pixels, which may need converted @@ -105,7 +105,7 @@ Bitmap::ScopedReadAccess& VclCanvasBitmap::getBitmapReadAccess() return *m_pBmpReadAcc; } -Bitmap::ScopedReadAccess& VclCanvasBitmap::getAlphaReadAccess() +BitmapScopedReadAccess& VclCanvasBitmap::getAlphaReadAccess() { if(!m_pAlphaReadAcc) m_pAlphaReadAcc.emplace(m_aAlpha); @@ -128,7 +128,7 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) : if( m_aBmpEx.IsAlpha() ) { m_aAlpha = m_aBmpEx.GetAlphaMask().GetBitmap(); - m_pAlphaAcc = Bitmap::ScopedInfoAccess(m_aAlpha); + m_pAlphaAcc = m_aAlpha; } m_aLayout.ScanLines = 0; @@ -403,7 +403,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB if( !m_aBmpEx.IsAlpha() ) { - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); OSL_ENSURE(pBmpAcc,"Invalid bmp read access"); // can return bitmap data as-is @@ -416,8 +416,8 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB } else { - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); - Bitmap::ScopedReadAccess& pAlphaAcc = getAlphaReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pAlphaAcc = getAlphaReadAccess(); OSL_ENSURE(pBmpAcc,"Invalid bmp read access"); OSL_ENSURE(pAlphaAcc,"Invalid alpha read access"); @@ -496,7 +496,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer const tools::Long nScanlineLeftOffset( pos.X*m_nBitsPerInputPixel/8 ); if( !m_aBmpEx.IsAlpha() ) { - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); assert(pBmpAcc && "Invalid bmp read access"); // can return bitmap data as-is @@ -505,8 +505,8 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer } else { - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); - Bitmap::ScopedReadAccess& pAlphaAcc = getAlphaReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pAlphaAcc = getAlphaReadAccess(); assert(pBmpAcc && "Invalid bmp read access"); assert(pAlphaAcc && "Invalid alpha read access"); @@ -1038,7 +1038,7 @@ uno::Sequence<rendering::RGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToRGB uno::Sequence< rendering::RGBColor > aRes(nNumColors); rendering::RGBColor* pOut( aRes.getArray() ); - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); ENSURE_OR_THROW(pBmpAcc, "Unable to get BitmapAccess"); @@ -1091,7 +1091,7 @@ uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToAR uno::Sequence< rendering::ARGBColor > aRes(nNumColors); rendering::ARGBColor* pOut( aRes.getArray() ); - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); ENSURE_OR_THROW(pBmpAcc, "Unable to get BitmapAccess"); @@ -1146,7 +1146,7 @@ uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToPA uno::Sequence< rendering::ARGBColor > aRes(nNumColors); rendering::ARGBColor* pOut( aRes.getArray() ); - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); ENSURE_OR_THROW(pBmpAcc, "Unable to get BitmapAccess"); @@ -1200,7 +1200,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromRGB( con uno::Sequence< sal_Int8 > aRes(nNumBytes); sal_uInt8* pColors=reinterpret_cast<sal_uInt8*>(aRes.getArray()); - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); if( m_aBmpEx.IsAlpha() ) { @@ -1250,7 +1250,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromARGB( co uno::Sequence< sal_Int8 > aRes(nNumBytes); sal_uInt8* pColors=reinterpret_cast<sal_uInt8*>(aRes.getArray()); - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); if( m_aBmpEx.IsAlpha() ) { @@ -1300,7 +1300,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromPARGB( c uno::Sequence< sal_Int8 > aRes(nNumBytes); sal_uInt8* pColors=reinterpret_cast<sal_uInt8*>(aRes.getArray()); - Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess(); + BitmapScopedReadAccess& pBmpAcc = getBitmapReadAccess(); if( m_aBmpEx.IsAlpha() ) { diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx index c0e783f9f508..1e1b2bdd2ddf 100644 --- a/vcl/source/helper/canvastools.cxx +++ b/vcl/source/helper/canvastools.cxx @@ -43,7 +43,7 @@ #include <canvasbitmap.hxx> #include <vcl/canvastools.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> using namespace ::com::sun::star; @@ -283,8 +283,9 @@ namespace vcl::unotools { // limit scoped access BitmapScopedWriteAccess pWriteAccess( aBitmap ); - BitmapScopedWriteAccess pAlphaWriteAccess( nAlphaDepth ? aAlpha.AcquireWriteAccess() : nullptr, - aAlpha ); + BitmapScopedWriteAccess pAlphaWriteAccess; + if (nAlphaDepth) + pAlphaWriteAccess = aAlpha; ENSURE_OR_THROW(pWriteAccess.get() != nullptr, "Cannot get write access to bitmap"); diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index daf0ddf72162..c944426b75f7 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -35,7 +35,7 @@ #include <vcl/opengl/OpenGLWrapper.hxx> #include <vcl/opengl/OpenGLContext.hxx> #include <desktop/crashreport.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <watchdog.hxx> #include <vcl/skia/SkiaHelper.hxx> #include <salinst.hxx> @@ -558,7 +558,7 @@ BitmapEx OpenGLHelper::ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, t { BitmapScopedWriteAccess pWriteAccess( aBitmap ); - AlphaScopedWriteAccess pAlphaWriteAccess( aAlpha ); + BitmapScopedWriteAccess pAlphaWriteAccess( aAlpha ); #ifdef _WIN32 assert(pWriteAccess->GetScanlineFormat() == ScanlineFormat::N24BitTcBgr); assert(pWriteAccess->IsTopDown()); diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 9df1ba41ae8c..c6855909d312 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -27,8 +27,8 @@ #include <vcl/metaact.hxx> #include <vcl/skia/SkiaHelper.hxx> #include <vcl/virdev.hxx> +#include <vcl/BitmapWriteAccess.hxx> -#include <bitmap/BitmapWriteAccess.hxx> #include <bitmap/bmpfast.hxx> #include <drawmode.hxx> #include <salbmp.hxx> @@ -650,8 +650,8 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, TradScaleContext aTradContext(aDstRect, aBmpRect, aOutSize, nOffX, nOffY); - Bitmap::ScopedReadAccess pBitmapReadAccess(const_cast<Bitmap&>(rBitmap)); - AlphaMask::ScopedReadAccess pAlphaReadAccess(const_cast<AlphaMask&>(rAlpha)); + BitmapScopedReadAccess pBitmapReadAccess(rBitmap); + BitmapScopedReadAccess pAlphaReadAccess(rAlpha); DBG_ASSERT( pAlphaReadAccess->GetScanlineFormat() == ScanlineFormat::N8BitPal, "OutputDevice::ImplDrawAlpha(): non-8bit alpha no longer supported!" ); @@ -821,7 +821,7 @@ Bitmap OutputDevice::BlendBitmapWithAlpha( { Bitmap aDither(aBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP); BitmapColor aIndex( 0 ); - Bitmap::ScopedReadAccess pB(aBmp); + BitmapScopedReadAccess pB(aBmp); BitmapScopedWriteAccess pW(aDither); if (pB && pP && pA && pW && pAlphaW) @@ -913,7 +913,7 @@ Bitmap OutputDevice::BlendBitmap( { Bitmap aDither(aBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP); BitmapColor aIndex( 0 ); - Bitmap::ScopedReadAccess pB(aBmp); + BitmapScopedReadAccess pB(aBmp); BitmapScopedWriteAccess pW(aDither); for( int nY = 0, nOutY = nOffY; nY < nDstHeight; nY++, nOutY++ ) diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index ce933f9417c7..7588dec55647 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -30,8 +30,7 @@ #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/virdev.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <pdf/pdfwriter_impl.hxx> #include <salgdi.hxx> @@ -359,7 +358,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, if( !aPaint.IsEmpty() && !aPolyMask.IsEmpty() ) { BitmapScopedWriteAccess pW(aPaint); - Bitmap::ScopedReadAccess pR(aPolyMask); + BitmapScopedReadAccess pR(aPolyMask); if( pW && pR ) { diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index c445e5e5ad98..553be738c8f5 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -27,7 +27,7 @@ #include <tools/UnitConversion.hxx> #include <o3tl/string_view.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> using namespace com::sun::star; diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 8d1691ee212d..e3300de34357 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -270,8 +270,8 @@ static void CreateNetWmAppIcon( sal_uInt16 nIcon, NetWmIconData& netwm_icon ) vcl::bitmap::convertBitmap32To24Plus8(aIcon, aIcon); Bitmap icon = aIcon.GetBitmap(); AlphaMask mask = aIcon.GetAlphaMask(); - BitmapReadAccess* iconData = icon.AcquireReadAccess(); - BitmapReadAccess* maskData = mask.AcquireReadAccess(); + BitmapScopedReadAccess iconData(icon); + BitmapScopedReadAccess maskData(mask); netwm_icon[ pos++ ] = size; // width netwm_icon[ pos++ ] = size; // height for( int y = 0; y < size; ++y ) @@ -281,8 +281,6 @@ static void CreateNetWmAppIcon( sal_uInt16 nIcon, NetWmIconData& netwm_icon ) BitmapColor alpha = maskData->GetColor( y, x ); netwm_icon[ pos++ ] = (((( 255 - alpha.GetBlue()) * 256U ) + col.GetRed()) * 256 + col.GetGreen()) * 256 + col.GetBlue(); } - Bitmap::ReleaseAccess( iconData ); - Bitmap::ReleaseAccess( maskData ); } netwm_icon.resize( pos ); } diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx index a969bff5e242..1ecc03835fd8 100644 --- a/vcl/workben/svptest.cxx +++ b/vcl/workben/svptest.cxx @@ -38,7 +38,7 @@ #include <vcl/bitmap.hxx> #include <vcl/metric.hxx> #include <vcl/vclptr.hxx> -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <rtl/ustrbuf.hxx> @@ -110,7 +110,7 @@ MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) : m_aBitmap(Size(256, 256), vcl::PixelFormat::N32_BPP) { // prepare an alpha mask - BitmapWriteAccess* pAcc = m_aBitmap.AcquireWriteAccess(); + BitmapScopedWriteAccess pAcc(m_aBitmap); for( int nX = 0; nX < 256; nX++ ) { for( int nY = 0; nY < 256; nY++ ) @@ -127,7 +127,6 @@ MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) : pAcc->SetPixel( nY, nX, BitmapColor( sal_uInt8(fRed), sal_uInt8(fGreen), sal_uInt8(fBlue) ) ); } } - Bitmap::ReleaseAccess( pAcc ); } static Point project( const Point& rPoint ) diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 2a8a5800bbde..6824b6039360 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -52,8 +52,7 @@ #include <vcl/menu.hxx> #include <vcl/ImageTree.hxx> #include <vcl/BitmapEmbossGreyFilter.hxx> - -#include <bitmap/BitmapWriteAccess.hxx> +#include <vcl/BitmapWriteAccess.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -1307,10 +1306,10 @@ public: AlphaMask aMask(aSrc.GetSizePixel()); Bitmap aRecovered(aSrc.GetSizePixel(), vcl::PixelFormat::N24_BPP); { - AlphaScopedWriteAccess pMaskAcc(aMask); + BitmapScopedWriteAccess pMaskAcc(aMask); BitmapScopedWriteAccess pRecAcc(aRecovered); - Bitmap::ScopedReadAccess pAccW(aWhiteBmp); // a * pix + (1-a) - Bitmap::ScopedReadAccess pAccB(aBlackBmp); // a * pix + 0 + BitmapScopedReadAccess pAccW(aWhiteBmp); // a * pix + (1-a) + BitmapScopedReadAccess pAccB(aBlackBmp); // a * pix + 0 int nSizeX = aSrc.GetSizePixel().Width(); int nSizeY = aSrc.GetSizePixel().Height(); for (int y = 0; y < nSizeY; y++) |