| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |