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

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: update 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
Index: src/gpu/GrGpuResource.cpp
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 1f1d313d6b0e68ab4224edd5efed2867acff0534..deac9cb81bb298993714f4fa5d7214228970825e 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -22,13 +22,14 @@ GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
: fGpu(gpu)
, fGpuMemorySize(kInvalidGpuMemorySize)
, fUniqueID(CreateUniqueID())
- , fScratchKey(GrResourceKey::NullScratchKey())
- , fContentKeySet(false) {
+ , fScratchKey(GrResourceKey::NullScratchKey()) {
egdaniel 2014/11/13 20:47:31 extra space
bsalomon 2014/11/13 20:53:33 Done.
if (isWrapped) {
- fFlags = kWrapped_FlagBit;
+ fFlags = kWrapped_Flag;
} else {
- fFlags = 0;
+ // By default all non-wrapped resources are budgeted.
+ fFlags = kBudgeted_Flag;
}
+
egdaniel 2014/11/13 20:47:32 Extra \n added
bsalomon 2014/11/13 20:53:34 Done.
}
void GrGpuResource::registerWithCache() {
@@ -95,15 +96,15 @@ bool GrGpuResource::setContentKey(const GrResourceKey& contentKey) {
return false;
}
- if (fContentKeySet) {
+ if (fFlags & kContentKeySet_Flag) {
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;
@@ -120,7 +121,7 @@ void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) {
SkASSERT(scratchKey.isScratch());
SkASSERT(!scratchKey.isNullScratch());
// Wrapped resources can never have a key.
- if (this->isWrapped()) {
+ if (this->cacheAccess().isWrapped()) {
bsalomon 2014/11/13 19:20:54 This is unnecessary. Will revert before submitting
return;
}
fScratchKey = scratchKey;
@@ -134,3 +135,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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698