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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 SkRect fRect; | 48 SkRect fRect; |
49 uint32_t fFlags; | 49 uint32_t fFlags; |
50 }; | 50 }; |
51 | 51 |
52 class Proxy { | 52 class Proxy { |
53 public: | 53 public: |
54 virtual ~Proxy() {}; | 54 virtual ~Proxy() {}; |
55 | 55 |
56 virtual SkBaseDevice* createDevice(int width, int height) = 0; | 56 virtual SkBaseDevice* createDevice(int width, int height) = 0; |
57 // returns true if the proxy can handle this filter natively | 57 // returns true if the proxy can handle this filter natively |
58 virtual bool canHandleImageFilter(SkImageFilter*) = 0; | 58 virtual bool canHandleImageFilter(const SkImageFilter*) = 0; |
59 // returns true if the proxy handled the filter itself. if this returns | 59 // returns true if the proxy handled the filter itself. if this returns |
60 // false then the filter's code will be called. | 60 // false then the filter's code will be called. |
61 virtual bool filterImage(SkImageFilter*, const SkBitmap& src, | 61 virtual bool filterImage(const SkImageFilter*, const SkBitmap& src, |
62 const SkMatrix& ctm, | 62 const SkMatrix& ctm, |
63 SkBitmap* result, SkIPoint* offset) = 0; | 63 SkBitmap* result, SkIPoint* offset) = 0; |
64 }; | 64 }; |
65 | 65 |
66 /** | 66 /** |
67 * Request a new (result) image to be created from the src image. | 67 * Request a new (result) image to be created from the src image. |
68 * If the src has no pixels (isNull()) then the request just wants to | 68 * If the src has no pixels (isNull()) then the request just wants to |
69 * receive the config and width/height of the result. | 69 * receive the config and width/height of the result. |
70 * | 70 * |
71 * The matrix is the current matrix on the canvas. | 71 * The matrix is the current matrix on the canvas. |
72 * | 72 * |
73 * Offset is the amount to translate the resulting image relative to the | 73 * Offset is the amount to translate the resulting image relative to the |
74 * src when it is drawn. This is an out-param. | 74 * src when it is drawn. This is an out-param. |
75 * | 75 * |
76 * If the result image cannot be created, return false, in which case both | 76 * If the result image cannot be created, return false, in which case both |
77 * the result and offset parameters will be ignored by the caller. | 77 * the result and offset parameters will be ignored by the caller. |
78 */ | 78 */ |
79 bool filterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm, | 79 bool filterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm, |
80 SkBitmap* result, SkIPoint* offset); | 80 SkBitmap* result, SkIPoint* offset) const; |
81 | 81 |
82 /** | 82 /** |
83 * Given the src bounds of an image, this returns the bounds of the result | 83 * Given the src bounds of an image, this returns the bounds of the result |
84 * image after the filter has been applied. | 84 * image after the filter has been applied. |
85 */ | 85 */ |
86 bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) con
st; | 86 bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) con
st; |
87 | 87 |
88 /** | 88 /** |
89 * Returns true if the filter can be processed on the GPU. This is most | 89 * Returns true if the filter can be processed on the GPU. This is most |
90 * often used for multi-pass effects, where intermediate results must be | 90 * often used for multi-pass effects, where intermediate results must be |
91 * rendered to textures. For single-pass effects, use asNewEffect(). | 91 * rendered to textures. For single-pass effects, use asNewEffect(). |
92 * The default implementation returns asNewEffect(NULL, NULL, SkMatrix::I()
, | 92 * The default implementation returns asNewEffect(NULL, NULL, SkMatrix::I()
, |
93 * SkIRect()). | 93 * SkIRect()). |
94 */ | 94 */ |
95 virtual bool canFilterImageGPU() const; | 95 virtual bool canFilterImageGPU() const; |
96 | 96 |
97 /** | 97 /** |
98 * Process this image filter on the GPU. This is most often used for | 98 * Process this image filter on the GPU. This is most often used for |
99 * multi-pass effects, where intermediate results must be rendered to | 99 * multi-pass effects, where intermediate results must be rendered to |
100 * textures. For single-pass effects, use asNewEffect(). src is the | 100 * textures. For single-pass effects, use asNewEffect(). src is the |
101 * source image for processing, as a texture-backed bitmap. result is | 101 * source image for processing, as a texture-backed bitmap. result is |
102 * the destination bitmap, which should contain a texture-backed pixelref | 102 * the destination bitmap, which should contain a texture-backed pixelref |
103 * on success. offset is the amount to translate the resulting image | 103 * on success. offset is the amount to translate the resulting image |
104 * relative to the src when it is drawn. The default implementation does | 104 * relative to the src when it is drawn. The default implementation does |
105 * single-pass processing using asNewEffect(). | 105 * single-pass processing using asNewEffect(). |
106 */ | 106 */ |
107 virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const SkMatrix& ctm
, | 107 virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const SkMatrix& ctm
, |
108 SkBitmap* result, SkIPoint* offset); | 108 SkBitmap* result, SkIPoint* offset) const; |
109 | 109 |
110 /** | 110 /** |
111 * Returns whether this image filter is a color filter and puts the color f
ilter into the | 111 * Returns whether this image filter is a color filter and puts the color f
ilter into the |
112 * "filterPtr" parameter if it can. Does nothing otherwise. | 112 * "filterPtr" parameter if it can. Does nothing otherwise. |
113 * If this returns false, then the filterPtr is unchanged. | 113 * If this returns false, then the filterPtr is unchanged. |
114 * If this returns true, then if filterPtr is not null, it must be set to a
ref'd colorfitler | 114 * If this returns true, then if filterPtr is not null, it must be set to a
ref'd colorfitler |
115 * (i.e. it may not be set to NULL). | 115 * (i.e. it may not be set to NULL). |
116 */ | 116 */ |
117 virtual bool asColorFilter(SkColorFilter** filterPtr) const; | 117 virtual bool asColorFilter(SkColorFilter** filterPtr) const; |
118 | 118 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 * The matrix is the current matrix on the canvas. | 180 * The matrix is the current matrix on the canvas. |
181 * | 181 * |
182 * Offset is the amount to translate the resulting image relative to the | 182 * Offset is the amount to translate the resulting image relative to the |
183 * src when it is drawn. This is an out-param. | 183 * src when it is drawn. This is an out-param. |
184 * | 184 * |
185 * If the result image cannot be created, this should false, in which | 185 * If the result image cannot be created, this should false, in which |
186 * case both the result and offset parameters will be ignored by the | 186 * case both the result and offset parameters will be ignored by the |
187 * caller. | 187 * caller. |
188 */ | 188 */ |
189 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 189 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
190 SkBitmap* result, SkIPoint* offset); | 190 SkBitmap* result, SkIPoint* offset) const; |
191 // Given the bounds of the destination rect to be filled in device | 191 // Given the bounds of the destination rect to be filled in device |
192 // coordinates (first parameter), and the CTM, compute (conservatively) | 192 // coordinates (first parameter), and the CTM, compute (conservatively) |
193 // which rect of the source image would be required (third parameter). | 193 // which rect of the source image would be required (third parameter). |
194 // Used for clipping and temp-buffer allocations, so the result need not | 194 // Used for clipping and temp-buffer allocations, so the result need not |
195 // be exact, but should never be smaller than the real answer. The default | 195 // be exact, but should never be smaller than the real answer. The default |
196 // implementation recursively unions all input bounds, or returns false if | 196 // implementation recursively unions all input bounds, or returns false if |
197 // no inputs. | 197 // no inputs. |
198 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const
; | 198 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const
; |
199 | 199 |
200 // Applies "matrix" to the crop rect, and sets "rect" to the intersection of | 200 // Applies "matrix" to the crop rect, and sets "rect" to the intersection of |
(...skipping 22 matching lines...) Expand all Loading... |
223 const SkIRect& bounds) const; | 223 const SkIRect& bounds) const; |
224 | 224 |
225 private: | 225 private: |
226 typedef SkFlattenable INHERITED; | 226 typedef SkFlattenable INHERITED; |
227 int fInputCount; | 227 int fInputCount; |
228 SkImageFilter** fInputs; | 228 SkImageFilter** fInputs; |
229 CropRect fCropRect; | 229 CropRect fCropRect; |
230 }; | 230 }; |
231 | 231 |
232 #endif | 232 #endif |
OLD | NEW |