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