diff options
-rw-r--r-- | bench/benchmain.cpp | 2 | ||||
-rw-r--r-- | gm/gmmain.cpp | 2 | ||||
-rw-r--r-- | include/config/SkUserConfig.h | 2 | ||||
-rw-r--r-- | include/core/SkInstCnt.h | 7 | ||||
-rw-r--r-- | include/core/SkPostConfig.h | 11 | ||||
-rw-r--r-- | src/core/SkInstCnt.cpp | 2 | ||||
-rw-r--r-- | tests/GrMemoryPoolTest.cpp | 6 | ||||
-rw-r--r-- | tests/LListTest.cpp | 16 | ||||
-rw-r--r-- | tests/skia_test.cpp | 2 | ||||
-rw-r--r-- | tools/bench_pictures_main.cpp | 2 |
10 files changed, 30 insertions, 22 deletions
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index fb6d376678..2a92dfa010 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -398,7 +398,7 @@ static void help() { 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 964bafa9ad..573c9dce78 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -959,7 +959,7 @@ template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { 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 2b1be9f49d..63fc90db72 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 02b63dba99..e7f752edf5 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 86798e40ce..128cfa4dc3 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 d22639ee50..2f9a57dc2b 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 3f00f673c5..8660ea2a3b 100644 --- a/tests/GrMemoryPoolTest.cpp +++ b/tests/GrMemoryPoolTest.cpp @@ -50,7 +50,7 @@ public: 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 @@ public: } static void ResetAllocator() { -#ifdef SK_ENABLE_INST_COUNT +#if SK_ENABLE_INST_COUNT SkASSERT(0 == GetInstanceCount()); #endif gPool.reset(NULL); @@ -233,7 +233,7 @@ static void test_memory_pool(skiatest::Reporter* reporter) { 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 89c4971b96..ab36ef53ce 100644 --- a/tests/LListTest.cpp +++ b/tests/LListTest.cpp @@ -16,7 +16,7 @@ public: } 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 @@ static void TestTLList(skiatest::Reporter* reporter) { Iter iter3; Iter iter4; -#ifdef SK_ENABLE_INST_COUNT +#if SK_ENABLE_INST_COUNT SkASSERT(0 == ListElement::InstanceCount()); #endif @@ -151,7 +151,7 @@ static void TestTLList(skiatest::Reporter* reporter) { // 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 @@ static void TestTLList(skiatest::Reporter* reporter) { 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 @@ static void TestTLList(skiatest::Reporter* reporter) { 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 @@ static void TestTLList(skiatest::Reporter* reporter) { --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 5e944f7774..84318da824 100644 --- a/tests/skia_test.cpp +++ b/tests/skia_test.cpp @@ -84,7 +84,7 @@ private: 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 73c9a7d188..582cf43d43 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -774,7 +774,7 @@ static int process_input(const SkString& input, 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; |