OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkColorFilter_DEFINED | 8 #ifndef SkColorFilter_DEFINED |
9 #define SkColorFilter_DEFINED | 9 #define SkColorFilter_DEFINED |
10 | 10 |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 #include "SkXfermode.h" | 14 #include "SkXfermode.h" |
15 | 15 |
16 class GrContext; | 16 class GrContext; |
17 class GrFragmentProcessor; | 17 class GrFragmentProcessor; |
18 class SkBitmap; | 18 class SkBitmap; |
| 19 class SkRasterPipeline; |
19 | 20 |
20 /** | 21 /** |
21 * ColorFilters are optional objects in the drawing pipeline. When present in | 22 * ColorFilters are optional objects in the drawing pipeline. When present in |
22 * a paint, they are called with the "src" colors, and return new colors, which | 23 * a paint, they are called with the "src" colors, and return new colors, which |
23 * are then passed onto the next stage (either ImageFilter or Xfermode). | 24 * are then passed onto the next stage (either ImageFilter or Xfermode). |
24 * | 25 * |
25 * All subclasses are required to be reentrant-safe : it must be legal to share | 26 * All subclasses are required to be reentrant-safe : it must be legal to share |
26 * the same instance between several threads. | 27 * the same instance between several threads. |
27 */ | 28 */ |
28 class SK_API SkColorFilter : public SkFlattenable { | 29 class SK_API SkColorFilter : public SkFlattenable { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 The implementation writes out its filtered version into result[]. | 64 The implementation writes out its filtered version into result[]. |
64 Note: shader and result may be the same buffer. | 65 Note: shader and result may be the same buffer. |
65 @param src array of colors, possibly generated by a shader | 66 @param src array of colors, possibly generated by a shader |
66 @param count the number of entries in the src[] and result[] arrays | 67 @param count the number of entries in the src[] and result[] arrays |
67 @param result written by the filter | 68 @param result written by the filter |
68 */ | 69 */ |
69 virtual void filterSpan(const SkPMColor src[], int count, SkPMColor result[]
) const = 0; | 70 virtual void filterSpan(const SkPMColor src[], int count, SkPMColor result[]
) const = 0; |
70 | 71 |
71 virtual void filterSpan4f(const SkPM4f src[], int count, SkPM4f result[]) co
nst; | 72 virtual void filterSpan4f(const SkPM4f src[], int count, SkPM4f result[]) co
nst; |
72 | 73 |
| 74 bool appendStages(SkRasterPipeline*) const; |
| 75 |
73 enum Flags { | 76 enum Flags { |
74 /** If set the filter methods will not change the alpha channel of the c
olors. | 77 /** If set the filter methods will not change the alpha channel of the c
olors. |
75 */ | 78 */ |
76 kAlphaUnchanged_Flag = 1 << 0, | 79 kAlphaUnchanged_Flag = 1 << 0, |
77 }; | 80 }; |
78 | 81 |
79 /** Returns the flags for this filter. Override in subclasses to return cust
om flags. | 82 /** Returns the flags for this filter. Override in subclasses to return cust
om flags. |
80 */ | 83 */ |
81 virtual uint32_t getFlags() const { return 0; } | 84 virtual uint32_t getFlags() const { return 0; } |
82 | 85 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 164 } |
162 | 165 |
163 SK_TO_STRING_PUREVIRT() | 166 SK_TO_STRING_PUREVIRT() |
164 | 167 |
165 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 168 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
166 SK_DEFINE_FLATTENABLE_TYPE(SkColorFilter) | 169 SK_DEFINE_FLATTENABLE_TYPE(SkColorFilter) |
167 | 170 |
168 protected: | 171 protected: |
169 SkColorFilter() {} | 172 SkColorFilter() {} |
170 | 173 |
| 174 virtual bool onAppendStages(SkRasterPipeline*) const; |
| 175 |
171 private: | 176 private: |
172 /* | 177 /* |
173 * Returns 1 if this is a single filter (not a composition of other filters
), otherwise it | 178 * Returns 1 if this is a single filter (not a composition of other filters
), otherwise it |
174 * reutrns the number of leaf-node filters in a composition. This should be
the same value | 179 * reutrns the number of leaf-node filters in a composition. This should be
the same value |
175 * as the number of GrFragmentProcessors returned by asFragmentProcessors's
array parameter. | 180 * as the number of GrFragmentProcessors returned by asFragmentProcessors's
array parameter. |
176 * | 181 * |
177 * e.g. compose(filter, compose(compose(filter, filter), filter)) --> 4 | 182 * e.g. compose(filter, compose(compose(filter, filter), filter)) --> 4 |
178 */ | 183 */ |
179 virtual int privateComposedFilterCount() const { return 1; } | 184 virtual int privateComposedFilterCount() const { return 1; } |
180 friend class SkComposeColorFilter; | 185 friend class SkComposeColorFilter; |
181 | 186 |
182 typedef SkFlattenable INHERITED; | 187 typedef SkFlattenable INHERITED; |
183 }; | 188 }; |
184 | 189 |
185 #endif | 190 #endif |
OLD | NEW |