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; |
}; |