static GrContext* Create(GrEngine engine,
GrPlatform3DContext context3D);
+ /**
+ * Returns the number of GrContext instances for the current thread.
+ */
+ static int GetThreadInstanceCount();
+
virtual ~GrContext();
/**
#include "GrStencilBuffer.h"
#include "GrTextStrike.h"
#include "SkTLazy.h"
+#include "SkTLS.h"
#include "SkTrace.h"
#define DEFER_TEXT_RENDERING 1
return ctx;
}
+namespace {
+void* CreateThreadInstanceCount() {
+ return new int(0);
+}
+void DeleteThreadInstanceCount(void* v) {
+ delete reinterpret_cast<int*>(v);
+}
+#define THREAD_INSTANCE_COUNT \
+ (*reinterpret_cast<int*>(SkTLS::Get(CreateThreadInstanceCount, \
+ DeleteThreadInstanceCount)))
+
+}
+
+int GrContext::GetThreadInstanceCount() {
+ return THREAD_INSTANCE_COUNT;
+}
+
GrContext::~GrContext() {
this->flush();
GrSafeUnref(fPathRendererChain);
GrSafeUnref(fSoftwarePathRenderer);
fDrawState->unref();
+
+ --THREAD_INSTANCE_COUNT;
}
void GrContext::contextLost() {
}
GrContext::GrContext(GrGpu* gpu) {
+ ++THREAD_INSTANCE_COUNT;
+
fGpu = gpu;
fGpu->ref();
fGpu->setContext(this);