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

Unified Diff: src/core/SkImageFilter.cpp

Issue 225903010: Allow clients to specify an external SkImageFilter cache. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Move external to a global on SkImageFilter. Created 6 years, 8 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/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 8d0c22de285a51ac5de63483233507d8533725a1..05f559b02d251acb8ca80adcc5cc456b56cb9915 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -20,6 +20,8 @@
#include "SkGr.h"
#endif
+SkImageFilter::Cache* gExternalCache;
+
SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect)
: fInputCount(inputCount),
fInputs(new SkImageFilter*[inputCount]),
@@ -295,6 +297,14 @@ bool SkImageFilter::asColorFilter(SkColorFilter**) const {
return false;
}
+void SkImageFilter::SetExternalCache(Cache* cache) {
+ SkRefCnt_SafeAssign(gExternalCache, cache);
+}
+
+SkImageFilter::Cache* SkImageFilter::GetExternalCache() {
+ return gExternalCache;
+}
+
#if SK_SUPPORT_GPU
void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
@@ -363,6 +373,7 @@ public:
virtual ~CacheImpl();
bool get(const SkImageFilter* key, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
void set(const SkImageFilter* key, const SkBitmap& result, const SkIPoint& offset) SK_OVERRIDE;
+ void remove(const SkImageFilter* key) SK_OVERRIDE;
private:
typedef const SkImageFilter* Key;
struct Value {
@@ -392,6 +403,14 @@ bool CacheImpl::get(const SkImageFilter* key, SkBitmap* result, SkIPoint* offset
return false;
}
+void CacheImpl::remove(const SkImageFilter* key) {
+ Value* v = fData.find(key);
+ if (v) {
+ fData.remove(key);
+ delete v;
+ }
+}
+
void CacheImpl::set(const SkImageFilter* key, const SkBitmap& result, const SkIPoint& offset) {
if (key->getRefCnt() >= fMinChildren) {
fData.add(new Value(key, result, offset));
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698