vcl/headless/CairoCommon.cxx | 2 +- vcl/headless/svpbmp.cxx | 14 +++++++++++--- vcl/inc/headless/svpbmp.hxx | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-)
New commits: commit 10a4fc18c48bbcf3dbfe802f7c13405cfe737084 Author: Caolán McNamara <[email protected]> AuthorDate: Sat Oct 21 19:42:09 2023 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Oct 22 16:39:28 2023 +0200 SvpGraphicsBackend::getBitmap overwrites the buffer so in this case we don't need to memset it to 0 before seen in VclDrawingArea::DumpAsPropertyTree Change-Id: I339677f091e9e6585e5d6e72f467d439efb43cb8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158325 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 4d29e8a1602f..093e970e4dfd 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1907,7 +1907,7 @@ std::shared_ptr<SalBitmap> CairoCommon::getBitmap(tools::Long nX, tools::Long nY ePixelFormat = vcl::PixelFormat::N32_BPP; } - if (!pBitmap->Create(Size(nWidth, nHeight), ePixelFormat, aPal)) + if (!pBitmap->ImplCreate(Size(nWidth, nHeight), ePixelFormat, aPal, false)) { SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap"); return nullptr; diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 9c12fb91d2c1..bb8153fb87ef 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -46,7 +46,8 @@ SvpSalBitmap::~SvpSalBitmap() static std::unique_ptr<BitmapBuffer> ImplCreateDIB( const Size& rSize, vcl::PixelFormat ePixelFormat, - const BitmapPalette& rPal) + const BitmapPalette& rPal, + bool bClear) { if (!rSize.Width() || !rSize.Height()) return nullptr; @@ -125,6 +126,7 @@ static std::unique_ptr<BitmapBuffer> ImplCreateDIB( } else #endif + if (bClear) { std::memset(pDIB->mpBits, 0, size); } @@ -143,13 +145,19 @@ void SvpSalBitmap::Create(std::unique_ptr<BitmapBuffer> pBuf) mpDIB = std::move(pBuf); } -bool SvpSalBitmap::Create(const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal) +bool SvpSalBitmap::ImplCreate(const Size& rSize, vcl::PixelFormat ePixelFormat, + const BitmapPalette& rPal, bool bClear) { Destroy(); - mpDIB = ImplCreateDIB(rSize, ePixelFormat, rPal); + mpDIB = ImplCreateDIB(rSize, ePixelFormat, rPal, bClear); return mpDIB != nullptr; } +bool SvpSalBitmap::Create(const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal) +{ + return ImplCreate(rSize, ePixelFormat, rPal, true); +} + bool SvpSalBitmap::Create(const SalBitmap& rBmp) { Destroy(); diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index cd90d23e8e22..b7cfdd2e4f6b 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -32,6 +32,11 @@ public: SvpSalBitmap(); virtual ~SvpSalBitmap() override; + bool ImplCreate(const Size& rSize, + vcl::PixelFormat ePixelFormat, + const BitmapPalette& rPalette, + bool bClear); + // SalBitmap virtual bool Create(const Size& rSize, vcl::PixelFormat ePixelFormat,
