Index: src/gpu/GrGpuObject.cpp |
diff --git a/src/gpu/GrGpuObject.cpp b/src/gpu/GrGpuObject.cpp |
index fff2a2fd8f2c94a898b1d76f7ca52b48ae7dc87e..4a72a50c499689b8ae48f871e58afb68161a45fd 100644 |
--- a/src/gpu/GrGpuObject.cpp |
+++ b/src/gpu/GrGpuObject.cpp |
@@ -10,7 +10,10 @@ |
#include "GrGpuObject.h" |
#include "GrGpu.h" |
-GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) { |
+GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) |
+ : fRefCnt(1) |
+ , fCacheEntry(NULL) |
+ , fUniqueID(CreateUniqueID()) { |
fGpu = gpu; |
if (isWrapped) { |
fFlags = kWrapped_FlagBit; |
@@ -21,6 +24,7 @@ GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) { |
} |
GrGpuObject::~GrGpuObject() { |
+ SkASSERT(0 == fRefCnt); |
// subclass should have released this. |
SkASSERT(this->wasDestroyed()); |
} |
@@ -56,3 +60,12 @@ GrContext* GrGpuObject::getContext() { |
return NULL; |
} |
} |
+ |
+uint32_t GrGpuObject::CreateUniqueID() { |
+ static int32_t gUniqueID = SK_InvalidUniqueID; |
+ uint32_t id; |
+ do { |
+ id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
+ } while (id == SK_InvalidUniqueID); |
+ return id; |
+} |