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); |
+ } |
+} |