Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: include/core/SkInstCnt.h

Issue 138683006: Revert "Make leak counters thread-safe and turn them on by default for Debug" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/core.gypi ('k') | include/core/SkOnce.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkInstCnt.h
diff --git a/include/core/SkInstCnt.h b/include/core/SkInstCnt.h
index 1c1770ac487baece8006977180d40e3789abde5e..89bbfa1126d12017b6a77486421baa8ad22f4b46 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -20,7 +20,6 @@
#include "SkTypes.h"
#if SK_ENABLE_INST_COUNT
-#include "SkOnce.h"
#include "SkTArray.h"
#include "SkThread.h"
@@ -39,16 +38,17 @@ extern bool gPrintInstCount;
#define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep) \
class SkInstanceCountHelper { \
public: \
+ typedef int (*PFCheckInstCnt)(int level, bool cleanUp); \
SkInstanceCountHelper() { \
- SK_DECLARE_STATIC_ONCE(once); \
- SkOnce(&once, init, 0); \
+ static bool gInited; \
+ if (!gInited) { \
+ initStep \
+ GetChildren() = new SkTArray<PFCheckInstCnt>; \
+ gInited = true; \
+ } \
sk_atomic_inc(GetInstanceCountPtr()); \
} \
\
- static void init(int) { \
- initStep \
- } \
- \
SkInstanceCountHelper(const SkInstanceCountHelper&) { \
sk_atomic_inc(GetInstanceCountPtr()); \
} \
@@ -62,16 +62,11 @@ extern bool gPrintInstCount;
return &gInstanceCount; \
} \
\
- static SkTArray<int (*)(int, bool)>*& GetChildren() { \
- static SkTArray<int (*)(int, bool)>* gChildren; \
+ static SkTArray<PFCheckInstCnt>*& GetChildren() { \
+ static SkTArray<PFCheckInstCnt>* gChildren; \
return gChildren; \
} \
\
- static SkBaseMutex& GetChildrenMutex() { \
- SK_DECLARE_STATIC_MUTEX(childrenMutex); \
- return childrenMutex; \
- } \
- \
} fInstanceCountHelper; \
\
static int32_t GetInstanceCount() { \
@@ -91,7 +86,7 @@ extern bool gPrintInstCount;
if (NULL == SkInstanceCountHelper::GetChildren()) { \
return GetInstanceCount(); \
} \
- SkTArray<int (*)(int, bool)>* children = \
+ SkTArray<int (*)(int, bool)>* children = \
SkInstanceCountHelper::GetChildren(); \
int childCount = children->count(); \
int count = GetInstanceCount(); \
@@ -110,12 +105,8 @@ extern bool gPrintInstCount;
} \
\
static void AddInstChild(int (*childCheckInstCnt)(int, bool)) { \
- if (CheckInstanceCount != childCheckInstCnt) { \
- SkAutoMutexAcquire ama(SkInstanceCountHelper::GetChildrenMutex()); \
- if (NULL == SkInstanceCountHelper::GetChildren()) { \
- SkInstanceCountHelper::GetChildren() = \
- new SkTArray<int (*)(int, bool)>; \
- } \
+ if (CheckInstanceCount != childCheckInstCnt && \
+ NULL != SkInstanceCountHelper::GetChildren()) { \
SkInstanceCountHelper::GetChildren()->push_back(childCheckInstCnt); \
} \
}
« no previous file with comments | « gyp/core.gypi ('k') | include/core/SkOnce.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698