diff options
-rw-r--r-- | vcl/inc/skia/salbmp.hxx | 4 | ||||
-rw-r--r-- | vcl/skia/salbmp.cxx | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index 78b864104a2c..40cbb62104d1 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -24,6 +24,8 @@ #include <SkImage.h> +#include <boost/smart_ptr/shared_ptr.hpp> + class VCL_PLUGIN_PUBLIC SkiaSalBitmap final : public SalBitmap { public: @@ -114,7 +116,7 @@ private: // mBitmap/mBuffer must be filled from it on demand if necessary by EnsureBitmapData(). SkBitmap mBitmap; sk_sp<SkImage> mImage; // possibly GPU-backed - std::shared_ptr<sal_uInt8[]> mBuffer; + boost::shared_ptr<sal_uInt8[]> mBuffer; int mScanlineSize; // size of one row in mBuffer sk_sp<SkImage> mAlphaImage; // cached contents as alpha image, possibly GPU-backed #ifdef DBG_UTIL diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 4430d7f672cd..172b7c37ef92 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -21,6 +21,7 @@ #include <o3tl/safeint.hxx> #include <tools/helpers.hxx> +#include <boost/smart_ptr/make_shared.hpp> #include <salgdi.hxx> #include <salinst.hxx> @@ -140,22 +141,21 @@ bool SkiaSalBitmap::CreateBitmapData() return false; } mScanlineSize = AlignedWidth4Bytes(bitScanlineWidth); - sal_uInt8* buffer = nullptr; if (mScanlineSize != 0 && mSize.Height() != 0) { size_t allocate = mScanlineSize * mSize.Height(); #ifdef DBG_UTIL allocate += sizeof(CANARY); #endif - buffer = new sal_uInt8[allocate]; + mBuffer = boost::make_shared<sal_uInt8[]>(allocate); #ifdef DBG_UTIL // fill with random garbage + sal_uInt8* buffer = mBuffer.get(); for (size_t i = 0; i < allocate; i++) buffer[i] = (i & 0xFF); memcpy(buffer + allocate - sizeof(CANARY), CANARY, sizeof(CANARY)); #endif } - mBuffer.reset(buffer); } return true; } @@ -613,9 +613,9 @@ void SkiaSalBitmap::EnsureBitmapUniqueData() assert(memcmp(mBuffer.get() + allocate, CANARY, sizeof(CANARY)) == 0); allocate += sizeof(CANARY); #endif - sal_uInt8* newBuffer = new sal_uInt8[allocate]; - memcpy(newBuffer, mBuffer.get(), allocate); - mBuffer.reset(newBuffer); + boost::shared_ptr<sal_uInt8[]> newBuffer = boost::make_shared<sal_uInt8[]>(allocate); + memcpy(newBuffer.get(), mBuffer.get(), allocate); + mBuffer = newBuffer; } } |