#include "SkRandom.h"
#include "SkTArray.h"
-class SkDoOnce : SkNoncopyable {
+class SkOnce : SkNoncopyable {
public:
- SkDoOnce() { fDidOnce = false; }
+ SkOnce() { fDidOnce = false; }
bool needToDo() const { return !fDidOnce; }
bool alreadyDone() const { return fDidOnce; }
namespace skiagm {
class ConvexPathsGM : public GM {
- SkDoOnce fOnce;
+ SkOnce fOnce;
public:
ConvexPathsGM() {
this->setBGColor(0xFF000000);
#include "SkTypes.h"
#if SK_ENABLE_INST_COUNT
-#include "SkOnce.h"
#include "SkTArray.h"
#include "SkThread_platform.h"
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()); \
} \
return gChildren; \
} \
\
- static SkBaseMutex& GetChildrenMutex() { \
- SK_DECLARE_STATIC_MUTEX(childrenMutex); \
- return childrenMutex; \
- } \
- \
} fInstanceCountHelper; \
\
static int32_t GetInstanceCount() { \
if (NULL == SkInstanceCountHelper::GetChildren()) { \
return GetInstanceCount(); \
} \
- SkTArray<typename SkInstanceCountHelper::PFCheckInstCnt>* children = \
+ SkTArray<int (*)(int, bool)>* children = \
SkInstanceCountHelper::GetChildren(); \
int childCount = children->count(); \
int count = GetInstanceCount(); \
} \
\
static void AddInstChild(int (*childCheckInstCnt)(int, bool)) { \
- if (CheckInstanceCount != childCheckInstCnt) { \
- SkAutoMutexAcquire ama(SkInstanceCountHelper::GetChildrenMutex()); \
- if (NULL == SkInstanceCountHelper::GetChildren()) { \
- SkInstanceCountHelper::GetChildren() = \
- new SkTArray<typename SkInstanceCountHelper::PFCheckInstCnt>; \
- } \
+ if (CheckInstanceCount != childCheckInstCnt && \
+ NULL != SkInstanceCountHelper::GetChildren()) { \
SkInstanceCountHelper::GetChildren()->push_back(childCheckInstCnt); \
} \
}
* SK_ENABLE_INST_COUNT controlls printing how many reference counted objects
* are still held on exit.
* Defaults to 1 in DEBUG and 0 in RELEASE.
+ * FIXME: currently always 0, since it fails if multiple threads run at once
+ * (see skbug.com/1219 ).
*/
#ifndef SK_ENABLE_INST_COUNT
# ifdef SK_DEBUG
-# define SK_ENABLE_INST_COUNT 1
+# define SK_ENABLE_INST_COUNT 0
# else
# define SK_ENABLE_INST_COUNT 0
# endif