Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: src/gpu/GrGpuObject.cpp

Issue 414013005: Merge GrGpuObject and GrCacheable. (Closed) Base URL: https://skia.googlesource.com/skia.git@uniqueid
Patch Set: Address comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698