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

Unified Diff: src/gpu/GrGpuResource.cpp

Issue 716143004: Replace GrResourceCache with GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix asserts Created 6 years, 1 month 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/GrContext.cpp ('k') | src/gpu/GrGpuResourceCacheAccess.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrGpuResourceCacheAccess.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698