From 4649ee47134c9985a626e2354a43d201e043e9cc Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 23 Sep 2016 11:40:25 -0400 Subject: [PATCH] Bug 1303054 - use dynamic cache size with SkiaGL on desktop. r=milan MozReview-Commit-ID: 3Hhsa1SNcXw --- gfx/thebes/gfxPlatform.cpp | 15 +++++++++------ gfx/thebes/gfxPlatform.h | 2 +- modules/libpref/init/all.js | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 1eb04b62bb90..3706356266f4 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -100,8 +100,6 @@ #include "mozilla/layers/GrallocTextureHost.h" #endif -#include "mozilla/Hal.h" - #ifdef USE_SKIA # ifdef __GNUC__ # pragma GCC diagnostic push @@ -144,6 +142,7 @@ class mozilla::gl::SkiaGLGlue : public GenericAtomicRefCounted { #include "gfxVR.h" #include "VRManagerChild.h" #include "mozilla/gfx/GPUParent.h" +#include "prsystem.h" namespace mozilla { namespace layers { @@ -506,7 +505,8 @@ gfxPlatform::gfxPlatform() #endif InitBackendPrefs(canvasMask, BackendType::CAIRO, contentMask, BackendType::CAIRO); - mTotalSystemMemory = mozilla::hal::GetTotalSystemMemory(); + + mTotalSystemMemory = PR_GetPhysicalMemorySize(); VRManager::ManagerInit(); } @@ -1274,7 +1274,7 @@ gfxPlatform::InitializeSkiaCacheLimits() #ifdef USE_SKIA_GPU bool usingDynamicCache = gfxPrefs::CanvasSkiaGLDynamicCache(); int cacheItemLimit = gfxPrefs::CanvasSkiaGLCacheItems(); - int cacheSizeLimit = gfxPrefs::CanvasSkiaGLCacheSize(); + uint64_t cacheSizeLimit = std::max(gfxPrefs::CanvasSkiaGLCacheSize(), (int32_t)0); // Prefs are in megabytes, but we want the sizes in bytes cacheSizeLimit *= 1024*1024; @@ -1289,11 +1289,14 @@ gfxPlatform::InitializeSkiaCacheLimits() } } + // Ensure cache size doesn't overflow on 32-bit platforms. + cacheSizeLimit = std::min(cacheSizeLimit, (uint64_t)SIZE_MAX); + #ifdef DEBUG - printf_stderr("Determined SkiaGL cache limits: Size %i, Items: %i\n", cacheSizeLimit, cacheItemLimit); + printf_stderr("Determined SkiaGL cache limits: Size %" PRIu64 ", Items: %i\n", cacheSizeLimit, cacheItemLimit); #endif - mSkiaGlue->GetGrContext()->setResourceCacheLimits(cacheItemLimit, cacheSizeLimit); + mSkiaGlue->GetGrContext()->setResourceCacheLimits(cacheItemLimit, (size_t)cacheSizeLimit); #endif } } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index fd7da22b7834..2d630386f7fd 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -770,7 +770,7 @@ protected: // max number of entries in word cache int32_t mWordCacheMaxEntries; - uint32_t mTotalSystemMemory; + uint64_t mTotalSystemMemory; // Hardware vsync source. Only valid on parent process RefPtr mVsyncSource; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 4f5a45cb0399..38c763cb0bc1 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -786,6 +786,8 @@ pref("gfx.content.azure.backends", "skia"); #endif #endif +pref("gfx.canvas.skiagl.dynamic-cache", true); + pref("gfx.text.disable-aa", false); pref("gfx.work-around-driver-bugs", true);