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

Unified Diff: include/core/SkImageFilter.h

Issue 414483003: Implement a persistent uniqueID-based cache for SkImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix cross-process issue (revert those changes to HEAD^^) 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 | « include/core/SkDevice.h ('k') | include/core/SkPicture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageFilter.h
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index e7ba5e6ad92a881c8e043c58f5b41992a5d35d54..d2a4d3e3d93073a6c9ccc2b17c11d5f329576058 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -61,18 +61,30 @@ public:
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 {
+ public:
+ struct Key;
+ virtual ~UniqueIDCache() {}
+ static UniqueIDCache* Create(size_t maxBytes);
+ static UniqueIDCache* 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, Cache* cache) :
+ Context(const SkMatrix& ctm, const SkIRect& clipBounds, UniqueIDCache* cache) :
fCTM(ctm), fClipBounds(clipBounds), fCache(cache) {
}
const SkMatrix& ctm() const { return fCTM; }
const SkIRect& clipBounds() const { return fClipBounds; }
- Cache* cache() const { return fCache; }
+ UniqueIDCache* cache() const { return fCache; }
private:
SkMatrix fCTM;
SkIRect fClipBounds;
- Cache* fCache;
+ UniqueIDCache* fCache;
};
class Proxy {
@@ -210,6 +222,7 @@ protected:
CropRect cropRect() const { return fCropRect; }
int inputCount() const { return fInputs.count(); }
SkImageFilter** inputs() const { return fInputs.get(); }
+ uint32_t uniqueID() const { return fUniqueID; }
// If the caller wants a copy of the inputs, call this and it will transfer ownership
// of the unflattened input filters to the caller. This is just a short-cut for copying
@@ -221,6 +234,7 @@ protected:
CropRect fCropRect;
// most filters accept at most 2 input-filters
SkAutoSTArray<2, SkImageFilter*> fInputs;
+ uint32_t fUniqueID;
void allocInputs(int count);
};
@@ -308,10 +322,14 @@ protected:
const SkIRect& bounds) const;
private:
+ bool usesSrcInput() const { return fUsesSrcInput; }
+
typedef SkFlattenable INHERITED;
int fInputCount;
SkImageFilter** fInputs;
+ bool fUsesSrcInput;
CropRect fCropRect;
+ uint32_t fUniqueID; // Globally unique
};
#endif
« no previous file with comments | « include/core/SkDevice.h ('k') | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698