Chromium Code Reviews| Index: src/gpu/GrResourceCache.h |
| diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h |
| index 80380c9e684d63eeb691d43c6726fbade06cab93..38f8c239e135f4776dcdec2ea77d00117cc5faa2 100644 |
| --- a/src/gpu/GrResourceCache.h |
| +++ b/src/gpu/GrResourceCache.h |
| @@ -55,7 +55,9 @@ public: |
| /** |
| * Returns the number of resources. |
| */ |
| - int getResourceCount() const { return fCount; } |
| + int getResourceCount() const { |
| + return fPurgeableQueue.count() + fNonpurgeableResources.count(); |
| + } |
| /** |
| * Returns the number of resources that count against the budget. |
| @@ -185,9 +187,13 @@ private: |
| void internalPurgeAsNeeded(); |
| void processInvalidContentKeys(const SkTArray<GrContentKeyInvalidatedMessage>&); |
| + void addToNonpurgeableArray(GrGpuResource*); |
| + void removeFromNonpurgeableArray(GrGpuResource*); |
|
robertphillips
2015/02/17 18:32:23
<= for underBudget ?
bsalomon
2015/02/17 19:32:51
I made it < since this is used to check if there i
|
| + bool underBudget() const { return fBudgetedBytes < fMaxBytes && fBudgetedCount < fMaxCount; } |
| + bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCount > fMaxCount; } |
| #ifdef SK_DEBUG |
| - bool isInCache(const GrGpuResource* r) const { return fResources.isInList(r); } |
| + bool isInCache(const GrGpuResource* r) const; |
| void validate() const; |
| #else |
| void validate() const {} |
| @@ -215,8 +221,6 @@ private: |
| }; |
| typedef SkTDynamicHash<GrGpuResource, GrContentKey, ContentHashTraits> ContentHash; |
| - typedef SkTInternalLList<GrGpuResource> ResourceList; |
| - |
| static bool CompareTimestamp(GrGpuResource* const& a, GrGpuResource* const& b) { |
| return a->cacheAccess().timestamp() < b->cacheAccess().timestamp(); |
| } |
| @@ -227,12 +231,11 @@ private: |
| typedef SkMessageBus<GrContentKeyInvalidatedMessage>::Inbox InvalidContentKeyInbox; |
| typedef SkTDPQueue<GrGpuResource*, CompareTimestamp, AccessResourceIndex> PurgeableQueue; |
| + typedef SkTDArray<GrGpuResource*> ResourceArray; |
| uint32_t fTimestamp; |
| PurgeableQueue fPurgeableQueue; |
| - |
| - // TODO: Replace this with an array of nonpurgeable resources |
| - ResourceList fResources; |
| + ResourceArray fNonpurgeableResources; |
| // This map holds all resources that can be used as scratch resources. |
| ScratchMap fScratchMap; |
| @@ -251,7 +254,7 @@ private: |
| #endif |
| // our current stats for all resources |
| - int fCount; |
| + SkDEBUGCODE(int fCount;) |
| size_t fBytes; |
| // our current stats for resources that count against the budget |