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

Side by Side Diff: include/core/SkImageFilter.h

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkImageFilter_DEFINED 8 #ifndef SkImageFilter_DEFINED
9 #define SkImageFilter_DEFINED 9 #define SkImageFilter_DEFINED
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 }; 49 };
50 50
51 class Cache : public SkRefCnt { 51 class Cache : public SkRefCnt {
52 public: 52 public:
53 // By default, we cache only image filters with 2 or more children. 53 // By default, we cache only image filters with 2 or more children.
54 static Cache* Create(int minChildren = 2); 54 static Cache* Create(int minChildren = 2);
55 virtual ~Cache() {} 55 virtual ~Cache() {}
56 virtual bool get(const SkImageFilter* key, SkBitmap* result, SkIPoint* o ffset) = 0; 56 virtual bool get(const SkImageFilter* key, SkBitmap* result, SkIPoint* o ffset) = 0;
57 virtual void set(const SkImageFilter* key, 57 virtual void set(const SkImageFilter* key,
58 const SkBitmap& result, const SkIPoint& offset) = 0; 58 const SkBitmap& result, const SkIPoint& offset) = 0;
59 virtual void remove(const SkImageFilter* key) = 0;
59 }; 60 };
60 61
61 class Context { 62 class Context {
62 public: 63 public:
63 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) : 64 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) :
64 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { 65 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) {
65 } 66 }
66 const SkMatrix& ctm() const { return fCTM; } 67 const SkMatrix& ctm() const { return fCTM; }
67 const SkIRect& clipBounds() const { return fClipBounds; } 68 const SkIRect& clipBounds() const { return fClipBounds; }
68 Cache* cache() const { return fCache; } 69 Cache* cache() const { return fCache; }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 static void WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result); 177 static void WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result);
177 178
178 /** 179 /**
179 * Recursively evaluate this filter on the GPU. If the filter has no GPU 180 * Recursively evaluate this filter on the GPU. If the filter has no GPU
180 * implementation, it will be processed in software and uploaded to the GPU. 181 * implementation, it will be processed in software and uploaded to the GPU.
181 */ 182 */
182 bool getInputResultGPU(SkImageFilter::Proxy* proxy, const SkBitmap& src, con st Context&, 183 bool getInputResultGPU(SkImageFilter::Proxy* proxy, const SkBitmap& src, con st Context&,
183 SkBitmap* result, SkIPoint* offset) const; 184 SkBitmap* result, SkIPoint* offset) const;
184 #endif 185 #endif
185 186
187 /**
188 * Set an external cache to be used for all image filter processing. This
189 * will replace the default intra-frame cache.
190 */
191 static void SetExternalCache(Cache* cache);
192
193 /**
194 * Returns the currently-set external cache, or NULL if none is set.
195 */
196 static Cache* GetExternalCache();
197
186 SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter) 198 SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter)
187 199
188 protected: 200 protected:
189 SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRe ct = NULL); 201 SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRe ct = NULL);
190 202
191 // Convenience constructor for 1-input filters. 203 // Convenience constructor for 1-input filters.
192 explicit SkImageFilter(SkImageFilter* input, const CropRect* cropRect = NULL ); 204 explicit SkImageFilter(SkImageFilter* input, const CropRect* cropRect = NULL );
193 205
194 // Convenience constructor for 2-input filters. 206 // Convenience constructor for 2-input filters.
195 SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect* cropRect = NULL); 207 SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect* cropRect = NULL);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 * in the texture. "matrix" is a transformation to apply to filter 279 * in the texture. "matrix" is a transformation to apply to filter
268 * parameters before they are used in the effect. Note that this function 280 * parameters before they are used in the effect. Note that this function
269 * will be called with (NULL, NULL, SkMatrix::I()) to query for support, 281 * will be called with (NULL, NULL, SkMatrix::I()) to query for support,
270 * so returning "true" indicates support for all possible matrices. 282 * so returning "true" indicates support for all possible matrices.
271 */ 283 */
272 virtual bool asNewEffect(GrEffectRef** effect, 284 virtual bool asNewEffect(GrEffectRef** effect,
273 GrTexture*, 285 GrTexture*,
274 const SkMatrix& matrix, 286 const SkMatrix& matrix,
275 const SkIRect& bounds) const; 287 const SkIRect& bounds) const;
276 288
277
278 private: 289 private:
279 typedef SkFlattenable INHERITED; 290 typedef SkFlattenable INHERITED;
280 int fInputCount; 291 int fInputCount;
281 SkImageFilter** fInputs; 292 SkImageFilter** fInputs;
282 CropRect fCropRect; 293 CropRect fCropRect;
283 }; 294 };
284 295
285 #endif 296 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698