Allow default texture cache limit to be set within gyp.
Review URL: https://codereview.appspot.com/6818051
git-svn-id: http://skia.googlecode.com/svn/trunk@6177 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi
index 3d19e62..6acf5bc 100644
--- a/gyp/common_variables.gypi
+++ b/gyp/common_variables.gypi
@@ -81,6 +81,7 @@
'skia_scalar%': 'float',
'skia_mesa%': 0,
'skia_nv_path_rendering%': 0,
+ 'skia_texture_cache_mb_limit%': 0,
'skia_angle%': 0,
'skia_directwrite%': 0,
'skia_nacl%': 0,
@@ -97,6 +98,7 @@
'skia_scalar%': '<(skia_scalar)',
'skia_mesa%': '<(skia_mesa)',
'skia_nv_path_rendering%': '<(skia_nv_path_rendering)',
+ 'skia_texture_cache_mb_limit%': '<(skia_texture_cache_mb_limit)',
'skia_angle%': '<(skia_angle)',
'skia_arch_width%': '<(skia_arch_width)',
'skia_arch_type%': '<(skia_arch_type)',
diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp
index 0dc84ee..9cb0698 100644
--- a/gyp/gpu.gyp
+++ b/gyp/gpu.gyp
@@ -71,6 +71,11 @@
],
},
}],
+ [ 'skia_texture_cache_mb_limit != 0', {
+ 'defines': [
+ 'GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT=<(skia_texture_cache_mb_limit)',
+ ],
+ }],
],
'direct_dependent_settings': {
'conditions': [
diff --git a/include/gpu/GrConfig.h b/include/gpu/GrConfig.h
index c61c34e..66d1c97 100644
--- a/include/gpu/GrConfig.h
+++ b/include/gpu/GrConfig.h
@@ -369,6 +369,15 @@
#define GR_GEOM_BUFFER_LOCK_THRESHOLD (1 << 15)
#endif
+/**
+ * GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT gives a threshold (in megabytes) for the
+ * maximum size of the texture cache in vram. The value is only a default and
+ * can be overridden at runtime.
+ */
+#if !defined(GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT)
+ #define GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT 96
+#endif
+
///////////////////////////////////////////////////////////////////////////////
// tail section:
//
diff --git a/include/gpu/GrUserConfig.h b/include/gpu/GrUserConfig.h
index d514486..7b4e4bb 100644
--- a/include/gpu/GrUserConfig.h
+++ b/include/gpu/GrUserConfig.h
@@ -54,6 +54,12 @@
*/
//#define GR_GEOM_BUFFER_LOCK_THRESHOLD (1<<15)
+/**
+ * This gives a threshold in megabytes for the maximum size of the texture cache
+ * in vram. The value is only a default and can be overridden at runtime.
+ */
+//#define GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT 96
+
///////////////////////////////////////////////////////////////////////////////
// Decide Ganesh types
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b2733c2..900af8a 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -49,7 +49,7 @@
#endif
static const size_t MAX_TEXTURE_CACHE_COUNT = 2048;
-static const size_t MAX_TEXTURE_CACHE_BYTES = 96 * 1024 * 1024;
+static const size_t MAX_TEXTURE_CACHE_BYTES = GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT * 1024 * 1024;
static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15;
static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4;