Remove external SkImageFilter cache, and rename UniqueIDCache -> Cache.
There Can Only Be One.... Cache for SkImageFilter.
R=bsalomon@google.com
BUG=skia:
Author: senorblanco@chromium.org
Review URL: https://codereview.chromium.org/452923002
diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h
index 5dde9e0..f8ce93a 100644
--- a/include/core/SkBitmapDevice.h
+++ b/include/core/SkBitmapDevice.h
@@ -156,7 +156,7 @@
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE;
- virtual SkImageFilter::UniqueIDCache* getImageFilterCache() SK_OVERRIDE;
+ virtual SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE;
SkBitmap fBitmap;
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 3e5e42b..a5682c2 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -380,7 +380,7 @@
*/
virtual void flush() {}
- virtual SkImageFilter::UniqueIDCache* getImageFilterCache() { return NULL; }
+ virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; }
SkIPoint fOrigin;
SkMetaData* fMetaData;
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index d2a4d3e..d4930c4 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -49,42 +49,30 @@
uint32_t fFlags;
};
- class SK_API Cache : public SkRefCnt {
- public:
- // By default, we cache only image filters with 2 or more children.
- // Values less than 2 mean always cache; values greater than 2 are not supported.
- static Cache* Create(int minChildren = 2);
- virtual ~Cache() {}
- virtual bool get(const SkImageFilter* key, SkBitmap* result, SkIPoint* offset) = 0;
- virtual void set(const SkImageFilter* key,
- const SkBitmap& result, const SkIPoint& offset) = 0;
- virtual void remove(const SkImageFilter* key) = 0;
- };
-
// This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap generation ID) to
// (result, offset).
- class UniqueIDCache : public SkRefCnt {
+ class Cache : public SkRefCnt {
public:
struct Key;
- virtual ~UniqueIDCache() {}
- static UniqueIDCache* Create(size_t maxBytes);
- static UniqueIDCache* Get();
+ virtual ~Cache() {}
+ static Cache* Create(size_t maxBytes);
+ static Cache* Get();
virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) const = 0;
virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0;
};
class Context {
public:
- Context(const SkMatrix& ctm, const SkIRect& clipBounds, UniqueIDCache* cache) :
+ Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) :
fCTM(ctm), fClipBounds(clipBounds), fCache(cache) {
}
const SkMatrix& ctm() const { return fCTM; }
const SkIRect& clipBounds() const { return fClipBounds; }
- UniqueIDCache* cache() const { return fCache; }
+ Cache* cache() const { return fCache; }
private:
SkMatrix fCTM;
SkIRect fClipBounds;
- UniqueIDCache* fCache;
+ Cache* fCache;
};
class Proxy {