Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: src/gpu/GrResourceCache.h

Issue 932863004: Use an array of nonpurgeable resources in GrResourceCache (Closed) Base URL: https://skia.googlesource.com/skia.git@queue
Patch Set: skdebugf- Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrGpuResource.h ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache.h
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index b5984f2344ca9a00532719d3cf9cd0e521bda4d8..0f19b98ece9261e2e0166053cd501c26fd70df0b 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,12 @@ private:
void internalPurgeAsNeeded();
void processInvalidContentKeys(const SkTArray<GrContentKeyInvalidatedMessage>&);
+ void addToNonpurgeableArray(GrGpuResource*);
+ void removeFromNonpurgeableArray(GrGpuResource*);
+ 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 +220,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,15 +230,14 @@ private:
typedef SkMessageBus<GrContentKeyInvalidatedMessage>::Inbox InvalidContentKeyInbox;
typedef SkTDPQueue<GrGpuResource*, CompareTimestamp, AccessResourceIndex> PurgeableQueue;
+ typedef SkTDArray<GrGpuResource*> ResourceArray;
// Whenever a resource is added to the cache or the result of a cache lookup, fTimestamp is
// assigned as the resource's timestamp and then incremented. fPurgeableQueue orders the
// purgeable resources by this value, and thus is used to purge resources in LRU order.
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;
@@ -254,7 +256,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
« no previous file with comments | « include/gpu/GrGpuResource.h ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698