aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpuResource.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-17 09:33:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-17 09:33:27 -0800
commit84c8e62fad59f0e19b40ac718467f5b7884b431d (patch)
treed1957e4aecfe83bd76b181f316ce3bda25604879 /src/gpu/GrGpuResource.cpp
parentbd27e514e29a38d369358d829560ffe3a58efd73 (diff)
Allow GPU resources to not be counted against the cache budget.
Diffstat (limited to 'src/gpu/GrGpuResource.cpp')
-rw-r--r--src/gpu/GrGpuResource.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index ea3756b8dd..8dbbd83ef5 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);
+ }
+}