aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpuResource.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-14 06:47:39 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-14 06:47:39 -0800
commitac49acda520292b059bc37fd368dff912626c3d9 (patch)
tree64b8e7e0e2471aac0c27f0eb947c4a4f9dc0a4b3 /src/gpu/GrGpuResource.cpp
parent407aa584d183c1bf314f5defd1cf0202e8a96c89 (diff)
Revert of Replace GrResourceCache with GrResourceCache2. (patchset #7 id:120001 of https://codereview.chromium.org/716143004/)
Reason for revert: broken again Original issue's description: > Replace GrResourceCache with GrResourceCache2. > > BUG=skia:2889 > > Committed: https://skia.googlesource.com/skia/+/66a450f21a3da174b7eed89a1d5fc8591e8b6ee6 > > Committed: https://skia.googlesource.com/skia/+/407aa584d183c1bf314f5defd1cf0202e8a96c89 TBR=robertphillips@google.com NOTREECHECKS=true NOTRY=true BUG=skia:2889 Review URL: https://codereview.chromium.org/726913002
Diffstat (limited to 'src/gpu/GrGpuResource.cpp')
-rw-r--r--src/gpu/GrGpuResource.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index be8ea0daf0..f6f7282700 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -18,8 +18,16 @@ 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())
@@ -32,7 +40,7 @@ GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
}
void GrGpuResource::registerWithCache() {
- get_resource_cache2(fGpu)->resourceAccess().insertResource(this);
+ get_resource_cache2(fGpu)->insertResource(this);
}
GrGpuResource::~GrGpuResource() {
@@ -43,18 +51,16 @@ GrGpuResource::~GrGpuResource() {
void GrGpuResource::release() {
if (fGpu) {
this->onRelease();
- get_resource_cache2(fGpu)->resourceAccess().removeResource(this);
+ get_resource_cache2(fGpu)->removeResource(this);
fGpu = NULL;
- fGpuMemorySize = 0;
}
}
void GrGpuResource::abandon() {
if (fGpu) {
this->onAbandon();
- get_resource_cache2(fGpu)->resourceAccess().removeResource(this);
+ get_resource_cache2(fGpu)->removeResource(this);
fGpu = NULL;
- fGpuMemorySize = 0;
}
}
@@ -74,17 +80,6 @@ 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());
@@ -97,7 +92,7 @@ bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) {
fContentKey = contentKey;
fContentKeySet = true;
- if (!get_resource_cache2(fGpu)->resourceAccess().didSetContentKey(this)) {
+ if (!get_resource_cache2(fGpu)->didSetContentKey(this)) {
fContentKeySet = false;
return false;
}
@@ -105,8 +100,8 @@ bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) {
}
void GrGpuResource::notifyIsPurgable() const {
- if (!this->wasDestroyed()) {
- get_resource_cache2(fGpu)->resourceAccess().notifyPurgable(this);
+ if (fCacheEntry && !this->wasDestroyed()) {
+ get_resource_cache(fGpu)->notifyPurgable(this);
}
}