summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-10-14 15:05:19 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-10-15 00:52:28 +0200
commitf0443fa4438aa98bce48bfd53dc6a687737687b6 (patch)
tree51901fc9bb534be806240dc2881b95443ba16b05
parentf1020c61e950b0ccca06d56df676a366907c0db2 (diff)
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@CIB.de>
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs8
-rw-r--r--vcl/inc/graphic/Manager.hxx1
-rw-r--r--vcl/source/graphic/Manager.cxx20
3 files changed, 23 insertions, 6 deletions
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)