Allow default texture cache limit to be set within gyp.
authordjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 29 Oct 2012 19:24:45 +0000 (19:24 +0000)
committerdjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 29 Oct 2012 19:24:45 +0000 (19:24 +0000)
Review URL: https://codereview.appspot.com/6818051

git-svn-id: http://skia.googlecode.com/svn/trunk@6177 2bbb7eff-a529-9590-31e7-b0007b416f81

gyp/common_variables.gypi
gyp/gpu.gyp
include/gpu/GrConfig.h
include/gpu/GrUserConfig.h
src/gpu/GrContext.cpp

index 3d19e62..6acf5bc 100644 (file)
@@ -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)',
index 0dc84ee..9cb0698 100644 (file)
           ],
         },
       }],
+      [ 'skia_texture_cache_mb_limit != 0', {
+        'defines': [
+          'GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT=<(skia_texture_cache_mb_limit)',
+        ],
+      }],
     ],
     'direct_dependent_settings': {
       'conditions': [
index c61c34e..66d1c97 100644 (file)
@@ -369,6 +369,15 @@ inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); }
     #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:
 //
index d514486..7b4e4bb 100644 (file)
  */
 //#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
 
index b2733c2..900af8a 100644 (file)
@@ -49,7 +49,7 @@ SK_DEFINE_INST_COUNT(GrDrawState)
 #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;