From a214ac677481883d31800bc2b67fd3a9c504319d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 4 Dec 2023 11:17:23 +0200 Subject: [PATCH] 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 --- accessibility/inc/pch/precompiled_acc.hxx | 1 - basctl/inc/pch/precompiled_basctl.hxx | 1 - canvas/qa/cppunit/canvastest.cxx | 4 +- canvas/source/directx/dx_vcltools.cxx | 8 +- canvas/source/vcl/canvashelper.cxx | 2 +- .../inc/pch/precompiled_chartcontroller.hxx | 1 - comphelper/inc/pch/precompiled_comphelper.hxx | 1 - cppcanvas/inc/pch/precompiled_cppcanvas.hxx | 1 - cppcanvas/qa/extras/emfplus/emfplus.cxx | 2 +- cui/inc/pch/precompiled_cui.hxx | 1 - dbaccess/inc/pch/precompiled_dba.hxx | 1 - desktop/inc/pch/precompiled_sofficeapp.hxx | 1 - desktop/source/lib/init.cxx | 4 +- drawinglayer/inc/texture/texture3d.hxx | 5 +- .../qa/unit/vclmetafileprocessor2d.cxx | 2 +- drawinglayer/qa/unit/vclpixelprocessor2d.cxx | 2 +- .../processor2d/cairopixelprocessor2d.cxx | 6 +- .../processor2d/d2dpixelprocessor2d.cxx | 8 +- drawinglayer/source/texture/texture3d.cxx | 4 +- editeng/inc/pch/precompiled_editeng.hxx | 1 - emfio/source/reader/wmfreader.cxx | 2 +- filter/source/msfilter/msdffimp.cxx | 2 +- filter/source/msfilter/svdfppt.cxx | 2 +- forms/source/component/imgprod.cxx | 11 +- framework/inc/pch/precompiled_fwk.hxx | 1 - include/vcl/BitmapInfoAccess.hxx | 52 +++++++- include/vcl/BitmapReadAccess.hxx | 51 +++++++- .../vcl}/BitmapWriteAccess.hxx | 54 ++++++-- include/vcl/alpha.hxx | 9 -- include/vcl/bitmap.hxx | 11 -- include/vcl/scopedbitmapaccess.hxx | 123 ------------------ reportdesign/inc/pch/precompiled_rpt.hxx | 1 - reportdesign/inc/pch/precompiled_rptui.hxx | 1 - sc/inc/pch/precompiled_sc.hxx | 1 - sc/source/filter/excel/xeescher.cxx | 2 +- sd/inc/pch/precompiled_sdui.hxx | 1 - sd/qa/unit/PNGExportTests.cxx | 30 ++--- sd/qa/unit/import-tests2.cxx | 2 +- sd/qa/unit/tiledrendering/tiledrendering.cxx | 2 +- sd/source/ui/dlg/vectdlg.cxx | 2 +- slideshow/inc/pch/precompiled_slideshow.hxx | 1 - solenv/clang-format/excludelist | 1 - svtools/inc/pch/precompiled_svt.hxx | 1 - svx/inc/pch/precompiled_svxcore.hxx | 1 - svx/qa/unit/customshapes.cxx | 8 +- svx/source/svdraw/svdetc.cxx | 2 +- sw/inc/pch/precompiled_msword.hxx | 1 - sw/inc/pch/precompiled_swui.hxx | 1 - sw/inc/pch/precompiled_vbaswobj.hxx | 1 - sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 2 +- .../extras/tiledrendering/tiledrendering.cxx | 16 +-- vbahelper/inc/pch/precompiled_msforms.hxx | 1 - vcl/backendtest/outputdevice/bitmap.cxx | 6 +- vcl/backendtest/outputdevice/common.cxx | 2 +- vcl/inc/canvasbitmap.hxx | 13 +- vcl/inc/pch/precompiled_vcl.hxx | 2 +- vcl/qa/cppunit/BackendTest.cxx | 6 +- vcl/qa/cppunit/BitmapExTest.cxx | 28 ++-- vcl/qa/cppunit/BitmapFilterTest.cxx | 4 +- vcl/qa/cppunit/BitmapProcessorTest.cxx | 10 +- vcl/qa/cppunit/BitmapScaleTest.cxx | 4 +- vcl/qa/cppunit/BitmapTest.cxx | 18 +-- vcl/qa/cppunit/GraphicTest.cxx | 2 +- .../cppunit/bitmaprender/BitmapRenderTest.cxx | 2 +- vcl/qa/cppunit/canvasbitmaptest.cxx | 20 +-- vcl/qa/cppunit/cjktext.cxx | 4 +- vcl/qa/cppunit/drawmode.cxx | 6 +- vcl/qa/cppunit/gen/gen.cxx | 4 +- vcl/qa/cppunit/gradient.cxx | 2 +- .../graphicfilter/filters-tiff-test.cxx | 10 +- .../graphicfilter/filters-webp-test.cxx | 12 +- vcl/qa/cppunit/jpeg/JpegReaderTest.cxx | 4 +- vcl/qa/cppunit/jpeg/JpegWriterTest.cxx | 4 +- vcl/qa/cppunit/outdev.cxx | 16 +-- vcl/qa/cppunit/png/PngFilterTest.cxx | 16 +-- vcl/qa/cppunit/skia/skia.cxx | 14 +- vcl/qa/cppunit/svm/svmtest.cxx | 4 +- vcl/qa/cppunit/text.cxx | 6 +- vcl/source/bitmap/BitmapAlphaClampFilter.cxx | 5 +- .../bitmap/BitmapBasicMorphologyFilter.cxx | 39 +++--- .../bitmap/BitmapColorQuantizationFilter.cxx | 5 +- vcl/source/bitmap/BitmapColorizeFilter.cxx | 2 +- .../bitmap/BitmapConvolutionMatrixFilter.cxx | 5 +- .../bitmap/BitmapDisabledImageFilter.cxx | 4 +- vcl/source/bitmap/BitmapDuoToneFilter.cxx | 5 +- vcl/source/bitmap/BitmapEmbossGreyFilter.cxx | 5 +- vcl/source/bitmap/BitmapEx.cxx | 28 ++-- vcl/source/bitmap/BitmapFastScaleFilter.cxx | 4 +- vcl/source/bitmap/BitmapFilterStackBlur.cxx | 12 +- .../BitmapGaussianSeparableBlurFilter.cxx | 7 +- vcl/source/bitmap/BitmapInfoAccess.cxx | 11 +- .../bitmap/BitmapInterpolateScaleFilter.cxx | 8 +- vcl/source/bitmap/BitmapLightenFilter.cxx | 4 +- vcl/source/bitmap/BitmapMaskToAlphaFilter.cxx | 4 +- vcl/source/bitmap/BitmapMedianFilter.cxx | 5 +- vcl/source/bitmap/BitmapMonochromeFilter.cxx | 5 +- vcl/source/bitmap/BitmapMosaicFilter.cxx | 20 ++- vcl/source/bitmap/BitmapPopArtFilter.cxx | 3 +- vcl/source/bitmap/BitmapReadAccess.cxx | 7 +- .../bitmap/BitmapScaleConvolutionFilter.cxx | 6 +- vcl/source/bitmap/BitmapScaleSuperFilter.cxx | 4 +- .../bitmap/BitmapSeparableUnsharpenFilter.cxx | 7 +- vcl/source/bitmap/BitmapSepiaFilter.cxx | 5 +- vcl/source/bitmap/BitmapShadowFilter.cxx | 3 +- .../BitmapSimpleColorQuantizationFilter.cxx | 5 +- vcl/source/bitmap/BitmapSobelGreyFilter.cxx | 5 +- vcl/source/bitmap/BitmapSolarizeFilter.cxx | 3 +- vcl/source/bitmap/BitmapSymmetryCheck.cxx | 2 +- vcl/source/bitmap/BitmapTools.cxx | 68 +++++----- vcl/source/bitmap/BitmapWriteAccess.cxx | 7 +- vcl/source/bitmap/alpha.cxx | 12 +- vcl/source/bitmap/bitmap.cxx | 69 ++-------- vcl/source/bitmap/bitmappaint.cxx | 26 ++-- vcl/source/bitmap/bmpfast.cxx | 2 +- vcl/source/bitmap/dibtools.cxx | 10 +- vcl/source/bitmap/impvect.cxx | 2 +- vcl/source/filter/egif/egif.cxx | 10 +- vcl/source/filter/eps/eps.cxx | 8 +- vcl/source/filter/etiff/etiff.cxx | 7 +- vcl/source/filter/graphicfilter.cxx | 4 +- vcl/source/filter/igif/gifread.cxx | 10 +- vcl/source/filter/ipdf/pdfread.cxx | 4 +- vcl/source/filter/itiff/itiff.cxx | 4 +- vcl/source/filter/ixbm/xbmread.cxx | 4 +- vcl/source/filter/ixpm/xpmread.cxx | 6 +- vcl/source/filter/jpeg/JpegReader.cxx | 2 +- vcl/source/filter/jpeg/JpegReader.hxx | 2 +- vcl/source/filter/jpeg/JpegWriter.cxx | 2 +- vcl/source/filter/jpeg/JpegWriter.hxx | 2 +- vcl/source/filter/jpeg/jpeg.h | 2 +- vcl/source/filter/jpeg/jpeg.hxx | 3 +- vcl/source/filter/png/PngImageReader.cxx | 14 +- vcl/source/filter/png/PngImageWriter.cxx | 10 +- vcl/source/filter/png/png.hxx | 5 +- vcl/source/filter/webp/reader.cxx | 6 +- vcl/source/filter/webp/writer.cxx | 4 +- vcl/source/gdi/mtfxmldump.cxx | 2 +- vcl/source/gdi/pdfwriter_impl.cxx | 6 +- vcl/source/helper/canvasbitmap.cxx | 30 ++--- vcl/source/helper/canvastools.cxx | 7 +- vcl/source/opengl/OpenGLHelper.cxx | 4 +- vcl/source/outdev/bitmap.cxx | 10 +- vcl/source/outdev/transparent.cxx | 5 +- vcl/source/pdf/PDFiumLibrary.cxx | 2 +- vcl/unx/generic/window/salframe.cxx | 6 +- vcl/workben/svptest.cxx | 5 +- vcl/workben/vcldemo.cxx | 9 +- xmloff/inc/pch/precompiled_xo.hxx | 1 - .../inc/pch/precompiled_xmlsecurity.hxx | 1 - 149 files changed, 587 insertions(+), 705 deletions(-) rename {vcl/inc/bitmap => include/vcl}/BitmapWriteAccess.hxx (67%) delete mode 100644 include/vcl/scopedbitmapaccess.hxx diff --git a/accessibility/inc/pch/precompiled_acc.hxx b/accessibility/inc/pch/precompiled_acc.hxx index 5045b2bf4fab..c9589365ab4b 100644 --- a/accessibility/inc/pch/precompiled_acc.hxx +++ b/accessibility/inc/pch/precompiled_acc.hxx @@ -133,7 +133,6 @@ #include #include #include -#include #include #include #include diff --git a/basctl/inc/pch/precompiled_basctl.hxx b/basctl/inc/pch/precompiled_basctl.hxx index d41ed13289ae..1794f96f90e9 100644 --- a/basctl/inc/pch/precompiled_basctl.hxx +++ b/basctl/inc/pch/precompiled_basctl.hxx @@ -154,7 +154,6 @@ #include #include #include -#include #include #include #include diff --git a/canvas/qa/cppunit/canvastest.cxx b/canvas/qa/cppunit/canvastest.cxx index d4cba860db43..922888b4894a 100644 --- a/canvas/qa/cppunit/canvastest.cxx +++ b/canvas/qa/cppunit/canvastest.cxx @@ -95,7 +95,7 @@ public: mRenderState); exportDevice("test-draw-line.png", mVclDevice); Bitmap bitmap = mVclDevice->GetBitmap(Point(), mVclDevice->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); // Canvas uses AA, which blurs the line, and it cannot be turned off, // so do not check the end points. CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), access->GetPixel(0, 0)); @@ -130,7 +130,7 @@ public: exportDevice("test-tdf134053.png", mVclDevice); Bitmap bitmap = mVclDevice->GetBitmap(Point(), mVclDevice->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); struct Check { tools::Long start; diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx index fb5e5c5e93db..31b05be58e9c 100644 --- a/canvas/source/directx/dx_vcltools.cxx +++ b/canvas/source/directx/dx_vcltools.cxx @@ -100,7 +100,7 @@ namespace dxcanvas::tools { // first of all, ensure that Bitmap contains a DIB, by // acquiring a read access - BitmapReadAccess* pReadAcc = rBmp.AcquireReadAccess(); + BitmapScopedReadAccess pReadAcc(rBmp); // TODO(P2): Acquiring a read access can actually // force a read from VRAM, thus, avoiding this @@ -116,8 +116,6 @@ namespace dxcanvas::tools return drawDIBits( rGraphics, aBmpSysData.pDIB ); } - - Bitmap::ReleaseAccess( pReadAcc ); } } else @@ -156,7 +154,7 @@ namespace dxcanvas::tools Bitmap aBitmap( rBmpEx.GetBitmap() ); - Bitmap::ScopedReadAccess pReadAccess( aBitmap ); + BitmapScopedReadAccess pReadAccess( aBitmap ); const sal_Int32 nWidth( aBmpSize.Width() ); const sal_Int32 nHeight( aBmpSize.Height() ); @@ -167,7 +165,7 @@ namespace dxcanvas::tools Bitmap aAlpha( rBmpEx.GetAlphaMask().GetBitmap() ); - Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha ); + BitmapScopedReadAccess pAlphaReadAccess( aAlpha ); // By convention, the access buffer always has // one of the following formats: diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 0e4dfdbf633f..1e47b02c84fc 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -971,7 +971,7 @@ namespace vclcanvas Bitmap aBitmap( rOutDev.GetBitmapEx(aRect.TopLeft(), aRect.GetSize()).GetBitmap() ); - Bitmap::ScopedReadAccess pReadAccess( aBitmap ); + BitmapScopedReadAccess pReadAccess( aBitmap ); ENSURE_OR_THROW( pReadAccess.get() != nullptr, "Could not acquire read access to OutDev bitmap" ); diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx index 960c99bd1f8d..77745b05373c 100644 --- a/chart2/inc/pch/precompiled_chartcontroller.hxx +++ b/chart2/inc/pch/precompiled_chartcontroller.hxx @@ -145,7 +145,6 @@ #include #include #include -#include #include #include #include diff --git a/comphelper/inc/pch/precompiled_comphelper.hxx b/comphelper/inc/pch/precompiled_comphelper.hxx index caa5b43017f6..897773b473f5 100644 --- a/comphelper/inc/pch/precompiled_comphelper.hxx +++ b/comphelper/inc/pch/precompiled_comphelper.hxx @@ -112,7 +112,6 @@ #include #include #include -#include #include #include #include diff --git a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx index 44c0bb3db4c4..408286c2ac96 100644 --- a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx +++ b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx @@ -77,7 +77,6 @@ #include #include #include -#include #include #endif // PCH_LEVEL >= 2 #if PCH_LEVEL >= 3 diff --git a/cppcanvas/qa/extras/emfplus/emfplus.cxx b/cppcanvas/qa/extras/emfplus/emfplus.cxx index e19508b202d7..21cb7c219e19 100644 --- a/cppcanvas/qa/extras/emfplus/emfplus.cxx +++ b/cppcanvas/qa/extras/emfplus/emfplus.cxx @@ -51,7 +51,7 @@ public: CPPUNIT_TEST_FIXTURE(Test, testFdo77229) { Bitmap aBitmap = load("fdo77229.emf"); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); // The green star was missing. Color aColor(pAccess->GetPixel(284, 280)); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), aColor.GetRed()); diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index 067318ee9790..3655744b08fa 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -145,7 +145,6 @@ #include #include #include -#include #include #include #include diff --git a/dbaccess/inc/pch/precompiled_dba.hxx b/dbaccess/inc/pch/precompiled_dba.hxx index acb731881764..b281a8b51193 100644 --- a/dbaccess/inc/pch/precompiled_dba.hxx +++ b/dbaccess/inc/pch/precompiled_dba.hxx @@ -99,7 +99,6 @@ #include #include #include -#include #include #include #endif // PCH_LEVEL >= 2 diff --git a/desktop/inc/pch/precompiled_sofficeapp.hxx b/desktop/inc/pch/precompiled_sofficeapp.hxx index f39dc60aff16..3635613937e9 100644 --- a/desktop/inc/pch/precompiled_sofficeapp.hxx +++ b/desktop/inc/pch/precompiled_sofficeapp.hxx @@ -107,7 +107,6 @@ #include #include #include -#include #include #include #endif // PCH_LEVEL >= 2 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index fa1c55c09e05..e5aaa66ddb35 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4221,8 +4221,8 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, BitmapEx aBmpEx = pDevice->GetBitmapEx({ 0, 0 }, { nCanvasWidth, nCanvasHeight }); Bitmap aBmp = aBmpEx.GetBitmap(); AlphaMask aAlpha = aBmpEx.GetAlphaMask(); - Bitmap::ScopedReadAccess sraBmp(aBmp); - AlphaMask::ScopedReadAccess sraAlpha(aAlpha); + BitmapScopedReadAccess sraBmp(aBmp); + BitmapScopedReadAccess sraAlpha(aAlpha); assert(sraBmp->Height() == nCanvasHeight); assert(sraBmp->Width() == nCanvasWidth); diff --git a/drawinglayer/inc/texture/texture3d.hxx b/drawinglayer/inc/texture/texture3d.hxx index 88d13ed03b7c..07f4b181b2ad 100644 --- a/drawinglayer/inc/texture/texture3d.hxx +++ b/drawinglayer/inc/texture/texture3d.hxx @@ -21,6 +21,7 @@ #include #include +#include namespace drawinglayer::primitive3d { class HatchTexturePrimitive3D; @@ -53,9 +54,9 @@ namespace drawinglayer::texture protected: BitmapEx maBitmapEx; Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope - Bitmap::ScopedReadAccess mpReadBitmap; + BitmapScopedReadAccess mpReadBitmap; Bitmap maTransparence; - Bitmap::ScopedReadAccess mpReadTransparence; + BitmapScopedReadAccess mpReadTransparence; basegfx::B2DPoint maTopLeft; basegfx::B2DVector maSize; double mfMulX; diff --git a/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx b/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx index 478645cbf5b1..f34ef8a1bb6f 100644 --- a/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx +++ b/drawinglayer/qa/unit/vclmetafileprocessor2d.cxx @@ -133,7 +133,7 @@ public: CPPUNIT_ASSERT(renderer->draw()); exportDevice("test-tdf136957", mVclDevice); Bitmap bitmap = mVclDevice->GetBitmap(Point(), Size(1920, 1080)); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); // There should be a dotted line, without the fix it wouldn't be there, so check // there's a sufficient amount of non-white pixels and that's the line. int nonWhiteCount = 0; diff --git a/drawinglayer/qa/unit/vclpixelprocessor2d.cxx b/drawinglayer/qa/unit/vclpixelprocessor2d.cxx index 4362d3e55f19..c132d0927408 100644 --- a/drawinglayer/qa/unit/vclpixelprocessor2d.cxx +++ b/drawinglayer/qa/unit/vclpixelprocessor2d.cxx @@ -117,7 +117,7 @@ public: exportDevice("test-tdf139000.png", device); Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); - Bitmap::ScopedReadAccess access(bitmap); + BitmapScopedReadAccess access(bitmap); // The upper half should keep its red background color. CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_RED), access->GetColor(Point(0, 99))); // First line of the gradient should not be the start color, but something halfway. diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx index 53261229a0d7..89cb21ddcb74 100644 --- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx @@ -174,8 +174,8 @@ std::vector createBitmapData(const BitmapEx& rBitmapEx) if (bAlpha) { Bitmap aSrcAlpha(rBitmapEx.GetAlphaMask().GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(const_cast(rBitmapEx.GetBitmap())); - Bitmap::ScopedReadAccess pAlphaReadAccess(aSrcAlpha.AcquireReadAccess(), aSrcAlpha); + BitmapScopedReadAccess pReadAccess(rBitmapEx.GetBitmap()); + BitmapScopedReadAccess pAlphaReadAccess(aSrcAlpha); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); @@ -198,7 +198,7 @@ std::vector createBitmapData(const BitmapEx& rBitmapEx) } else { - Bitmap::ScopedReadAccess pReadAccess(const_cast(rBitmapEx.GetBitmap())); + BitmapScopedReadAccess pReadAccess(rBitmapEx.GetBitmap()); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); diff --git a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx index 7671e0c29a05..6bfc95878332 100644 --- a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx @@ -399,8 +399,8 @@ sal::systools::COMReference createB2DBitmap(const BitmapEx& rBitmap if (bAlpha) { Bitmap aSrcAlpha(rBitmapEx.GetAlphaMask().GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(const_cast(rBitmapEx.GetBitmap())); - Bitmap::ScopedReadAccess pAlphaReadAccess(aSrcAlpha.AcquireReadAccess(), aSrcAlpha); + BitmapScopedReadAccess pReadAccess(rBitmapEx.GetBitmap()); + BitmapScopedReadAccess pAlphaReadAccess(aSrcAlpha); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); @@ -421,7 +421,7 @@ sal::systools::COMReference createB2DBitmap(const BitmapEx& rBitmap } else { - Bitmap::ScopedReadAccess pReadAccess(const_cast(rBitmapEx.GetBitmap())); + BitmapScopedReadAccess pReadAccess(const_cast(rBitmapEx.GetBitmap())); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); @@ -1076,7 +1076,7 @@ sal::systools::COMReference D2DPixelProcessor2D::implCreateAlpha_B2 std::unique_ptr aData(new sal_uInt8[nPixelCount]); sal_uInt8* pTarget = aData.get(); Bitmap aSrcAlpha(aAlpha.GetBitmap()); - Bitmap::ScopedReadAccess pReadAccess(aSrcAlpha.AcquireReadAccess(), aSrcAlpha); + BitmapScopedReadAccess pReadAccess(aSrcAlpha); const tools::Long nHeight(pReadAccess->Height()); const tools::Long nWidth(pReadAccess->Width()); diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx index 85870f70cc85..3ee751cbbda4 100644 --- a/drawinglayer/source/texture/texture3d.cxx +++ b/drawinglayer/source/texture/texture3d.cxx @@ -76,11 +76,11 @@ namespace drawinglayer::texture if(mbIsAlpha) { maTransparence = rBitmapEx.GetAlphaMask().GetBitmap(); - mpReadTransparence = Bitmap::ScopedReadAccess(maTransparence); + mpReadTransparence = maTransparence; } if (!maBitmap.IsEmpty()) - mpReadBitmap = Bitmap::ScopedReadAccess(maBitmap); + mpReadBitmap = maBitmap; SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap"); if (mpReadBitmap) { diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx index 5a89fbe7cace..32fecd6c60e2 100644 --- a/editeng/inc/pch/precompiled_editeng.hxx +++ b/editeng/inc/pch/precompiled_editeng.hxx @@ -114,7 +114,6 @@ #include #include #include -#include #include #include #include diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 1b5739b3b190..4c74229fc8c8 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1003,7 +1003,7 @@ namespace emfio SAL_WARN( "emfio", "\tTODO Read DIB failed. Interrupting processing whole image. Please report bug report." ); if ( !aBmp.IsEmpty() ) { - Bitmap::ScopedReadAccess pBmp(aBmp); + BitmapScopedReadAccess pBmp(aBmp); for ( tools::Long y = 0; y < pBmp->Height(); y++ ) { for ( tools::Long x = 0; x < pBmp->Width(); x++ ) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 3fd6e84db310..0c9875cf43af 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1430,7 +1430,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co // Create a bitmap for the pattern with expected colors vcl::bitmap::RawBitmap aResult(Size(8, 8), 24); { - Bitmap::ScopedReadAccess pRead(aBmp); + BitmapScopedReadAccess pRead(aBmp); for (tools::Long y = 0; y < aResult.Height(); ++y) { diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index a9b73ddf9b65..0a93095d4ddf 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -5654,7 +5654,7 @@ void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, T if ( aSize.Height() > 64 ) aSize.setHeight( 64 ); - Bitmap::ScopedReadAccess pAcc(aBmp); + BitmapScopedReadAccess pAcc(aBmp); if( pAcc ) { sal_uLong nRt = 0, nGn = 0, nBl = 0; diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index 3f2e6bfdee5b..002ef0cc56e8 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -361,13 +361,15 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); Bitmap aBmp( aBmpEx.GetBitmap() ); - BitmapReadAccess* pBmpAcc = aBmp.AcquireReadAccess(); + BitmapScopedReadAccess pBmpAcc(aBmp); if( !pBmpAcc ) return; AlphaMask aMask( aBmpEx.GetAlphaMask() ); - BitmapReadAccess* pMskAcc = !aMask.IsEmpty() ? aMask.AcquireReadAccess() : nullptr; + BitmapScopedReadAccess pMskAcc; + if (!aMask.IsEmpty()) + pMskAcc = aMask; const tools::Long nWidth = pBmpAcc->Width(); const tools::Long nHeight = pBmpAcc->Height(); const tools::Long nStartX = 0; @@ -381,7 +383,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) { aMask = AlphaMask(aBmp.GetSizePixel()); aMask.Erase( 0 ); - pMskAcc = aMask.AcquireReadAccess(); + pMskAcc = aMask; } // create temporary list to hold interfaces @@ -464,9 +466,6 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) for (auto const& elem : aTmp) elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); } - - Bitmap::ReleaseAccess( pBmpAcc ); - Bitmap::ReleaseAccess( pMskAcc ); } diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx index 36f1c78981af..286a89247753 100644 --- a/framework/inc/pch/precompiled_fwk.hxx +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -109,7 +109,6 @@ #include #include #include -#include #include #include #include diff --git a/include/vcl/BitmapInfoAccess.hxx b/include/vcl/BitmapInfoAccess.hxx index 6e255c97e7ec..7ded0c9a95da 100644 --- a/include/vcl/BitmapInfoAccess.hxx +++ b/include/vcl/BitmapInfoAccess.hxx @@ -16,9 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#ifndef INCLUDED_VCL_BITMAPINFOACCESS_HXX -#define INCLUDED_VCL_BITMAPINFOACCESS_HXX +#pragma once #include #include @@ -38,10 +36,13 @@ class VCL_DLLPUBLIC BitmapInfoAccess friend class BitmapReadAccess; public: - BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Info); + BitmapInfoAccess(const Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Info); + BitmapInfoAccess(const AlphaMask& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Info); + virtual ~BitmapInfoAccess(); bool operator!() const { return mpBuffer == nullptr; } + explicit operator bool() const { return mpBuffer != nullptr; } tools::Long Width() const { return mpBuffer ? mpBuffer->mnWidth : 0L; } @@ -152,6 +153,47 @@ protected: BitmapAccessMode mnAccessMode; }; -#endif // INCLUDED_VCL_BITMAPINFOACCESS_HXX +class BitmapScopedInfoAccess +{ +public: + BitmapScopedInfoAccess(const Bitmap& rBitmap) + : moAccess(rBitmap) + { + } + BitmapScopedInfoAccess(const AlphaMask& rBitmap) + : moAccess(rBitmap) + { + } + BitmapScopedInfoAccess() {} + + BitmapScopedInfoAccess& operator=(const Bitmap& rBitmap) + { + moAccess.emplace(rBitmap); + return *this; + } + + BitmapScopedInfoAccess& operator=(const AlphaMask& rBitmap) + { + moAccess.emplace(rBitmap); + return *this; + } + + bool operator!() const { return !moAccess.has_value() || !*moAccess; } + explicit operator bool() const { return moAccess && bool(*moAccess); } + + void reset() { moAccess.reset(); } + + BitmapInfoAccess* get() { return moAccess ? &*moAccess : nullptr; } + const BitmapInfoAccess* get() const { return moAccess ? &*moAccess : nullptr; } + + BitmapInfoAccess* operator->() { return &*moAccess; } + const BitmapInfoAccess* operator->() const { return &*moAccess; } + + BitmapInfoAccess& operator*() { return *moAccess; } + const BitmapInfoAccess& operator*() const { return *moAccess; } + +private: + std::optional moAccess; +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapReadAccess.hxx b/include/vcl/BitmapReadAccess.hxx index 0d12bcae9dd6..5a99adb56bba 100644 --- a/include/vcl/BitmapReadAccess.hxx +++ b/include/vcl/BitmapReadAccess.hxx @@ -16,9 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#ifndef INCLUDED_VCL_BITMAPREADACCESS_HXX -#define INCLUDED_VCL_BITMAPREADACCESS_HXX +#pragma once #include #include @@ -33,7 +31,9 @@ class SAL_DLLPUBLIC_RTTI BitmapReadAccess : public BitmapInfoAccess friend class BitmapWriteAccess; public: - VCL_DLLPUBLIC BitmapReadAccess(Bitmap& rBitmap, + VCL_DLLPUBLIC BitmapReadAccess(const Bitmap& rBitmap, + BitmapAccessMode nMode = BitmapAccessMode::Read); + VCL_DLLPUBLIC BitmapReadAccess(const AlphaMask& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Read); VCL_DLLPUBLIC virtual ~BitmapReadAccess() override; @@ -189,6 +189,47 @@ public: static FncSetPixel SetPixelFunction(ScanlineFormat nFormat); }; -#endif // INCLUDED_VCL_BITMAPREADACCESS_HXX +class BitmapScopedReadAccess +{ +public: + BitmapScopedReadAccess(const Bitmap& rBitmap) + : moAccess(rBitmap) + { + } + BitmapScopedReadAccess(const AlphaMask& rBitmap) + : moAccess(rBitmap) + { + } + BitmapScopedReadAccess() {} + + BitmapScopedReadAccess& operator=(const Bitmap& rBitmap) + { + moAccess.emplace(rBitmap); + return *this; + } + + BitmapScopedReadAccess& operator=(const AlphaMask& rBitmap) + { + moAccess.emplace(rBitmap); + return *this; + } + + bool operator!() const { return !moAccess.has_value() || !*moAccess; } + explicit operator bool() const { return moAccess && bool(*moAccess); } + + void reset() { moAccess.reset(); } + + BitmapReadAccess* get() { return moAccess ? &*moAccess : nullptr; } + const BitmapReadAccess* get() const { return moAccess ? &*moAccess : nullptr; } + + BitmapReadAccess* operator->() { return &*moAccess; } + const BitmapReadAccess* operator->() const { return &*moAccess; } + + BitmapReadAccess& operator*() { return *moAccess; } + const BitmapReadAccess& operator*() const { return *moAccess; } + +private: + std::optional moAccess; +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/bitmap/BitmapWriteAccess.hxx b/include/vcl/BitmapWriteAccess.hxx similarity index 67% rename from vcl/inc/bitmap/BitmapWriteAccess.hxx rename to include/vcl/BitmapWriteAccess.hxx index bc903769d679..9027210adb50 100644 --- a/vcl/inc/bitmap/BitmapWriteAccess.hxx +++ b/include/vcl/BitmapWriteAccess.hxx @@ -7,25 +7,18 @@ * 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 +#pragma once #include #include #include #include -typedef vcl::ScopedBitmapAccess - BitmapScopedWriteAccess; - -typedef vcl::ScopedBitmapAccess - AlphaScopedWriteAccess; - class VCL_DLLPUBLIC BitmapWriteAccess final : public BitmapReadAccess { public: BitmapWriteAccess(Bitmap& rBitmap); + BitmapWriteAccess(AlphaMask& rBitmap); virtual ~BitmapWriteAccess() override; void CopyScanline(tools::Long nY, const BitmapReadAccess& rReadAcc); @@ -89,6 +82,47 @@ private: BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete; }; -#endif +class BitmapScopedWriteAccess +{ +public: + BitmapScopedWriteAccess(Bitmap& rBitmap) + : moAccess(rBitmap) + { + } + BitmapScopedWriteAccess(AlphaMask& rBitmap) + : moAccess(rBitmap) + { + } + BitmapScopedWriteAccess() {} + + BitmapScopedWriteAccess& operator=(Bitmap& rBitmap) + { + moAccess.emplace(rBitmap); + return *this; + } + + BitmapScopedWriteAccess& operator=(AlphaMask& rBitmap) + { + moAccess.emplace(rBitmap); + return *this; + } + + bool operator!() const { return !moAccess.has_value() || !*moAccess; } + explicit operator bool() const { return moAccess && bool(*moAccess); } + + void reset() { moAccess.reset(); } + + BitmapWriteAccess* get() { return moAccess ? &*moAccess : nullptr; } + const BitmapWriteAccess* get() const { return moAccess ? &*moAccess : nullptr; } + + BitmapWriteAccess* operator->() { return &*moAccess; } + const BitmapWriteAccess* operator->() const { return &*moAccess; } + + BitmapWriteAccess& operator*() { return *moAccess; } + const BitmapWriteAccess& operator*() const { return *moAccess; } + +private: + std::optional moAccess; +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx index 65ad50cfb4ea..fb5be9c16388 100644 --- a/include/vcl/alpha.hxx +++ b/include/vcl/alpha.hxx @@ -62,13 +62,6 @@ public: // check if alpha is used, returns true if at least one pixel has transparence bool hasAlpha() const; - BitmapReadAccess* AcquireAlphaReadAccess() { return maBitmap.AcquireReadAccess(); } - BitmapWriteAccess* AcquireAlphaWriteAccess() { return maBitmap.AcquireWriteAccess(); } - static void ReleaseAccess( BitmapInfoAccess* pBitmapAccess ) { Bitmap::ReleaseAccess(pBitmapAccess); } - - typedef vcl::ScopedBitmapAccess ScopedReadAccess; - typedef vcl::ScopedBitmapAccess ScopedWriteAccess; - bool IsEmpty() const { return maBitmap.IsEmpty(); } void SetEmpty() { maBitmap.SetEmpty(); } @@ -83,8 +76,6 @@ public: void SetPrefMapMode( const MapMode& rMapMode ) { maBitmap.SetPrefMapMode(rMapMode); } - BitmapReadAccess* AcquireReadAccess() { return maBitmap.AcquireReadAccess(); } - BitmapChecksum GetChecksum() const { return maBitmap.GetChecksum(); } bool Invert(); diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index 514eefea8f1b..8ce5d9cf74fa 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -605,16 +604,6 @@ public: SAL_DLLPRIVATE bool ImplMakeGreyscales(); -public: - - BitmapInfoAccess* AcquireInfoAccess(); - BitmapReadAccess* AcquireReadAccess(); - BitmapWriteAccess* AcquireWriteAccess(); - static void ReleaseAccess( BitmapInfoAccess* pAccess ); - - typedef vcl::ScopedBitmapAccess ScopedReadAccess; - typedef vcl::ScopedBitmapAccess ScopedInfoAccess; - private: SAL_DLLPRIVATE bool ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const* pExtColor = nullptr); SAL_DLLPRIVATE bool ImplConvertDown8BPP(Color const* pExtColor = nullptr); diff --git a/include/vcl/scopedbitmapaccess.hxx b/include/vcl/scopedbitmapaccess.hxx deleted file mode 100644 index b06618091529..000000000000 --- a/include/vcl/scopedbitmapaccess.hxx +++ /dev/null @@ -1,123 +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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_SCOPEDBITMAPACCESS_HXX -#define INCLUDED_VCL_SCOPEDBITMAPACCESS_HXX - -#include - -namespace vcl -{ - -/** This template handles BitmapAccess the RAII way. - - Please don't use directly, but through the ready-made typedefs - ScopedReadAccess and ScopedWriteAccess in classes Bitmap and - AlphaMask. - - Use as follows: - Bitmap aBitmap; - Bitmap::ScopedReadAccess pReadAccess( aBitmap ); - pReadAccess->SetPixel()... - - Bitmap aBitmap2; - BitmapScopedWriteAccess pWriteAccess( bCond ? aBitmap2.AcquireWriteAccess() : 0, aBitmap2 ); - if ( pWriteAccess )... - - @attention for practical reasons, ScopedBitmapAccess stores a - reference to the provided bitmap, thus, make sure that the bitmap - specified at construction time lives at least as long as the - ScopedBitmapAccess. - */ -template < class Access, class Bitmap, Access* (Bitmap::* Acquire)() > class ScopedBitmapAccess -{ -public: - explicit ScopedBitmapAccess( Bitmap& rBitmap ) : - mpAccess( nullptr ), - mpBitmap( &rBitmap ) - { - mpAccess = (mpBitmap->*Acquire)(); - } - - ScopedBitmapAccess( Access* pAccess, Bitmap& rBitmap ) : - mpAccess( pAccess ), - mpBitmap( &rBitmap ) - { - } - - ScopedBitmapAccess( ) : - mpAccess( nullptr ), - mpBitmap( nullptr ) - { - } - - // Move semantics - ScopedBitmapAccess &operator=(ScopedBitmapAccess&&other) - { - mpAccess=other.mpAccess; - mpBitmap=other.mpBitmap; - other.mpAccess = nullptr; - other.mpBitmap = nullptr; - return *this; - } - - // Disable copy from lvalue. - ScopedBitmapAccess(const ScopedBitmapAccess&) = delete; - ScopedBitmapAccess &operator=(const ScopedBitmapAccess&) = delete; - - ~ScopedBitmapAccess() COVERITY_NOEXCEPT_FALSE - { - if (mpAccess) - mpBitmap->ReleaseAccess( mpAccess ); - } - - void reset() - { - if (mpAccess) - { - mpBitmap->ReleaseAccess( mpAccess ); - mpAccess = nullptr; - } - } - - bool operator!() const { return !mpAccess; } - explicit operator bool() const - { - return mpAccess; - } - - Access* get() { return mpAccess; } - const Access* get() const { return mpAccess; } - - Access* operator->() { return mpAccess; } - const Access* operator->() const { return mpAccess; } - - Access& operator*() { return *mpAccess; } - const Access& operator*() const { return *mpAccess; } - -private: - Access* mpAccess; - Bitmap* mpBitmap; -}; - -} - -#endif // INCLUDED_VCL_SCOPEDBITMAPACCESS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/inc/pch/precompiled_rpt.hxx b/reportdesign/inc/pch/precompiled_rpt.hxx index f680e55fff5a..6e52bedf1e00 100644 --- a/reportdesign/inc/pch/precompiled_rpt.hxx +++ b/reportdesign/inc/pch/precompiled_rpt.hxx @@ -131,7 +131,6 @@ #include #include #include -#include #include #include #include diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx b/reportdesign/inc/pch/precompiled_rptui.hxx index cae7143cb082..9dc3e3fd6fe2 100644 --- a/reportdesign/inc/pch/precompiled_rptui.hxx +++ b/reportdesign/inc/pch/precompiled_rptui.hxx @@ -149,7 +149,6 @@ #include #include #include -#include #include #include #include diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index df9c3c3322aa..0bd47079ec85 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -143,7 +143,6 @@ #include #include #include -#include #include #include #include diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index c85089fc0736..8827b78afe64 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -396,7 +396,7 @@ void XclExpImgData::Save( XclExpStream& rStrm ) if (aBmp.getPixelFormat() != vcl::PixelFormat::N24_BPP) aBmp.Convert( BmpConversion::N24Bit ); - Bitmap::ScopedReadAccess pAccess(aBmp); + BitmapScopedReadAccess pAccess(aBmp); if( !pAccess ) return; diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx index b74e188d61d5..00b2c8389df4 100644 --- a/sd/inc/pch/precompiled_sdui.hxx +++ b/sd/inc/pch/precompiled_sdui.hxx @@ -158,7 +158,6 @@ #include #include #include -#include #include #include #include diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index da435ae971f1..645cf136b07f 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -75,7 +75,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf105998) // use assertColorsAreSimilar since the color might differ a little bit on mac Bitmap aBMP = aBMPEx.GetBitmap(); { - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { const Color aColorTop = pReadAccess->GetColor(0, nX); @@ -135,7 +135,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf126319) // Check all borders are red or similar. Ignore the corners Bitmap aBMP = aBMPEx.GetBitmap(); { - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 2; nX < aSize.Width() - 2; ++nX) { const Color aColorTop = pReadAccess->GetColor(0, nX); @@ -195,7 +195,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf136632) vcl::PngImageReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.read(); AlphaMask aAlpha = aBMPEx.GetAlphaMask(); - AlphaMask::ScopedReadAccess pReadAccess(aAlpha); + BitmapScopedReadAccess pReadAccess(aAlpha); // Without the fix in place, this test would have failed here CPPUNIT_ASSERT(!pReadAccess); @@ -234,7 +234,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157652) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) @@ -282,7 +282,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf156808) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); int nBlackCount = 0; for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { @@ -334,7 +334,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157795) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) @@ -383,7 +383,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf105362) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) @@ -431,7 +431,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157636) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); int nBlackCount = 0; for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { @@ -482,7 +482,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157793) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); int nLightGrayCount = 0; for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { @@ -533,7 +533,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157635) Size aSize = aBMPEx.GetSizePixel(); CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); int nBlackCount = 0; for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { @@ -585,7 +585,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf113163) CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); { - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) @@ -635,7 +635,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf147119) CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); AlphaMask aAlpha = aBMPEx.GetAlphaMask(); { - AlphaMask::ScopedReadAccess pReadAccess(aAlpha); + BitmapScopedReadAccess pReadAccess(aAlpha); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) @@ -684,7 +684,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf113197) CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); { - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { // Check the bottom half of the document is white @@ -734,7 +734,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf93124) CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx.GetSizePixel()); Bitmap aBMP = aBMPEx.GetBitmap(); { - Bitmap::ScopedReadAccess pReadAccess(aBMP); + BitmapScopedReadAccess pReadAccess(aBMP); int nNonWhiteCount = 0; // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white. for (tools::Long nY = 4; nY < (4 + 26); ++nY) @@ -789,7 +789,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf99729) vcl::PngImageReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.read(); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pRead(aBMP); + BitmapScopedReadAccess pRead(aBMP); for (tools::Long nX = 154; nX < (154 + 12); ++nX) { for (tools::Long nY = 16; nY < (16 + 96); ++nY) diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index da6572b8af5a..6b4e07cad33c 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -647,7 +647,7 @@ bool checkPatternValues(std::vector& rExpected, Bitmap& rBitmap) const Color aFGColor(0xFF0000); const Color aBGColor(0xFFFFFF); - Bitmap::ScopedReadAccess pAccess(rBitmap); + BitmapScopedReadAccess pAccess(rBitmap); for (tools::Long y = 0; y < pAccess->Height(); ++y) { Scanline pScanline = pAccess->GetScanline(y); diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index dd0182ef8ea2..23d96e7595bd 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -2431,7 +2431,7 @@ static void assertTilePixelColor(SdXImpressDocument* pXImpressDocument, int nPix pXImpressDocument->paintTile(*pDevice, nCanvasSize, nCanvasSize, 0, 0, 15360, 7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Color aActualColor(pAccess->GetPixel(nPixelX, nPixelY)); CPPUNIT_ASSERT_EQUAL(aColor, aActualColor); } diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx index 2db041e7e7e3..de555ceedb05 100644 --- a/sd/source/ui/dlg/vectdlg.cxx +++ b/sd/source/ui/dlg/vectdlg.cxx @@ -143,7 +143,7 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) if (m_xCbFillHoles->get_active()) { GDIMetaFile aNewMtf; - Bitmap::ScopedReadAccess pRAcc(aTmp); + BitmapScopedReadAccess pRAcc(aTmp); if( pRAcc ) { diff --git a/slideshow/inc/pch/precompiled_slideshow.hxx b/slideshow/inc/pch/precompiled_slideshow.hxx index ef4e988c96b3..6b0b55d53341 100644 --- a/slideshow/inc/pch/precompiled_slideshow.hxx +++ b/slideshow/inc/pch/precompiled_slideshow.hxx @@ -130,7 +130,6 @@ #include #include #include -#include #include #include #include diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 34bef2dcfe2d..7b189e4af414 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -6335,7 +6335,6 @@ include/vcl/salctype.hxx include/vcl/salgtype.hxx include/vcl/salnativewidgets.hxx include/vcl/scheduler.hxx -include/vcl/scopedbitmapaccess.hxx include/vcl/seleng.hxx include/vcl/settings.hxx include/vcl/split.hxx diff --git a/svtools/inc/pch/precompiled_svt.hxx b/svtools/inc/pch/precompiled_svt.hxx index 723464d627db..6d32b32206ca 100644 --- a/svtools/inc/pch/precompiled_svt.hxx +++ b/svtools/inc/pch/precompiled_svt.hxx @@ -125,7 +125,6 @@ #include #include #include -#include #include #include #include diff --git a/svx/inc/pch/precompiled_svxcore.hxx b/svx/inc/pch/precompiled_svxcore.hxx index 0a21fe48f2a0..cc63b1b5a10c 100644 --- a/svx/inc/pch/precompiled_svxcore.hxx +++ b/svx/inc/pch/precompiled_svxcore.hxx @@ -137,7 +137,6 @@ #include #include #include -#include #include #include #include diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 34a60fdbc3e4..3ac58e33394b 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -189,7 +189,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_NonUI) vcl::PngImageReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.read(); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pRead(aBMP); + BitmapScopedReadAccess pRead(aBMP); Size aSize = aBMP.GetSizePixel(); // GetColor(Y,X) Color aActualColor = pRead->GetColor(aSize.Height() / 2, aSize.Width() * 0.125); @@ -225,7 +225,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_FrontLightDim) vcl::PngImageReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.read(); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pRead(aBMP); + BitmapScopedReadAccess pRead(aBMP); Size aSize = aBMP.GetSizePixel(); // GetColor(Y,X) Color aActualColor = pRead->GetColor(aSize.Height() / 2, aSize.Width() * 0.4); @@ -252,7 +252,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_FirstLightHarsh) vcl::PngImageReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.read(); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pRead(aBMP); + BitmapScopedReadAccess pRead(aBMP); Size aSize = aBMP.GetSizePixel(); // GetColor(Y,X) const Color aActualColor = pRead->GetColor(aSize.Height() / 2, aSize.Width() / 2); @@ -1221,7 +1221,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148501_OctagonBevel) vcl::PngImageReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.read(); Bitmap aBMP = aBMPEx.GetBitmap(); - Bitmap::ScopedReadAccess pRead(aBMP); + BitmapScopedReadAccess pRead(aBMP); Size aSize = aBMP.GetSizePixel(); // GetColor(Y,X). The chosen threshold for the ColorDistance can be adapted if necessary. diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 15e638e445cf..e5f99a8f8f01 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -278,7 +278,7 @@ std::optional GetDraftFillColor(const SfxItemSet& rSet) if (nWidth <= 0 || nHeight <= 0) return {}; - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); if (pAccess) { diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx index 26b8daf95af7..0ef260ea7fae 100644 --- a/sw/inc/pch/precompiled_msword.hxx +++ b/sw/inc/pch/precompiled_msword.hxx @@ -156,7 +156,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/inc/pch/precompiled_swui.hxx b/sw/inc/pch/precompiled_swui.hxx index 3cdac268bea0..0ed7216a6b27 100644 --- a/sw/inc/pch/precompiled_swui.hxx +++ b/sw/inc/pch/precompiled_swui.hxx @@ -154,7 +154,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index 940f5d983087..c6e0bb176da7 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -136,7 +136,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index ebc094803153..553fbebbc6e3 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -1159,7 +1159,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156078) Graphic exported; GraphicFilter::LoadGraphic(maTempFile.GetURL(), {}, exported); Bitmap bmp = exported.GetBitmapEx().GetBitmap(); - Bitmap::ScopedReadAccess pAccess(bmp); + BitmapScopedReadAccess pAccess(bmp); // "1" must export to the top right corner; check its pixels bool numberPixelsFound = false; diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 36431f83856f..64d2f665a66d 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1739,7 +1739,7 @@ static void assertTilePixelColor(SwXTextDocument* pXTextDocument, int nPixelX, i pXTextDocument->paintTile(*pDevice, nCanvasSize, nCanvasSize, 0, 0, 15360, 7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Color aActualColor(pAccess->GetPixel(nPixelX, nPixelY)); CPPUNIT_ASSERT_EQUAL(aColor, aActualColor); } @@ -2843,7 +2843,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSemiTransparent) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); Color aColor(pAccess->GetPixel(255, 255)); // Without the accompanying fix in place, this test would have failed with 'Expected greater or @@ -2872,7 +2872,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testHighlightNumbering) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); // Yellow highlighting over numbering Color aColor(pAccess->GetPixel(103, 148)); @@ -2897,7 +2897,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testHighlightNumbering_shd) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); // No highlighting over numbering - w:shd does not apply to numbering. Color aColor(pAccess->GetPixel(103, 148)); @@ -2927,7 +2927,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPilcrowRedlining) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(100, 100), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); const char* aTexts[] = { "Insert paragraph break", @@ -3008,7 +3008,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testDoubleUnderlineAndStrikeOut) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); bool bGreenLine = false; size_t nGreenLine = 0; // count green horizontal lines by tracking a column of pixels counting the @@ -3054,7 +3054,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf43244_SpacesOnMargin) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(730, 120), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); //Test if we see any spaces on the right margin in a 47x48 rectangle bool bSpaceFound = false; @@ -3097,7 +3097,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testClipText) /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); - Bitmap::ScopedReadAccess pAccess(aBitmap); + BitmapScopedReadAccess pAccess(aBitmap); // check top margin, it's not white completely (i.e. showing top of letter "T") bool bClipTop = true; diff --git a/vbahelper/inc/pch/precompiled_msforms.hxx b/vbahelper/inc/pch/precompiled_msforms.hxx index 9afb398bbb2d..4718389ac675 100644 --- a/vbahelper/inc/pch/precompiled_msforms.hxx +++ b/vbahelper/inc/pch/precompiled_msforms.hxx @@ -106,7 +106,6 @@ #include #include #include -#include #include #include #include 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 #include #include -#include +#include 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 -#include +#include #include #include 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 #include +#include 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 m_pBmpReadAcc; - std::optional m_pAlphaReadAcc; + BitmapScopedInfoAccess m_pBmpAcc; + BitmapScopedInfoAccess m_pAlphaAcc; + std::optional m_pBmpReadAcc; + std::optional m_pAlphaReadAcc; css::uno::Sequence m_aComponentTags; css::uno::Sequence 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 #include #include -#include +#include #include #include #include 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 #include #include -#include +#include #include #include @@ -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 #include -#include +#include #include #include @@ -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(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(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(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(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(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(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(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(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 #include -#include +#include #include #include @@ -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 #include -#include +#include 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 #include -#include +#include 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 #include -#include +#include #include #include #include @@ -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(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(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 #include -#include +#include #include @@ -87,7 +87,7 @@ void checkCanvasBitmap( const rtl::Reference& 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 #include -#include +#include #include 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 #include -#include +#include #include #include 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 #include #include -#include +#include #include #include @@ -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 #include #include -#include +#include #include #include #include @@ -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 #include -#include +#include #include 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 #include -#include +#include #include #include @@ -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(pAcc->GetPixel(0, 0))); #if !defined _WIN32 //TODO: various failures on Windows tinderboxes CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast(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 #include #include -#include +#include #include #include #include @@ -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 #include -#include +#include 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(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(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(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(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(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(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(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 #include -#include +#include #include @@ -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 #include - -#include +#include 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 #include #include - -#include +#include #include @@ -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 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 struct Value { } - 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 struct Value 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 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 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 #include #include - -#include +#include #include #include @@ -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 #include -#include +#include #include 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 #include #include - -#include +#include #include @@ -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 +#include #include 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 #include #include - -#include +#include 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 #include #include - -#include +#include #include @@ -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 #include #include -#include +#include #include #include @@ -578,7 +578,7 @@ sal_uInt8 BitmapEx::GetAlpha(sal_Int32 nX, sal_Int32 nY) const } else { - AlphaMask::ScopedReadAccess pRead(const_cast(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(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 pVirDev(VclPtr::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 #include +#include -#include #include 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 -#include +#include #include #include @@ -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 #include #include - -#include +#include 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 #include -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(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(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 -#include +#include #include #include @@ -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 -#include +#include #include 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 -#include +#include #include /** @@ -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 #include #include - -#include +#include #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 #include #include - -#include +#include 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 #include #include - -#include +#include 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 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 #include #include - -#include +#include 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 #include -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 #include -#include +#include #include #include @@ -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 #include -#include +#include #include #include @@ -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 #include #include - -#include +#include 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 #include #include - -#include +#include #include 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 #include #include - -#include +#include 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 #include #include - -#include +#include #include 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 #include #include - -#include +#include #include @@ -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 #include #include - -#include +#include 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 #include #include -#include +#include 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 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 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(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(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 #include -#include +#include #include 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 #include -#include +#include #include #include #include @@ -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(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(*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(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 #include #include -#include +#include #include #include @@ -275,7 +275,7 @@ bool Bitmap::HasGreyPaletteAny() const { bool bRet = false; - ScopedInfoAccess pIAcc(const_cast(*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(*this)); + BitmapScopedInfoAccess pIAcc(*this); if( pIAcc ) { @@ -360,47 +360,6 @@ void Bitmap::ImplSetSalBitmap(const std::shared_ptr& xImpBmp) mxSalBmp = xImpBmp; } -BitmapInfoAccess* Bitmap::AcquireInfoAccess() -{ - std::unique_ptr pInfoAccess(new BitmapInfoAccess( *this )); - - if( !*pInfoAccess ) - { - return nullptr; - } - - return pInfoAccess.release(); -} - -BitmapReadAccess* Bitmap::AcquireReadAccess() -{ - std::unique_ptr pReadAccess(new BitmapReadAccess( *this )); - - if( !*pReadAccess ) - { - return nullptr; - } - - return pReadAccess.release(); -} - -BitmapWriteAccess* Bitmap::AcquireWriteAccess() -{ - std::unique_ptr 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(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 #include -#include +#include #include #include #include @@ -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(*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(*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(*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(*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(*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(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(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(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 -#include +#include #include #include 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 #include #include -#include +#include #include #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 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 m_pGraphic; /// Write pixel data using this access. std::unique_ptr m_pAccess; - std::unique_ptr m_pAlphaAccess; + std::unique_ptr 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 >& 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(rContext.mAlphaMask); + rContext.m_pAlphaAccess = std::make_unique(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 -#include +#include #include #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 #include -#include +#include #include #include #include @@ -92,7 +92,7 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector& 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 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 #include #include -#include +#include #include #include #include @@ -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 -#include +#include #include #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 #include -#include +#include #include #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 #include -#include +#include #include 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 #include -#include +#include #include 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 #include - -#include +#include #include 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 #include #include +#include -#include #include #include @@ -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 #include -#include +#include #include #include #include @@ -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 #include - -#include +#include 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 #include #include -#include +#include #include #include #include @@ -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 #include -#include +#include #include #include #include @@ -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 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 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 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(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(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(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 #include -#include +#include 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 #include #include -#include +#include #include #include #include @@ -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 #include #include +#include -#include #include #include #include @@ -650,8 +650,8 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, TradScaleContext aTradContext(aDstRect, aBmpRect, aOutSize, nOffX, nOffY); - Bitmap::ScopedReadAccess pBitmapReadAccess(const_cast(rBitmap)); - AlphaMask::ScopedReadAccess pAlphaReadAccess(const_cast(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 #include #include - -#include +#include #include #include @@ -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 #include -#include +#include 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 #include #include -#include +#include #include @@ -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 #include #include - -#include +#include #include #include @@ -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++) diff --git a/xmloff/inc/pch/precompiled_xo.hxx b/xmloff/inc/pch/precompiled_xo.hxx index 712f227fb41c..471c6ad80472 100644 --- a/xmloff/inc/pch/precompiled_xo.hxx +++ b/xmloff/inc/pch/precompiled_xo.hxx @@ -93,7 +93,6 @@ #include #include #include -#include #endif // PCH_LEVEL >= 2 #if PCH_LEVEL >= 3 #include diff --git a/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx b/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx index c05ded48fe80..bf9c9025a702 100644 --- a/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx +++ b/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx @@ -96,7 +96,6 @@ #include #include #include -#include #include #include #include