Index: src/gpu/GrGpuResource.cpp |
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp |
index f6f7282700a3d7e231ceab522d4e11933f595723..be8ea0daf07f744a921b06a2b3684be1b3c9066e 100644 |
--- a/src/gpu/GrGpuResource.cpp |
+++ b/src/gpu/GrGpuResource.cpp |
@@ -18,16 +18,8 @@ static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) { |
return gpu->getContext()->getResourceCache2(); |
} |
-static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { |
- SkASSERT(gpu); |
- SkASSERT(gpu->getContext()); |
- SkASSERT(gpu->getContext()->getResourceCache()); |
- return gpu->getContext()->getResourceCache(); |
-} |
- |
GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped) |
: fGpu(gpu) |
- , fCacheEntry(NULL) |
, fGpuMemorySize(kInvalidGpuMemorySize) |
, fUniqueID(CreateUniqueID()) |
, fScratchKey(GrResourceKey::NullScratchKey()) |
@@ -40,7 +32,7 @@ GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped) |
} |
void GrGpuResource::registerWithCache() { |
- get_resource_cache2(fGpu)->insertResource(this); |
+ get_resource_cache2(fGpu)->resourceAccess().insertResource(this); |
} |
GrGpuResource::~GrGpuResource() { |
@@ -51,16 +43,18 @@ GrGpuResource::~GrGpuResource() { |
void GrGpuResource::release() { |
if (fGpu) { |
this->onRelease(); |
- get_resource_cache2(fGpu)->removeResource(this); |
+ get_resource_cache2(fGpu)->resourceAccess().removeResource(this); |
fGpu = NULL; |
+ fGpuMemorySize = 0; |
} |
} |
void GrGpuResource::abandon() { |
if (fGpu) { |
this->onAbandon(); |
- get_resource_cache2(fGpu)->removeResource(this); |
+ get_resource_cache2(fGpu)->resourceAccess().removeResource(this); |
fGpu = NULL; |
+ fGpuMemorySize = 0; |
} |
} |
@@ -80,6 +74,17 @@ GrContext* GrGpuResource::getContext() { |
} |
} |
+void GrGpuResource::didChangeGpuMemorySize() const { |
+ if (this->wasDestroyed()) { |
+ return; |
+ } |
+ |
+ size_t oldSize = fGpuMemorySize; |
+ SkASSERT(kInvalidGpuMemorySize != oldSize); |
+ fGpuMemorySize = kInvalidGpuMemorySize; |
+ get_resource_cache2(fGpu)->resourceAccess().didChangeGpuMemorySize(this, oldSize); |
+} |
+ |
bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) { |
// Currently this can only be called once and can't be called when the resource is scratch. |
SkASSERT(!contentKey.isScratch()); |
@@ -92,7 +97,7 @@ bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) { |
fContentKey = contentKey; |
fContentKeySet = true; |
- if (!get_resource_cache2(fGpu)->didSetContentKey(this)) { |
+ if (!get_resource_cache2(fGpu)->resourceAccess().didSetContentKey(this)) { |
fContentKeySet = false; |
return false; |
} |
@@ -100,8 +105,8 @@ bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) { |
} |
void GrGpuResource::notifyIsPurgable() const { |
- if (fCacheEntry && !this->wasDestroyed()) { |
- get_resource_cache(fGpu)->notifyPurgable(this); |
+ if (!this->wasDestroyed()) { |
+ get_resource_cache2(fGpu)->resourceAccess().notifyPurgable(this); |
} |
} |