Allow cache tracking to be enabled in release
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 31 Aug 2012 13:07:37 +0000 (13:07 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 31 Aug 2012 13:07:37 +0000 (13:07 +0000)
https://codereview.appspot.com/6500057/

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

gm/gmmain.cpp
include/gpu/GrConfig.h
include/gpu/GrContext.h
src/gpu/GrContext.cpp
src/gpu/GrResourceCache.cpp
src/gpu/GrResourceCache.h

index feee33d00237db937f6d6cd87e44c584c47053d4..f13d99fd0a5e70d09b17024306adec200c845b66 100644 (file)
@@ -1151,7 +1151,7 @@ int main(int argc, char * const argv[]) {
 
 #if SK_SUPPORT_GPU
 
-#if SK_DEBUG
+#if GR_CACHE_STATS
     for (int i = 0; i < configs.count(); i++) {
         ConfigData config = gRec[configs[i]];
 
index 327dbb44b14897c33fb88ccf8b51cb7a8d9a2292..c61c34e193b4082e32245136af20a912c47735b3 100644 (file)
@@ -11,6 +11,8 @@
 #ifndef GrConfig_DEFINED
 #define GrConfig_DEFINED
 
+#include "SkTypes.h"
+
 ///////////////////////////////////////////////////////////////////////////////
 // preconfig section:
 //
@@ -48,6 +50,9 @@
 #if !defined(GR_QNX_BUILD)
     #define GR_QNX_BUILD        0
 #endif
+#if !defined(GR_CACHE_STATS)
+    #define GR_CACHE_STATS      0
+#endif
 
 /**
  *  If no build target has been defined, attempt to infer.
index d4657a76e5633e5e6b323b227ba28ff97ceb277d..f456a81ad28230c1209d3777ebeee0eed24201e3 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef GrContext_DEFINED
 #define GrContext_DEFINED
 
+#include "GrConfig.h"
 #include "GrPaint.h"
 #include "GrAARectRenderer.h"
 #include "GrClipData.h"
@@ -775,7 +776,7 @@ public:
                                     bool antiAlias,
                                     bool allowSW);
 
-#ifdef GR_DEBUG
+#if GR_CACHE_STATS
     void printCacheStats() const;
 #endif
 
index 6a4a5579db833f3f4df2e7f350f29c636fc9dc4f..2c724b51ee3ed32e1817e134e20363315ccfa97f 100644 (file)
@@ -1964,7 +1964,7 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-#if GR_DEBUG
+#if GR_CACHE_STATS
 void GrContext::printCacheStats() const {
     fTextureCache->printStats();
 }
index 3a3bd7344851815ce72daa7c1f1b1cd0664998df..ee127c846ca81cfd88508a7dedf55493d759523c 100644 (file)
@@ -68,7 +68,7 @@ public:
 GrResourceCache::GrResourceCache(int maxCount, size_t maxBytes) :
         fMaxCount(maxCount),
         fMaxBytes(maxBytes) {
-#if GR_DEBUG
+#if GR_CACHE_STATS
     fHighWaterEntryCount          = 0;
     fHighWaterUnlockedEntryCount  = 0;
     fHighWaterEntryBytes          = 0;
@@ -137,7 +137,7 @@ void GrResourceCache::internalDetach(GrResourceEntry* entry,
         fClientDetachedCount += 1;
         fClientDetachedBytes += entry->resource()->sizeInBytes();
 
-#if GR_DEBUG
+#if GR_CACHE_STATS
         if (fHighWaterClientDetachedCount < fClientDetachedCount) {
             fHighWaterClientDetachedCount = fClientDetachedCount;
         }
@@ -158,7 +158,7 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry,
 
     if (!entry->isLocked()) {
         ++fUnlockedEntryCount;
-#if GR_DEBUG
+#if GR_CACHE_STATS
         if (fHighWaterUnlockedEntryCount < fUnlockedEntryCount) {
             fHighWaterUnlockedEntryCount = fUnlockedEntryCount;
         }
@@ -173,7 +173,7 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry,
         fEntryCount += 1;
         fEntryBytes += entry->resource()->sizeInBytes();
 
-#if GR_DEBUG
+#if GR_CACHE_STATS
         if (fHighWaterEntryCount < fEntryCount) {
             fHighWaterEntryCount = fEntryCount;
         }
@@ -308,7 +308,7 @@ void GrResourceCache::unlock(GrResourceEntry* entry) {
     entry->unlock();
     if (!entry->isLocked()) {
         ++fUnlockedEntryCount;
-#if GR_DEBUG
+#if GR_CACHE_STATS
         if (fHighWaterUnlockedEntryCount < fUnlockedEntryCount) {
             fHighWaterUnlockedEntryCount = fUnlockedEntryCount;
         }
@@ -472,6 +472,9 @@ void GrResourceCache::validate() const {
 
     GrAssert(fExclusiveList.countEntries() == fClientDetachedCount);
 }
+#endif // GR_DEBUG
+
+#if GR_CACHE_STATS
 
 void GrResourceCache::printStats() const {
     SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
index 00e62ea923159539a373dc7b7be9a2b39eadf0ee..bfa528d30591ba5d1fc534a2f7937a6737c1f89b 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef GrResourceCache_DEFINED
 #define GrResourceCache_DEFINED
 
+#include "GrConfig.h"
 #include "GrTypes.h"
 #include "GrTHashCache.h"
 #include "SkTDLinkedList.h"
@@ -297,11 +298,14 @@ public:
 
 #if GR_DEBUG
     void validate() const;
-    void printStats() const;
 #else
     void validate() const {}
 #endif
 
+#if GR_CACHE_STATS
+    void printStats() const;
+#endif
+
 private:
     void internalDetach(GrResourceEntry*, bool);
     void attachToHead(GrResourceEntry*, bool);
@@ -326,7 +330,7 @@ private:
     size_t fMaxBytes;
 
     // our current stats, related to our budget
-#if GR_DEBUG
+#if GR_CACHE_STATS
     int fHighWaterEntryCount;
     int fHighWaterUnlockedEntryCount;
     size_t fHighWaterEntryBytes;