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

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

Issue 452923002: Remove external SkImageFilter cache, and rename UniqueIDCache -> Cache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « include/core/SkDevice.h ('k') | include/gpu/SkGpuDevice.h » ('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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 }; 42 };
43 CropRect() {} 43 CropRect() {}
44 explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge) : fRect(rect), fFlags(flags) {} 44 explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge) : fRect(rect), fFlags(flags) {}
45 uint32_t flags() const { return fFlags; } 45 uint32_t flags() const { return fFlags; }
46 const SkRect& rect() const { return fRect; } 46 const SkRect& rect() const { return fRect; }
47 private: 47 private:
48 SkRect fRect; 48 SkRect fRect;
49 uint32_t fFlags; 49 uint32_t fFlags;
50 }; 50 };
51 51
52 class SK_API Cache : public SkRefCnt {
53 public:
54 // By default, we cache only image filters with 2 or more children.
55 // Values less than 2 mean always cache; values greater than 2 are not s upported.
56 static Cache* Create(int minChildren = 2);
57 virtual ~Cache() {}
58 virtual bool get(const SkImageFilter* key, SkBitmap* result, SkIPoint* o ffset) = 0;
59 virtual void set(const SkImageFilter* key,
60 const SkBitmap& result, const SkIPoint& offset) = 0;
61 virtual void remove(const SkImageFilter* key) = 0;
62 };
63
64 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap generation ID) to 52 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap generation ID) to
65 // (result, offset). 53 // (result, offset).
66 class UniqueIDCache : public SkRefCnt { 54 class Cache : public SkRefCnt {
67 public: 55 public:
68 struct Key; 56 struct Key;
69 virtual ~UniqueIDCache() {} 57 virtual ~Cache() {}
70 static UniqueIDCache* Create(size_t maxBytes); 58 static Cache* Create(size_t maxBytes);
71 static UniqueIDCache* Get(); 59 static Cache* Get();
72 virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) con st = 0; 60 virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) con st = 0;
73 virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0; 61 virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0;
74 }; 62 };
75 63
76 class Context { 64 class Context {
77 public: 65 public:
78 Context(const SkMatrix& ctm, const SkIRect& clipBounds, UniqueIDCache* c ache) : 66 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) :
79 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { 67 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) {
80 } 68 }
81 const SkMatrix& ctm() const { return fCTM; } 69 const SkMatrix& ctm() const { return fCTM; }
82 const SkIRect& clipBounds() const { return fClipBounds; } 70 const SkIRect& clipBounds() const { return fClipBounds; }
83 UniqueIDCache* cache() const { return fCache; } 71 Cache* cache() const { return fCache; }
84 private: 72 private:
85 SkMatrix fCTM; 73 SkMatrix fCTM;
86 SkIRect fClipBounds; 74 SkIRect fClipBounds;
87 UniqueIDCache* fCache; 75 Cache* fCache;
88 }; 76 };
89 77
90 class Proxy { 78 class Proxy {
91 public: 79 public:
92 virtual ~Proxy() {}; 80 virtual ~Proxy() {};
93 81
94 virtual SkBaseDevice* createDevice(int width, int height) = 0; 82 virtual SkBaseDevice* createDevice(int width, int height) = 0;
95 // returns true if the proxy can handle this filter natively 83 // returns true if the proxy can handle this filter natively
96 virtual bool canHandleImageFilter(const SkImageFilter*) = 0; 84 virtual bool canHandleImageFilter(const SkImageFilter*) = 0;
97 // returns true if the proxy handled the filter itself. if this returns 85 // returns true if the proxy handled the filter itself. if this returns
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 314
327 typedef SkFlattenable INHERITED; 315 typedef SkFlattenable INHERITED;
328 int fInputCount; 316 int fInputCount;
329 SkImageFilter** fInputs; 317 SkImageFilter** fInputs;
330 bool fUsesSrcInput; 318 bool fUsesSrcInput;
331 CropRect fCropRect; 319 CropRect fCropRect;
332 uint32_t fUniqueID; // Globally unique 320 uint32_t fUniqueID; // Globally unique
333 }; 321 };
334 322
335 #endif 323 #endif
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | include/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698