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/GrGpuResource.cpp

Issue 721353002: Allow GPU resources to not be counted against the cache budget. (Closed) Base URL: https://skia.googlesource.com/skia.git@wrap
Patch Set: fix constructor order 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 ea3756b8dd07733fe5e711331d853fb5cecf28b6..8dbbd83ef58ad5a561d74bf0b52594262b0f5464 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -19,15 +19,15 @@ static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) {
}
GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
- : fGpu(gpu)
+ : fScratchKey(GrResourceKey::NullScratchKey())
+ , fGpu(gpu)
, fGpuMemorySize(kInvalidGpuMemorySize)
- , fUniqueID(CreateUniqueID())
- , fScratchKey(GrResourceKey::NullScratchKey())
- , fContentKeySet(false) {
+ , fUniqueID(CreateUniqueID()) {
if (isWrapped) {
- fFlags = kWrapped_FlagBit;
+ fFlags = kWrapped_Flag;
} else {
- fFlags = 0;
+ // By default all non-wrapped resources are budgeted.
+ fFlags = kBudgeted_Flag;
}
}
@@ -92,16 +92,16 @@ bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) {
if (this->isWrapped()) {
return false;
}
-
- if (fContentKeySet || this->wasDestroyed()) {
+
+ if ((fFlags & kContentKeySet_Flag) || this->wasDestroyed()) {
return false;
}
fContentKey = contentKey;
- fContentKeySet = true;
+ fFlags |= kContentKeySet_Flag;
if (!get_resource_cache2(fGpu)->resourceAccess().didSetContentKey(this)) {
- fContentKeySet = false;
+ fFlags &= ~kContentKeySet_Flag;
return false;
}
return true;
@@ -136,3 +136,21 @@ uint32_t GrGpuResource::CreateUniqueID() {
} while (id == SK_InvalidUniqueID);
return id;
}
+
+void GrGpuResource::setBudgeted(bool countsAgainstBudget) {
+ // Wrapped resources never count against the budget, nothing to do. No point in changing the
+ // budgeting of destroyed resources.
+ if (this->isWrapped() || this->wasDestroyed()) {
+ return;
+ }
+
+ uint32_t oldFlags = fFlags;
+ if (countsAgainstBudget) {
+ fFlags |= kBudgeted_Flag;
+ } else {
+ fFlags &= ~kBudgeted_Flag;
+ }
+ if (fFlags != oldFlags) {
+ get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(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