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 13 matching lines...) Expand all Loading... |
24 * Base class for image filters. If one is installed in the paint, then | 24 * Base class for image filters. If one is installed in the paint, then |
25 * all drawing occurs as usual, but it is as if the drawing happened into an | 25 * all drawing occurs as usual, but it is as if the drawing happened into an |
26 * offscreen (before the xfermode is applied). This offscreen bitmap will | 26 * offscreen (before the xfermode is applied). This offscreen bitmap will |
27 * then be handed to the imagefilter, who in turn creates a new bitmap which | 27 * then be handed to the imagefilter, who in turn creates a new bitmap which |
28 * is what will finally be drawn to the device (using the original xfermode). | 28 * is what will finally be drawn to the device (using the original xfermode). |
29 */ | 29 */ |
30 class SK_API SkImageFilter : public SkFlattenable { | 30 class SK_API SkImageFilter : public SkFlattenable { |
31 public: | 31 public: |
32 SK_DECLARE_INST_COUNT(SkImageFilter) | 32 SK_DECLARE_INST_COUNT(SkImageFilter) |
33 | 33 |
34 #ifdef SK_CROP_RECT_IS_INT | |
35 typedef SkIRect CropRect; | |
36 #else | |
37 struct CropRect { | 34 struct CropRect { |
38 SkRect fRect; | 35 SkRect fRect; |
39 uint32_t fFlags; | 36 uint32_t fFlags; |
40 enum CropEdge { | 37 enum CropEdge { |
41 kHasLeft_CropEdge = 0x01, | 38 kHasLeft_CropEdge = 0x01, |
42 kHasTop_CropEdge = 0x02, | 39 kHasTop_CropEdge = 0x02, |
43 kHasRight_CropEdge = 0x04, | 40 kHasRight_CropEdge = 0x04, |
44 kHasBottom_CropEdge = 0x08, | 41 kHasBottom_CropEdge = 0x08, |
45 kHasAll_CropEdge = 0x0F, | 42 kHasAll_CropEdge = 0x0F, |
46 }; | 43 }; |
47 CropRect() {} | 44 CropRect() {} |
48 explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge)
: fRect(rect), fFlags(flags) {} | 45 explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge)
: fRect(rect), fFlags(flags) {} |
| 46 // Returns true if any of the crop edges have been set. |
49 bool isSet() const | 47 bool isSet() const |
50 { | 48 { |
51 return fFlags != 0x0; | 49 return fFlags != 0x0; |
52 } | 50 } |
53 }; | 51 }; |
54 #endif | |
55 | 52 |
56 class Proxy { | 53 class Proxy { |
57 public: | 54 public: |
58 virtual ~Proxy() {}; | 55 virtual ~Proxy() {}; |
59 | 56 |
60 virtual SkBaseDevice* createDevice(int width, int height) = 0; | 57 virtual SkBaseDevice* createDevice(int width, int height) = 0; |
61 // returns true if the proxy can handle this filter natively | 58 // returns true if the proxy can handle this filter natively |
62 virtual bool canHandleImageFilter(SkImageFilter*) = 0; | 59 virtual bool canHandleImageFilter(SkImageFilter*) = 0; |
63 // returns true if the proxy handled the filter itself. if this returns | 60 // returns true if the proxy handled the filter itself. if this returns |
64 // false then the filter's code will be called. | 61 // false then the filter's code will be called. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 150 |
154 /** | 151 /** |
155 * Returns the crop rectangle of this filter. This is set at construction | 152 * Returns the crop rectangle of this filter. This is set at construction |
156 * time, and determines which pixels from the input image will | 153 * time, and determines which pixels from the input image will |
157 * be processed. The size of this rectangle should be used as the size | 154 * be processed. The size of this rectangle should be used as the size |
158 * of the destination image. The origin of this rect should be used to | 155 * of the destination image. The origin of this rect should be used to |
159 * offset access to the input images, and should also be added to the | 156 * offset access to the input images, and should also be added to the |
160 * "offset" parameter in onFilterImage and filterImageGPU(). (The latter | 157 * "offset" parameter in onFilterImage and filterImageGPU(). (The latter |
161 * ensures that the resulting buffer is drawn in the correct location.) | 158 * ensures that the resulting buffer is drawn in the correct location.) |
162 */ | 159 */ |
163 #ifdef SK_CROP_RECT_IS_INT | |
164 bool cropRectIsSet() const { return !fCropRect.isLargest(); } | |
165 #else | |
166 bool cropRectIsSet() const { return fCropRect.isSet(); } | 160 bool cropRectIsSet() const { return fCropRect.isSet(); } |
167 #endif | |
168 | 161 |
169 protected: | 162 protected: |
170 SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRe
ct = NULL); | 163 SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRe
ct = NULL); |
171 | 164 |
172 // Convenience constructor for 1-input filters. | 165 // Convenience constructor for 1-input filters. |
173 explicit SkImageFilter(SkImageFilter* input, const CropRect* cropRect = NULL
); | 166 explicit SkImageFilter(SkImageFilter* input, const CropRect* cropRect = NULL
); |
174 | 167 |
175 // Convenience constructor for 2-input filters. | 168 // Convenience constructor for 2-input filters. |
176 SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect*
cropRect = NULL); | 169 SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect*
cropRect = NULL); |
177 | 170 |
(...skipping 15 matching lines...) Expand all Loading... |
193 bool applyCropRect(SkIRect* rect, const SkMatrix& matrix) const; | 186 bool applyCropRect(SkIRect* rect, const SkMatrix& matrix) const; |
194 | 187 |
195 private: | 188 private: |
196 typedef SkFlattenable INHERITED; | 189 typedef SkFlattenable INHERITED; |
197 int fInputCount; | 190 int fInputCount; |
198 SkImageFilter** fInputs; | 191 SkImageFilter** fInputs; |
199 CropRect fCropRect; | 192 CropRect fCropRect; |
200 }; | 193 }; |
201 | 194 |
202 #endif | 195 #endif |
OLD | NEW |