[Libreoffice-commits] core.git: officecfg/registry vcl/inc vcl/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 14 22:53:27 UTC 2019


 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    8 +++++
 vcl/inc/graphic/Manager.hxx                                |    1 
 vcl/source/graphic/Manager.cxx                             |   20 +++++++++----
 3 files changed, 23 insertions(+), 6 deletions(-)

New commits:
commit f0443fa4438aa98bce48bfd53dc6a687737687b6
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Mon Oct 14 15:05:19 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Oct 15 00:52:28 2019 +0200

    Add option to prevent graphic swap out
    
    Change-Id: Icbfc21b219cd4ba582e798e5deda6ef7c81a2009
    Reviewed-on: https://gerrit.libreoffice.org/80773
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 0fd0786a77a9..0c6b90fea58d 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -1524,6 +1524,14 @@
           </info>
           <value>600</value>
         </prop>
+        <prop oor:name="GraphicSwappingEnabled" oor:type="xs:boolean" oor:nillable="false">
+          <info>
+            <desc>Whether graphics will be swapped to disk when `GraphicMemoryLimit`
+            is reached. Disable at your own risk.</desc>
+            <label>Graphic Swapping Enabled</label>
+          </info>
+          <value>true</value>
+        </prop>
         <prop oor:name="GraphicMemoryLimit" oor:type="xs:int" oor:nillable="false">
           <info>
             <desc>Specifies the allowed cumulated memory that the
diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx
index a756450caf28..f1413877bb08 100644
--- a/vcl/inc/graphic/Manager.hxx
+++ b/vcl/inc/graphic/Manager.hxx
@@ -35,6 +35,7 @@ private:
     std::recursive_mutex maMutex; // instead of SolarMutex because graphics can live past vcl main
     std::unordered_set<ImpGraphic*> m_pImpGraphicList;
     std::chrono::seconds mnAllowedIdleTime;
+    bool mbSwapEnabled;
     sal_Int64 mnMemoryLimit;
     sal_Int64 mnUsedSize;
     Timer maSwapOutTimer;
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index ec2bdca9be0b..5942b5cb8784 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -33,7 +33,7 @@ namespace graphic
 namespace
 {
 void setupConfigurationValuesIfPossible(sal_Int64& rMemoryLimit,
-                                        std::chrono::seconds& rAllowedIdleTime)
+                                        std::chrono::seconds& rAllowedIdleTime, bool& bSwapEnabled)
 {
     if (utl::ConfigManager::IsFuzzing())
         return;
@@ -45,6 +45,7 @@ void setupConfigurationValuesIfPossible(sal_Int64& rMemoryLimit,
         rMemoryLimit = Cache::GraphicManager::GraphicMemoryLimit::get();
         rAllowedIdleTime
             = std::chrono::seconds(Cache::GraphicManager::GraphicAllowedIdleTime::get());
+        bSwapEnabled = Cache::GraphicManager::GraphicSwappingEnabled::get();
     }
     catch (...)
     {
@@ -60,20 +61,27 @@ Manager& Manager::get()
 
 Manager::Manager()
     : mnAllowedIdleTime(10)
+    , mbSwapEnabled(true)
     , mnMemoryLimit(300000000)
     , mnUsedSize(0)
     , maSwapOutTimer("graphic::Manager maSwapOutTimer")
 {
-    setupConfigurationValuesIfPossible(mnMemoryLimit, mnAllowedIdleTime);
+    setupConfigurationValuesIfPossible(mnMemoryLimit, mnAllowedIdleTime, mbSwapEnabled);
 
-    maSwapOutTimer.SetInvokeHandler(LINK(this, Manager, SwapOutTimerHandler));
-    maSwapOutTimer.SetTimeout(10000);
-    maSwapOutTimer.SetDebugName("graphic::Manager maSwapOutTimer");
-    maSwapOutTimer.Start();
+    if (mbSwapEnabled)
+    {
+        maSwapOutTimer.SetInvokeHandler(LINK(this, Manager, SwapOutTimerHandler));
+        maSwapOutTimer.SetTimeout(10000);
+        maSwapOutTimer.SetDebugName("graphic::Manager maSwapOutTimer");
+        maSwapOutTimer.Start();
+    }
 }
 
 void Manager::reduceGraphicMemory()
 {
+    if (!mbSwapEnabled)
+        return;
+
     std::scoped_lock<std::recursive_mutex> aGuard(maMutex);
 
     for (ImpGraphic* pEachImpGraphic : m_pImpGraphicList)


More information about the Libreoffice-commits mailing list