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

Unified Diff: src/gpu/GrResourceCache2.h

Issue 902873002: Reimplement gpu message bus for invalidated bitmap gen IDs (Closed) Base URL: https://skia.googlesource.com/skia.git@one_tex
Patch Set: fix speeling error 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 | « src/gpu/GrLayerCache.cpp ('k') | src/gpu/GrResourceCache2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache2.h
diff --git a/src/gpu/GrResourceCache2.h b/src/gpu/GrResourceCache2.h
index 4f21db979beadfa374ff9f4f7b850ced30de8c33..e844f11e6a17be6ccd99bd8db63919dd7e0c7908 100644
--- a/src/gpu/GrResourceCache2.h
+++ b/src/gpu/GrResourceCache2.h
@@ -12,7 +12,9 @@
#include "GrGpuResource.h"
#include "GrGpuResourceCacheAccess.h"
#include "GrResourceKey.h"
+#include "SkMessageBus.h"
#include "SkRefCnt.h"
+#include "SkTArray.h"
#include "SkTInternalLList.h"
#include "SkTMultiMap.h"
@@ -128,6 +130,20 @@ public:
return SkToBool(fContentHash.find(contentKey));
}
+ /** Purges resources to become under budget and processes resources with invalidated content
+ keys. */
+ void purgeAsNeeded() {
+ SkTArray<GrContentKeyInvalidatedMessage> invalidKeyMsgs;
+ fInvalidContentKeyInbox.poll(&invalidKeyMsgs);
+ if (invalidKeyMsgs.count()) {
+ this->processInvalidContentKeys(invalidKeyMsgs);
+ }
+ if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBytes)) {
+ return;
+ }
+ this->internalPurgeAsNeeded();
+ }
+
/** Purges all resources that don't have external owners. */
void purgeAllUnlocked();
@@ -161,18 +177,13 @@ private:
void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize);
bool didSetContentKey(GrGpuResource*);
void willRemoveScratchKey(const GrGpuResource*);
+ void willRemoveContentKey(const GrGpuResource*);
void didChangeBudgetStatus(GrGpuResource*);
void makeResourceMRU(GrGpuResource*);
/// @}
- void purgeAsNeeded() {
- if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBytes)) {
- return;
- }
- this->internalPurgeAsNeeded();
- }
-
void internalPurgeAsNeeded();
+ void processInvalidContentKeys(const SkTArray<GrContentKeyInvalidatedMessage>&);
#ifdef SK_DEBUG
bool isInCache(const GrGpuResource* r) const { return fResources.isInList(r); }
@@ -205,6 +216,8 @@ private:
typedef SkTInternalLList<GrGpuResource> ResourceList;
+ typedef SkMessageBus<GrContentKeyInvalidatedMessage>::Inbox InvalidContentKeyInbox;
+
ResourceList fResources;
// This map holds all resources that can be used as scratch resources.
ScratchMap fScratchMap;
@@ -237,6 +250,8 @@ private:
PFOverBudgetCB fOverBudgetCB;
void* fOverBudgetData;
+ InvalidContentKeyInbox fInvalidContentKeyInbox;
+
};
class GrResourceCache2::ResourceAccess {
@@ -278,7 +293,14 @@ private:
bool didSetContentKey(GrGpuResource* resource) { return fCache->didSetContentKey(resource); }
/**
- * Called by GrGpuResources when the remove their scratch key.
+ * Called by a GrGpuResource when it removes its content key.
+ */
+ void willRemoveContentKey(GrGpuResource* resource) {
+ return fCache->willRemoveContentKey(resource);
+ }
+
+ /**
+ * Called by a GrGpuResource when it removes its scratch key.
*/
void willRemoveScratchKey(const GrGpuResource* resource) {
fCache->willRemoveScratchKey(resource);
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | src/gpu/GrResourceCache2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698