Re-enable inst counting in debug builds.

R=robertphillips@google.com
Review URL: https://codereview.appspot.com/7098066

git-svn-id: http://skia.googlecode.com/svn/trunk@7206 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index fb6d376..2a92dfa 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -398,7 +398,7 @@
 
 int tool_main(int argc, char** argv);
 int tool_main(int argc, char** argv) {
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
     gPrintInstCount = true;
 #endif
     SkAutoGraphics ag;
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 964bafa..573c9dc 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -959,7 +959,7 @@
 int tool_main(int argc, char** argv);
 int tool_main(int argc, char** argv) {
 
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
     gPrintInstCount = true;
 #endif
 
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
index 2b1be9f..63fc90d 100644
--- a/include/config/SkUserConfig.h
+++ b/include/config/SkUserConfig.h
@@ -79,7 +79,7 @@
     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
+//#define SK_ENABLE_INST_COUNT 1
 
 /*  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 02b63db..e7f752e 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -18,12 +18,9 @@
  * At the end of an application a call to all the "root" objects'
  * CheckInstanceCount methods should be made
  */
-//#if defined SK_DEBUG && !defined SK_ENABLE_INST_COUNT
-//#define SK_ENABLE_INST_COUNT
-//#endif
+#include "SkTypes.h"
 
-#ifdef SK_ENABLE_INST_COUNT
-#include <stdlib.h>
+#if SK_ENABLE_INST_COUNT
 #include "SkTArray.h"
 #include "SkThread_platform.h"
 
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index 86798e4..128cfa4 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -112,6 +112,17 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
+// SK_ENABLE_INST_COUNT defaults to 1 in DEBUG and 0 in RELEASE
+#ifndef SK_ENABLE_INST_COUNT
+    #ifdef SK_DEBUG
+        #define SK_ENABLE_INST_COUNT 1
+    #else
+        #define SK_ENABLE_INST_COUNT 0
+    #endif
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
 #if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT)
     // if this is defined, we convert floats to 2scompliment ints for compares
     #ifndef SK_SCALAR_SLOW_COMPARES
diff --git a/src/core/SkInstCnt.cpp b/src/core/SkInstCnt.cpp
index d22639e..2f9a57d 100644
--- a/src/core/SkInstCnt.cpp
+++ b/src/core/SkInstCnt.cpp
@@ -7,6 +7,6 @@
 
 #include "SkInstCnt.h"
 
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
 bool gPrintInstCount = false;
 #endif
diff --git a/tests/GrMemoryPoolTest.cpp b/tests/GrMemoryPoolTest.cpp
index 3f00f67..8660ea2 100644
--- a/tests/GrMemoryPoolTest.cpp
+++ b/tests/GrMemoryPoolTest.cpp
@@ -50,7 +50,7 @@
     static A* Create(SkRandom* r);
 
     static void SetAllocator(size_t preallocSize, size_t minAllocSize) {
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(0 == GetInstanceCount());
 #endif
         GrMemoryPool* pool = new GrMemoryPool(preallocSize, minAllocSize);
@@ -58,7 +58,7 @@
     }
 
     static void ResetAllocator() {
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(0 == GetInstanceCount());
 #endif
         gPool.reset(NULL);
@@ -233,7 +233,7 @@
                 REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue));
                 delete rec.fInstance;
             }
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
             REPORTER_ASSERT(reporter, !A::GetInstanceCount());
 #endif
         }
diff --git a/tests/LListTest.cpp b/tests/LListTest.cpp
index 89c4971..ab36ef5 100644
--- a/tests/LListTest.cpp
+++ b/tests/LListTest.cpp
@@ -16,7 +16,7 @@
     }
     bool operator== (const ListElement& other) { return fID == other.fID; }
 
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
     // Make the instance count available publicly.
     static int InstanceCount() { return GetInstanceCount(); }
 #endif
@@ -135,7 +135,7 @@
         Iter iter3;
         Iter iter4;
 
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(0 == ListElement::InstanceCount());
 #endif
 
@@ -151,7 +151,7 @@
         // Create two identical lists, one by appending to head and the other to the tail.
         list1.addToHead(ListElement(1));
         list2.addToTail(ListElement(1));
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(2 == ListElement::InstanceCount());
 #endif
         iter1.init(list1, Iter::kHead_IterStart);
@@ -178,7 +178,7 @@
         iter4.init(list2, Iter::kTail_IterStart);
         list2.addToHead(ListElement(2));
 
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(3 == ListElement::InstanceCount());
 #endif
 
@@ -189,14 +189,14 @@
         REPORTER_ASSERT(reporter, list1 != list2);
         list1.addToHead(ListElement(2));
         REPORTER_ASSERT(reporter, list1 == list2);
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(4 == ListElement::InstanceCount());
 #endif
         REPORTER_ASSERT(reporter, !list1.isEmpty());
 
         list1.reset();
         list2.reset();
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(0 == ListElement::InstanceCount());
 #endif
         REPORTER_ASSERT(reporter, list1.isEmpty() && list2.isEmpty());
@@ -301,12 +301,12 @@
                 --count;
             }
             REPORTER_ASSERT(reporter, count == list1.count());
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
             SkASSERT(count == ListElement::InstanceCount());
 #endif
         }
         list1.reset();
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
         SkASSERT(0 == ListElement::InstanceCount());
 #endif
     }
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 5e944f7..84318da 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -84,7 +84,7 @@
 
 int tool_main(int argc, char** argv);
 int tool_main(int argc, char** argv) {
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
     gPrintInstCount = true;
 #endif
     SkGraphics::Init();
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 73c9a7d..582cf43 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -774,7 +774,7 @@
 
 int tool_main(int argc, char** argv);
 int tool_main(int argc, char** argv) {
-#ifdef SK_ENABLE_INST_COUNT
+#if SK_ENABLE_INST_COUNT
     gPrintInstCount = true;
 #endif
     SkAutoGraphics ag;