OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkInstCnt_DEFINED | 9 #ifndef SkInstCnt_DEFINED |
10 #define SkInstCnt_DEFINED | 10 #define SkInstCnt_DEFINED |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 static int32_t* GetInstanceCountPtr() { \ | 66 static int32_t* GetInstanceCountPtr() { \ |
67 static int32_t gInstanceCount; \ | 67 static int32_t gInstanceCount; \ |
68 return &gInstanceCount; \ | 68 return &gInstanceCount; \ |
69 } \ | 69 } \ |
70 \ | 70 \ |
71 static SkTArray<int (*)(int, bool)>*& GetChildren() { \ | 71 static SkTArray<int (*)(int, bool)>*& GetChildren() { \ |
72 static SkTArray<int (*)(int, bool)>* gChildren; \ | 72 static SkTArray<int (*)(int, bool)>* gChildren; \ |
73 return gChildren; \ | 73 return gChildren; \ |
74 } \ | 74 } \ |
75 \ | 75 \ |
76 static void create_mutex(SkMutex** mutex) { \ | |
77 *mutex = SkNEW(SkMutex); \ | |
78 } \ | |
76 static SkBaseMutex& GetChildrenMutex() { \ | 79 static SkBaseMutex& GetChildrenMutex() { \ |
77 SK_DECLARE_STATIC_MUTEX(childrenMutex); \ | 80 static SkMutex* childrenMutex; \ |
78 return childrenMutex; \ | 81 SK_DECLARE_STATIC_ONCE(once); \ |
82 SkOnce(&once, className::SkInstanceCountHelper::create_mutex, &child renMutex);\ | |
83 return *childrenMutex; \ | |
bungeman-skia
2014/07/25 15:44:07
Making this body look like
SK_DECLARE_STATIC_LAZY
| |
79 } \ | 84 } \ |
80 \ | 85 \ |
81 } fInstanceCountHelper; \ | 86 } fInstanceCountHelper; \ |
82 \ | 87 \ |
83 static int32_t GetInstanceCount() { \ | 88 static int32_t GetInstanceCount() { \ |
84 return *SkInstanceCountHelper::GetInstanceCountPtr(); \ | 89 return *SkInstanceCountHelper::GetInstanceCountPtr(); \ |
85 } \ | 90 } \ |
86 \ | 91 \ |
87 static void exitPrint() { \ | 92 static void exitPrint() { \ |
88 CheckInstanceCount(0, true); \ | 93 CheckInstanceCount(0, true); \ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 #define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED: :AddInstChild(); } | 138 #define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED: :AddInstChild(); } |
134 #define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { } | 139 #define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { } |
135 #endif | 140 #endif |
136 | 141 |
137 // Following are deprecated. They are defined only for backwards API compatibili ty. | 142 // Following are deprecated. They are defined only for backwards API compatibili ty. |
138 #define SK_DECLARE_INST_COUNT_TEMPLATE(className) SK_DECLARE_INST_COUNT(classNam e) | 143 #define SK_DECLARE_INST_COUNT_TEMPLATE(className) SK_DECLARE_INST_COUNT(classNam e) |
139 #define SK_DEFINE_INST_COUNT(className) | 144 #define SK_DEFINE_INST_COUNT(className) |
140 #define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className) | 145 #define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className) |
141 | 146 |
142 #endif // SkInstCnt_DEFINED | 147 #endif // SkInstCnt_DEFINED |
OLD | NEW |