summaryrefslogtreecommitdiffstats
path: root/basegfx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-10-03 15:55:29 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-10-06 20:31:22 +0200
commite650279db77281fe98aaff28e31c2269611c31e4 (patch)
tree2e497016dbe882d7557c4ee7ff66bb8b5d582dc2 /basegfx
parentUNX use font cache based glyph rect cache (diff)
downloadcore-e650279db77281fe98aaff28e31c2269611c31e4.tar.gz
core-e650279db77281fe98aaff28e31c2269611c31e4.zip
Support estimateUsageInBytes for SystemDependentData
Change-Id: I6074035ed8f90e452915e9ecffdbe9363375e126 Reviewed-on: https://gerrit.libreoffice.org/61306 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/tools/systemdependentdata.cxx47
1 files changed, 46 insertions, 1 deletions
diff --git a/basegfx/source/tools/systemdependentdata.cxx b/basegfx/source/tools/systemdependentdata.cxx
index 4153d35f7d55..c727462c7191 100644
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -8,6 +8,7 @@
*/
#include <basegfx/utils/systemdependentdata.hxx>
+#include <math.h>
namespace basegfx
{
@@ -62,7 +63,8 @@ namespace basegfx
{
SystemDependentData::SystemDependentData(
SystemDependentDataManager& rSystemDependentDataManager)
- : mrSystemDependentDataManager(rSystemDependentDataManager)
+ : mrSystemDependentDataManager(rSystemDependentDataManager),
+ mnCalculatedCycles(0)
{
}
@@ -70,6 +72,49 @@ namespace basegfx
{
}
+ sal_uInt32 SystemDependentData::calculateCombinedHoldCyclesInSeconds() const
+ {
+ if(0 == mnCalculatedCycles)
+ {
+ const sal_Int64 nBytes(estimateUsageInBytes());
+ const sal_uInt32 nSeconds(getHoldCyclesInSeconds());
+
+ // default is Seconds (minimal is one)
+ sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);
+
+ if(0 != nBytes)
+ {
+ // use sqrt to get some curved shape. With a default of 60s we get
+ // a single second at 3600 byte. To get close to 10mb, multiply by
+ // a corresponding scaling factor
+ const double fScaleToMB(3600.0 / (1024.0 * 1024.0 * 10.0));
+
+ // also use a multiplier to move the start point higer
+ const double fMultiplierSeconds(10.0);
+
+ // calculate
+ nResult = static_cast<sal_uInt32>((fMultiplierSeconds * nSeconds) / sqrt(nBytes * fScaleToMB));
+
+ // minimal value is 1
+ if(nResult < 1)
+ {
+ nResult = 1;
+ }
+
+ // maximal value is nSeconds
+ if(nResult > nSeconds)
+ {
+ nResult = nSeconds;
+ }
+ }
+
+ // set locally (once, on-demand created, non-zero)
+ const_cast<SystemDependentData*>(this)->mnCalculatedCycles = nResult < 1 ? 1 : nResult;
+ }
+
+ return mnCalculatedCycles;
+ }
+
sal_uInt32 SystemDependentData::getHoldCyclesInSeconds() const
{
// default implementation returns 60(s)