Separated Inst counting from the SK_DEBUG #define (now SK_ENABLE_INST_COUNT)

http://codereview.appspot.com/6353047/



git-svn-id: http://skia.googlecode.com/svn/trunk@4376 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
index e7f781d..b180c89 100644
--- a/include/config/SkUserConfig.h
+++ b/include/config/SkUserConfig.h
@@ -65,6 +65,12 @@
 //#define SK_DEBUG
 //#define SK_RELEASE
 
+/*  To assist debugging, Skia provides an instance counting utility in
+    include/core/SkInstCount.h. This flag turns on and off that utility to
+    allow instance count tracking in either debug or release builds. By 
+    default it is enabled in debug but disabled in release.
+ */
+//#define SK_ENABLE_INST_COUNT
 
 /*  If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
     it will call SK_CRASH(). If this is not defined it, it is defined in
diff --git a/include/core/SkInstCnt.h b/include/core/SkInstCnt.h
index ff9a19f..18ea9bb 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -18,9 +18,11 @@
  * At the end of an application a call to all the "root" objects'
  * CheckInstanceCount methods should be made
  */
-#ifdef SK_DEBUG
+#ifdef SK_ENABLE_INST_COUNT
 #include "SkTArray.h"
 
+extern bool gPrintInstCount;
+
 #define SK_DECLARE_INST_COUNT(className)                                    \
     SK_DECLARE_INST_COUNT_INTERNAL(className,                               \
                                 INHERITED::AddInstChild(CheckInstanceCount);)
@@ -58,7 +60,7 @@
     }                                                                       \
                                                                             \
     static int CheckInstanceCount(int level = 0) {                          \
-        if (0 != SkInstanceCountHelper::gInstanceCount) {                   \
+        if (gPrintInstCount && 0 != SkInstanceCountHelper::gInstanceCount) {\
             SkDebugf("%*c Leaked %s: %d\n",                                 \
                      4*level, ' ', #className,                              \
                      SkInstanceCountHelper::gInstanceCount);                \
@@ -69,7 +71,7 @@
             count -= (*SkInstanceCountHelper::gChildren[i])(level+1);       \
         }                                                                   \
         SkASSERT(count >= 0);                                               \
-        if (childCount > 0 && count > 0) {                                  \
+        if (gPrintInstCount && childCount > 0 && count > 0) {               \
             SkDebugf("%*c Leaked ???: %d\n", 4*(level + 1), ' ', count);    \
         }                                                                   \
         return SkInstanceCountHelper::gInstanceCount;                       \