vcl/headless/SvpGraphicsBackend.cxx |    2 +-
 vcl/headless/svpbmp.cxx             |   14 +++++++++++---
 vcl/inc/headless/svpbmp.hxx         |    5 +++++
 3 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 86723a88c90ebb9a1845e710f067a9dc4cbc1b62
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sat Oct 21 19:42:09 2023 +0100
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Oct 23 09:59:14 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/+/158310
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/headless/SvpGraphicsBackend.cxx 
b/vcl/headless/SvpGraphicsBackend.cxx
index 0094290d47b8..1dc1ecf38eac 100644
--- a/vcl/headless/SvpGraphicsBackend.cxx
+++ b/vcl/headless/SvpGraphicsBackend.cxx
@@ -562,7 +562,7 @@ std::shared_ptr<SalBitmap> 
SvpGraphicsBackend::getBitmap(tools::Long nX, tools::
         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 a72774068d30..404bc9274f80 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;
@@ -128,6 +129,7 @@ static std::unique_ptr<BitmapBuffer> ImplCreateDIB(
         }
         else
 #endif
+        if (bClear)
         {
             std::memset(pDIB->mpBits, 0, size);
         }
@@ -146,13 +148,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,

Reply via email to