Index: src/gpu/GrResourceCache.h |
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h |
index 3e4ededc9e0c9eec5724f4c9d74bd1579ffed431..80380c9e684d63eeb691d43c6726fbade06cab93 100644 |
--- a/src/gpu/GrResourceCache.h |
+++ b/src/gpu/GrResourceCache.h |
@@ -10,11 +10,13 @@ |
#define GrResourceCache_DEFINED |
#include "GrGpuResource.h" |
+#include "GrGpuResourceCacheAccess.h" |
#include "GrGpuResourcePriv.h" |
#include "GrResourceKey.h" |
#include "SkMessageBus.h" |
#include "SkRefCnt.h" |
#include "SkTArray.h" |
+#include "SkTDPQueue.h" |
#include "SkTInternalLList.h" |
#include "SkTMultiMap.h" |
@@ -117,8 +119,7 @@ public: |
GrGpuResource* findAndRefContentResource(const GrContentKey& contentKey) { |
GrGpuResource* resource = fContentHash.find(contentKey); |
if (resource) { |
- resource->ref(); |
- this->makeResourceMRU(resource); |
+ this->refAndMakeResourceMRU(resource); |
} |
return resource; |
} |
@@ -138,7 +139,7 @@ public: |
if (invalidKeyMsgs.count()) { |
this->processInvalidContentKeys(invalidKeyMsgs); |
} |
- if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBytes)) { |
+ if (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBytes) { |
return; |
} |
this->internalPurgeAsNeeded(); |
@@ -179,7 +180,7 @@ private: |
void willRemoveScratchKey(const GrGpuResource*); |
void willRemoveContentKey(const GrGpuResource*); |
void didChangeBudgetStatus(GrGpuResource*); |
- void makeResourceMRU(GrGpuResource*); |
+ void refAndMakeResourceMRU(GrGpuResource*); |
/// @} |
void internalPurgeAsNeeded(); |
@@ -216,9 +217,23 @@ private: |
typedef SkTInternalLList<GrGpuResource> ResourceList; |
+ static bool CompareTimestamp(GrGpuResource* const& a, GrGpuResource* const& b) { |
+ return a->cacheAccess().timestamp() < b->cacheAccess().timestamp(); |
+ } |
+ |
+ static int* AccessResourceIndex(GrGpuResource* const& res) { |
+ return res->cacheAccess().accessCacheIndex(); |
+ } |
+ |
typedef SkMessageBus<GrContentKeyInvalidatedMessage>::Inbox InvalidContentKeyInbox; |
+ typedef SkTDPQueue<GrGpuResource*, CompareTimestamp, AccessResourceIndex> PurgeableQueue; |
robertphillips
2015/02/17 17:55:46
// This fTimestamp is the central source for monot
bsalomon
2015/02/17 19:18:43
Done.
|
+ uint32_t fTimestamp; |
+ PurgeableQueue fPurgeableQueue; |
+ |
+ // TODO: Replace this with an array of nonpurgeable resources |
ResourceList fResources; |
+ |
// This map holds all resources that can be used as scratch resources. |
ScratchMap fScratchMap; |
// This holds all resources that have content keys. |
@@ -243,15 +258,10 @@ private: |
int fBudgetedCount; |
size_t fBudgetedBytes; |
- // prevents recursive purging |
- bool fPurging; |
- bool fNewlyPurgeableResourceWhilePurging; |
- |
PFOverBudgetCB fOverBudgetCB; |
void* fOverBudgetData; |
InvalidContentKeyInbox fInvalidContentKeyInbox; |
- |
}; |
class GrResourceCache::ResourceAccess { |