| 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 29 matching lines...) Expand all Loading... |
| 40 // The root classes registers a function to print out the memory stats when | 40 // The root classes registers a function to print out the memory stats when |
| 41 // the app ends | 41 // the app ends |
| 42 #define SK_DECLARE_INST_COUNT_ROOT(className) \ | 42 #define SK_DECLARE_INST_COUNT_ROOT(className) \ |
| 43 SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);) | 43 SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);) |
| 44 | 44 |
| 45 #define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep) \ | 45 #define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep) \ |
| 46 class SkInstanceCountHelper { \ | 46 class SkInstanceCountHelper { \ |
| 47 public: \ | 47 public: \ |
| 48 SkInstanceCountHelper() { \ | 48 SkInstanceCountHelper() { \ |
| 49 SK_DECLARE_STATIC_ONCE(once); \ | 49 SK_DECLARE_STATIC_ONCE(once); \ |
| 50 SkOnce(&once, init, 0); \ | 50 SkOnce(&once, init); \ |
| 51 sk_atomic_inc(GetInstanceCountPtr()); \ | 51 sk_atomic_inc(GetInstanceCountPtr()); \ |
| 52 } \ | 52 } \ |
| 53 \ | 53 \ |
| 54 static void init(int) { \ | 54 static void init() { \ |
| 55 initStep \ | 55 initStep \ |
| 56 } \ | 56 } \ |
| 57 \ | 57 \ |
| 58 SkInstanceCountHelper(const SkInstanceCountHelper&) { \ | 58 SkInstanceCountHelper(const SkInstanceCountHelper&) { \ |
| 59 sk_atomic_inc(GetInstanceCountPtr()); \ | 59 sk_atomic_inc(GetInstanceCountPtr()); \ |
| 60 } \ | 60 } \ |
| 61 \ | 61 \ |
| 62 ~SkInstanceCountHelper() { \ | 62 ~SkInstanceCountHelper() { \ |
| 63 sk_atomic_dec(GetInstanceCountPtr()); \ | 63 sk_atomic_dec(GetInstanceCountPtr()); \ |
| 64 } \ | 64 } \ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 #define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED:
:AddInstChild(); } | 133 #define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED:
:AddInstChild(); } |
| 134 #define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { } | 134 #define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { } |
| 135 #endif | 135 #endif |
| 136 | 136 |
| 137 // Following are deprecated. They are defined only for backwards API compatibili
ty. | 137 // 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) | 138 #define SK_DECLARE_INST_COUNT_TEMPLATE(className) SK_DECLARE_INST_COUNT(classNam
e) |
| 139 #define SK_DEFINE_INST_COUNT(className) | 139 #define SK_DEFINE_INST_COUNT(className) |
| 140 #define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className) | 140 #define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className) |
| 141 | 141 |
| 142 #endif // SkInstCnt_DEFINED | 142 #endif // SkInstCnt_DEFINED |
| OLD | NEW |