vcl/headless/BitmapHelper.cxx     |   82 ++++++++++++++++++++++++++++++++++++++
 vcl/headless/svpgdi.cxx           |   78 ------------------------------------
 vcl/inc/headless/BitmapHelper.hxx |    5 ++
 3 files changed, 87 insertions(+), 78 deletions(-)

New commits:
commit 86fdd581a832c7476d7556f3f4fb7d83f5de4d8b
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Dec 29 15:47:42 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Jan 5 04:35:45 2022 +0100

    vcl: move tryToUse{Source,Mask}Buffer to BitmapHelper
    
    Change-Id: I9352aec388db56596fef3f5f323244b1df26cdcb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127979
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx
index 8d56631a4fee..2b9c670dfb3f 100644
--- a/vcl/headless/BitmapHelper.cxx
+++ b/vcl/headless/BitmapHelper.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <headless/BitmapHelper.hxx>
+#include <svdata.hxx>
 
 BitmapHelper::BitmapHelper(const SalBitmap& rSourceBitmap, const bool 
bForceARGB32)
 #ifdef HAVE_CAIRO_FORMAT_RGB24_888
@@ -183,4 +184,85 @@ sal_Int64 
SystemDependentData_MaskHelper::estimateUsageInBytes() const
 {
     return estimateUsageInBytesForSurfaceHelper(maMaskHelper.get());
 }
+
+namespace
+{
+// MM02 decide to use buffers or not
+const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES"));
+bool bUseBuffer(nullptr == pDisableMM02Goodies);
+const tools::Long nMinimalSquareSizeToBuffer(64 * 64);
+}
+
+void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, 
std::shared_ptr<BitmapHelper>& rSurface)
+{
+    // MM02 try to access buffered BitmapHelper
+    std::shared_ptr<SystemDependentData_BitmapHelper> 
pSystemDependentData_BitmapHelper;
+    const bool bBufferSource(bUseBuffer
+                             && rSourceBitmap.GetSize().Width() * 
rSourceBitmap.GetSize().Height()
+                                    > nMinimalSquareSizeToBuffer);
+
+    if (bBufferSource)
+    {
+        const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rSourceBitmap));
+        pSystemDependentData_BitmapHelper
+            = 
rSrcBmp.getSystemDependentData<SystemDependentData_BitmapHelper>();
+
+        if (pSystemDependentData_BitmapHelper)
+        {
+            // reuse buffered data
+            rSurface = pSystemDependentData_BitmapHelper->getBitmapHelper();
+        }
+    }
+
+    if (rSurface)
+        return;
+
+    // create data on-demand
+    rSurface = std::make_shared<BitmapHelper>(rSourceBitmap);
+
+    if (bBufferSource)
+    {
+        // add to buffering mechanism to potentially reuse next time
+        const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rSourceBitmap));
+        
rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_BitmapHelper>(
+            ImplGetSystemDependentDataManager(), rSurface);
+    }
+}
+
+void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, 
std::shared_ptr<MaskHelper>& rMask)
+{
+    // MM02 try to access buffered MaskHelper
+    std::shared_ptr<SystemDependentData_MaskHelper> 
pSystemDependentData_MaskHelper;
+    const bool bBufferMask(bUseBuffer
+                           && rMaskBitmap.GetSize().Width() * 
rMaskBitmap.GetSize().Height()
+                                  > nMinimalSquareSizeToBuffer);
+
+    if (bBufferMask)
+    {
+        const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rMaskBitmap));
+        pSystemDependentData_MaskHelper
+            = rSrcBmp.getSystemDependentData<SystemDependentData_MaskHelper>();
+
+        if (pSystemDependentData_MaskHelper)
+        {
+            // reuse buffered data
+            rMask = pSystemDependentData_MaskHelper->getMaskHelper();
+        }
+    }
+
+    if (rMask)
+        return;
+
+    // create data on-demand
+    rMask = std::make_shared<MaskHelper>(rMaskBitmap);
+
+    if (bBufferMask)
+    {
+        // add to buffering mechanism to potentially reuse next time
+        const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rMaskBitmap));
+        
rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_MaskHelper>(
+            ImplGetSystemDependentDataManager(), rMask);
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 3a321af10293..04849793efd9 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -57,84 +57,6 @@
 #   endif
 #endif
 
-namespace
-{
-    // MM02 decide to use buffers or not
-    const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES"));
-    bool bUseBuffer(nullptr == pDisableMM02Goodies);
-    const tools::Long nMinimalSquareSizeToBuffer(64*64);
-
-    void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, 
std::shared_ptr<BitmapHelper>& rSurface)
-    {
-        // MM02 try to access buffered BitmapHelper
-        std::shared_ptr<SystemDependentData_BitmapHelper> 
pSystemDependentData_BitmapHelper;
-        const bool bBufferSource(bUseBuffer
-            && rSourceBitmap.GetSize().Width() * 
rSourceBitmap.GetSize().Height() > nMinimalSquareSizeToBuffer);
-
-        if(bBufferSource)
-        {
-            const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rSourceBitmap));
-            pSystemDependentData_BitmapHelper = 
rSrcBmp.getSystemDependentData<SystemDependentData_BitmapHelper>();
-
-            if(pSystemDependentData_BitmapHelper)
-            {
-                // reuse buffered data
-                rSurface = 
pSystemDependentData_BitmapHelper->getBitmapHelper();
-            }
-        }
-
-        if(rSurface)
-            return;
-
-        // create data on-demand
-        rSurface = std::make_shared<BitmapHelper>(rSourceBitmap);
-
-        if(bBufferSource)
-        {
-            // add to buffering mechanism to potentially reuse next time
-            const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rSourceBitmap));
-            
rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_BitmapHelper>(
-                ImplGetSystemDependentDataManager(),
-                rSurface);
-        }
-    }
-
-    void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, 
std::shared_ptr<MaskHelper>& rMask)
-    {
-        // MM02 try to access buffered MaskHelper
-        std::shared_ptr<SystemDependentData_MaskHelper> 
pSystemDependentData_MaskHelper;
-        const bool bBufferMask(bUseBuffer
-            && rMaskBitmap.GetSize().Width() * rMaskBitmap.GetSize().Height() 
> nMinimalSquareSizeToBuffer);
-
-        if(bBufferMask)
-        {
-            const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rMaskBitmap));
-            pSystemDependentData_MaskHelper = 
rSrcBmp.getSystemDependentData<SystemDependentData_MaskHelper>();
-
-            if(pSystemDependentData_MaskHelper)
-            {
-                // reuse buffered data
-                rMask = pSystemDependentData_MaskHelper->getMaskHelper();
-            }
-        }
-
-        if(rMask)
-            return;
-
-        // create data on-demand
-        rMask = std::make_shared<MaskHelper>(rMaskBitmap);
-
-        if(bBufferMask)
-        {
-            // add to buffering mechanism to potentially reuse next time
-            const SvpSalBitmap& rSrcBmp(static_cast<const 
SvpSalBitmap&>(rMaskBitmap));
-            
rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_MaskHelper>(
-                ImplGetSystemDependentDataManager(),
-                rMask);
-        }
-    }
-}
-
 bool SvpSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, const SalBitmap& 
rSourceBitmap, const SalBitmap& rAlphaBitmap )
 {
     if (rAlphaBitmap.GetBitCount() != 8 && rAlphaBitmap.GetBitCount() != 1)
diff --git a/vcl/inc/headless/BitmapHelper.hxx 
b/vcl/inc/headless/BitmapHelper.hxx
index da5e417a4e9f..cffa0b21d50b 100644
--- a/vcl/inc/headless/BitmapHelper.hxx
+++ b/vcl/inc/headless/BitmapHelper.hxx
@@ -73,4 +73,9 @@ public:
     virtual sal_Int64 estimateUsageInBytes() const override;
 };
 
+VCL_DLLPUBLIC void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap,
+                                        std::shared_ptr<BitmapHelper>& 
rSurface);
+VCL_DLLPUBLIC void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap,
+                                      std::shared_ptr<MaskHelper>& rMask);
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to