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

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: Move MessageBus Inbox from GrContext to GrLayerCache 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
Index: src/gpu/GrLayerCache.h
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h
index 3d4c98a0d7034e84557a767c3e7b482c049fd4f0..cc790689b03a5fcb48e4de5116e072c302e3c97d 100644
--- a/src/gpu/GrLayerCache.h
+++ b/src/gpu/GrLayerCache.h
@@ -15,10 +15,24 @@
#include "GrPictureUtils.h"
#include "GrRect.h"
#include "SkChecksum.h"
+#include "SkGpuDevice.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;
+};
+
+class GrPictureDeletionListener : public SkPicture::DeletionListener {
+ virtual void onDeletion(uint32_t pictureID) SK_OVERRIDE{
+ const GrPictureDeletedMessage message = { pictureID };
+ SkMessageBus<GrPictureDeletedMessage>::Post(message);
+ }
+};
+
// 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 +160,8 @@ 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);
+ // Cleanup after any SkPicture deletions
+ void processDeletedPictures();
SkDEBUGCODE(void validate() const;)
@@ -167,11 +181,16 @@ private:
SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key> fLayerHash;
+ SkMessageBus<GrPictureDeletedMessage>::Inbox fPictDeletionInbox;
+
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(); }
};
« include/core/SkPicture.h ('K') | « src/core/SkPicture.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698