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

Unified Diff: src/gpu/GrGpuResource.cpp

Issue 1862043002: Refactor to separate backend object lifecycle and GpuResource budget decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unrelated GrBuffer::onGpuMemorySize() lack of override keyword compile error Created 4 years, 8 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.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 53e568b2a494ef19a3d9cf7e47e47cf365513e16..ff858fe9d297375cd682ba0c352e2fffe06164cc 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -19,15 +19,26 @@ static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
return gpu->getContext()->getResourceCache();
}
-GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle)
+GrGpuResource::GrGpuResource(GrGpu* gpu)
: fGpu(gpu)
, fGpuMemorySize(kInvalidGpuMemorySize)
- , fLifeCycle(lifeCycle)
+ , fBudgeted(SkBudgeted::kNo)
+ , fRefsWrappedObjects(false)
, fUniqueID(CreateUniqueID()) {
SkDEBUGCODE(fCacheArrayIndex = -1);
}
-void GrGpuResource::registerWithCache() {
+void GrGpuResource::registerWithCache(SkBudgeted budgeted) {
+ SkASSERT(fBudgeted == SkBudgeted::kNo);
+ fBudgeted = budgeted;
+ this->computeScratchKey(&fScratchKey);
+ get_resource_cache(fGpu)->resourceAccess().insertResource(this);
+}
+
+void GrGpuResource::registerWithCacheWrapped() {
+ SkASSERT(fBudgeted == SkBudgeted::kNo);
+ // Currently resources referencing wrapped objects are not budgeted.
+ fRefsWrappedObjects = true;
get_resource_cache(fGpu)->resourceAccess().insertResource(this);
}
@@ -164,16 +175,6 @@ bool GrGpuResource::notifyRefCountIsZero() const {
return false;
}
-void GrGpuResource::setScratchKey(const GrScratchKey& scratchKey) {
- SkASSERT(!fScratchKey.isValid());
- SkASSERT(scratchKey.isValid());
- // Wrapped resources can never have a scratch key.
- if (this->resourcePriv().isExternal()) {
- return;
- }
- fScratchKey = scratchKey;
-}
-
void GrGpuResource::removeScratchKey() {
if (!this->wasDestroyed() && fScratchKey.isValid()) {
get_resource_cache(fGpu)->resourceAccess().willRemoveScratchKey(this);
@@ -182,16 +183,18 @@ void GrGpuResource::removeScratchKey() {
}
void GrGpuResource::makeBudgeted() {
- if (!this->wasDestroyed() && GrGpuResource::kUncached_LifeCycle == fLifeCycle) {
- fLifeCycle = kCached_LifeCycle;
+ if (!this->wasDestroyed() && SkBudgeted::kNo == fBudgeted) {
+ // Currently resources referencing wrapped objects are not budgeted.
+ SkASSERT(!fRefsWrappedObjects);
+ fBudgeted = SkBudgeted::kYes;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}
}
void GrGpuResource::makeUnbudgeted() {
- if (!this->wasDestroyed() && GrGpuResource::kCached_LifeCycle == fLifeCycle &&
+ if (!this->wasDestroyed() && SkBudgeted::kYes == fBudgeted &&
!fUniqueKey.isValid()) {
- fLifeCycle = kUncached_LifeCycle;
+ fBudgeted = SkBudgeted::kNo;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}
}
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrGpuResourceCacheAccess.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698