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

Unified Diff: src/gpu/GrLayerCache.h

Issue 408923002: Add auto purging for SkPicture-related Ganesh resources (esp. layers) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 6 years, 5 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/core/SkPicture.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerCache.h
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h
index 3d4c98a0d7034e84557a767c3e7b482c049fd4f0..0fdd6c97b60bea0e7c0f58f185488353a556ccfc 100644
--- a/src/gpu/GrLayerCache.h
+++ b/src/gpu/GrLayerCache.h
@@ -16,9 +16,15 @@
#include "GrRect.h"
#include "SkChecksum.h"
#include "SkTDynamicHash.h"
+#include "SkMessageBus.h"
class SkPicture;
+// The layer cache listens for these messages to purge picture-related resources.
+struct GrPictureDeletedMessage {
+ uint32_t pictureID;
+};
+
// GrPictureInfo stores the atlas plots used by a single picture. A single
// plot may be used to store layers from multiple pictures.
struct GrPictureInfo {
@@ -146,8 +152,11 @@ public:
// Inform the cache that layer's cached image is not currently required
void unlock(GrCachedLayer* layer);
- // Remove all the layers (and unlock any resources) associated with 'picture'
- void purge(const SkPicture* picture);
+ // Setup to be notified when 'picture' is deleted
+ void trackPicture(const SkPicture* picture);
+
+ // Cleanup after any SkPicture deletions
+ void processDeletedPictures();
SkDEBUGCODE(void validate() const;)
@@ -167,11 +176,18 @@ private:
SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key> fLayerHash;
+ SkMessageBus<GrPictureDeletedMessage>::Inbox fPictDeletionInbox;
+
+ SkAutoTUnref<SkPicture::DeletionListener> fDeletionListener;
+
void initAtlas();
GrCachedLayer* createLayer(const SkPicture* picture, int layerID);
+ // Remove all the layers (and unlock any resources) associated with 'pictureID'
+ void purge(uint32_t pictureID);
+
// for testing
- friend class GetNumLayers;
+ friend class TestingAccess;
int numLayers() const { return fLayerHash.count(); }
};
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698