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

Unified Diff: src/gpu/GrResourceCache.h

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: remove todo Created 6 years, 2 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 | « src/gpu/GrOptDrawState.cpp ('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 83337805a42f1c3a021f9ff61f4276b3cfe32316..f6d064af395be1f44691c4d326efc676ca70db88 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -6,11 +6,10 @@
* found in the LICENSE file.
*/
-
-
#ifndef GrResourceCache_DEFINED
#define GrResourceCache_DEFINED
+#include "GrDrawTargetCaps.h"
#include "GrResourceKey.h"
#include "SkTMultiMap.h"
#include "SkMessageBus.h"
@@ -88,7 +87,7 @@ private:
*/
class GrResourceCache {
public:
- GrResourceCache(int maxCount, size_t maxBytes);
+ GrResourceCache(const GrDrawTargetCaps*, int maxCount, size_t maxBytes);
~GrResourceCache();
/**
@@ -141,26 +140,16 @@ public:
*/
int getCachedResourceCount() const { return fEntryCount; }
- // For a found or added resource to be completely exclusive to the caller
- // both the kNoOtherOwners and kHide flags need to be specified
- enum OwnershipFlags {
- kNoOtherOwners_OwnershipFlag = 0x1, // found/added resource has no other owners
- kHide_OwnershipFlag = 0x2 // found/added resource is hidden from future 'find's
- };
-
/**
* Search for an entry with the same Key. If found, return it.
* If not found, return null.
- * If ownershipFlags includes kNoOtherOwners and a resource is returned
- * then that resource has no other refs to it.
- * If ownershipFlags includes kHide and a resource is returned then that
- * resource will not be returned from future 'find' calls until it is
- * 'freed' (and recycled) or makeNonExclusive is called.
- * For a resource to be completely exclusive to a caller both kNoOtherOwners
- * and kHide must be specified.
*/
- GrGpuResource* find(const GrResourceKey& key,
- uint32_t ownershipFlags = 0);
+ GrGpuResource* find(const GrResourceKey& key);
+
+ void makeResourceMRU(GrGpuResource*);
+
+ /** Called by GrGpuResources when they detects that they are newly purgable. */
+ void notifyPurgable(const GrGpuResource*);
/**
* Add the new resource to the cache (by creating a new cache entry based
@@ -168,14 +157,8 @@ public:
*
* Ownership of the resource is transferred to the resource cache,
* which will unref() it when it is purged or deleted.
- *
- * If ownershipFlags includes kHide, subsequent calls to 'find' will not
- * return 'resource' until it is 'freed' (and recycled) or makeNonExclusive
- * is called.
*/
- void addResource(const GrResourceKey& key,
- GrGpuResource* resource,
- uint32_t ownershipFlags = 0);
+ void addResource(const GrResourceKey& key, GrGpuResource* resource);
/**
* Determines if the cache contains an entry matching a key. If a matching
@@ -184,20 +167,6 @@ public:
bool hasKey(const GrResourceKey& key) const { return SkToBool(fCache.find(key)); }
/**
- * Hide 'entry' so that future searches will not find it. Such
- * hidden entries will not be purged. The entry still counts against
- * the cache's budget and should be made non-exclusive when exclusive access
- * is no longer needed.
- */
- void makeExclusive(GrResourceCacheEntry* entry);
-
- /**
- * Restore 'entry' so that it can be found by future searches. 'entry'
- * will also be purgeable (provided its lock count is now 0.)
- */
- void makeNonExclusive(GrResourceCacheEntry* entry);
-
- /**
* Notify the cache that the size of a resource has changed.
*/
void didIncreaseResourceSize(const GrResourceCacheEntry*, size_t amountInc);
@@ -237,59 +206,45 @@ public:
#endif
private:
- enum BudgetBehaviors {
- kAccountFor_BudgetBehavior,
- kIgnore_BudgetBehavior
- };
-
- void internalDetach(GrResourceCacheEntry*, BudgetBehaviors behavior = kAccountFor_BudgetBehavior);
- void attachToHead(GrResourceCacheEntry*, BudgetBehaviors behavior = kAccountFor_BudgetBehavior);
-
- void removeInvalidResource(GrResourceCacheEntry* entry);
+ void internalDetach(GrResourceCacheEntry*);
+ void attachToHead(GrResourceCacheEntry*);
+ void purgeInvalidated();
+ void internalPurge(int extraCount, size_t extraBytes);
+#ifdef SK_DEBUG
+ static size_t countBytes(const SkTInternalLList<GrResourceCacheEntry>& list);
+#endif
- SkTMultiMap<GrResourceCacheEntry, GrResourceKey> fCache;
+ typedef SkTMultiMap<GrResourceCacheEntry, GrResourceKey> CacheMap;
+ CacheMap fCache;
// We're an internal doubly linked list
typedef SkTInternalLList<GrResourceCacheEntry> EntryList;
- EntryList fList;
-
-#ifdef SK_DEBUG
- // These objects cannot be returned by a search
- EntryList fExclusiveList;
-#endif
+ EntryList fList;
// our budget, used in purgeAsNeeded()
- int fMaxCount;
- size_t fMaxBytes;
+ int fMaxCount;
+ size_t fMaxBytes;
// our current stats, related to our budget
#if GR_CACHE_STATS
- int fHighWaterEntryCount;
- size_t fHighWaterEntryBytes;
- int fHighWaterClientDetachedCount;
- size_t fHighWaterClientDetachedBytes;
+ int fHighWaterEntryCount;
+ size_t fHighWaterEntryBytes;
#endif
- int fEntryCount;
- size_t fEntryBytes;
- int fClientDetachedCount;
- size_t fClientDetachedBytes;
+ int fEntryCount;
+ size_t fEntryBytes;
// prevents recursive purging
- bool fPurging;
+ bool fPurging;
- PFOverbudgetCB fOverbudgetCB;
- void* fOverbudgetData;
+ PFOverbudgetCB fOverbudgetCB;
+ void* fOverbudgetData;
- void internalPurge(int extraCount, size_t extraBytes);
+ SkAutoTUnref<const GrDrawTargetCaps> fCaps;
// Listen for messages that a resource has been invalidated and purge cached junk proactively.
- SkMessageBus<GrResourceInvalidatedMessage>::Inbox fInvalidationInbox;
- void purgeInvalidated();
-
-#ifdef SK_DEBUG
- static size_t countBytes(const SkTInternalLList<GrResourceCacheEntry>& list);
-#endif
+ typedef SkMessageBus<GrResourceInvalidatedMessage>::Inbox Inbox;
+ Inbox fInvalidationInbox;
};
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698