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

Unified Diff: src/image/SkImage_Base.h

Issue 1352883004: Purge cached resources on SkImage destruction. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 3 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/image/SkImage.cpp ('k') | src/image/SkImage_Generator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Base.h
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 737b30d1db6e3736dcede3736d2bb23bc0bf09d0..d0cb8d58409375a571af662d399c83875d7a6b08 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -8,6 +8,7 @@
#ifndef SkImage_Base_DEFINED
#define SkImage_Base_DEFINED
+#include "SkAtomics.h"
#include "SkImage.h"
#include "SkSurface.h"
@@ -17,16 +18,10 @@ enum {
kNeedNewImageUniqueID = 0
};
-static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) {
- return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry);
-}
-
class SkImage_Base : public SkImage {
public:
- SkImage_Base(int width, int height, uint32_t uniqueID, const SkSurfaceProps* props)
- : INHERITED(width, height, uniqueID)
- , fProps(copy_or_safe_defaults(props))
- {}
+ SkImage_Base(int width, int height, uint32_t uniqueID, const SkSurfaceProps* props);
+ virtual ~SkImage_Base();
/**
* If the props weren't know at constructor time, call this but only before the image is
@@ -74,9 +69,18 @@ public:
virtual bool onIsLazyGenerated() const { return false; }
+ // Call when this image is part of the key to a resourcecache entry. This allows the cache
+ // to know automatically those entries can be purged when this SkImage deleted.
+ void notifyAddedToCache() const {
+ fAddedToCache.store(true);
+ }
+
private:
const SkSurfaceProps fProps;
+ // Set true by caches when they cache content that's derived from the current pixels.
+ mutable SkAtomic<bool> fAddedToCache;
+
typedef SkImage INHERITED;
};
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Generator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698