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 SkXfermode_DEFINED | 8 #ifndef SkXfermode_DEFINED |
9 #define SkXfermode_DEFINED | 9 #define SkXfermode_DEFINED |
10 | 10 |
11 #include "SkFlattenable.h" | 11 #include "SkFlattenable.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 | 13 |
14 class GrFragmentProcessor; | 14 class GrFragmentProcessor; |
15 class GrTexture; | 15 class GrTexture; |
16 class GrXPFactory; | 16 class GrXPFactory; |
17 class SkRasterPipeline; | |
18 class SkString; | 17 class SkString; |
19 | 18 |
20 struct SkPM4f; | 19 struct SkPM4f; |
21 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst); | 20 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst); |
22 | 21 |
23 /** \class SkXfermode | 22 /** \class SkXfermode |
24 * | 23 * |
25 * SkXfermode is the base class for objects that are called to implement custom | 24 * SkXfermode is the base class for objects that are called to implement custom |
26 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) | 25 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) |
27 * can be called to return an instance of any of the predefined subclasses as | 26 * can be called to return an instance of any of the predefined subclasses as |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 #endif | 157 #endif |
159 | 158 |
160 /** Return a function pointer to a routine that applies the specified | 159 /** Return a function pointer to a routine that applies the specified |
161 porter-duff transfer mode. | 160 porter-duff transfer mode. |
162 */ | 161 */ |
163 static SkXfermodeProc GetProc(Mode mode); | 162 static SkXfermodeProc GetProc(Mode mode); |
164 static SkXfermodeProc4f GetProc4f(Mode); | 163 static SkXfermodeProc4f GetProc4f(Mode); |
165 | 164 |
166 virtual SkXfermodeProc4f getProc4f() const; | 165 virtual SkXfermodeProc4f getProc4f() const; |
167 | 166 |
168 bool appendStages(SkRasterPipeline*) const; | |
169 | |
170 /** | 167 /** |
171 * If the specified mode can be represented by a pair of Coeff, then return | 168 * If the specified mode can be represented by a pair of Coeff, then return |
172 * true and set (if not NULL) the corresponding coeffs. If the mode is | 169 * true and set (if not NULL) the corresponding coeffs. If the mode is |
173 * not representable as a pair of Coeffs, return false and ignore the | 170 * not representable as a pair of Coeffs, return false and ignore the |
174 * src and dst parameters. | 171 * src and dst parameters. |
175 */ | 172 */ |
176 static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst); | 173 static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst); |
177 | 174 |
178 /** | 175 /** |
179 * Returns whether or not the xfer mode can support treating coverage as alp
ha | 176 * Returns whether or not the xfer mode can support treating coverage as alp
ha |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. | 209 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
213 */ | 210 */ |
214 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); | 211 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); |
215 static bool IsOpaque(const sk_sp<SkXfermode>& xfer, SrcColorOpacity opacityT
ype) { | 212 static bool IsOpaque(const sk_sp<SkXfermode>& xfer, SrcColorOpacity opacityT
ype) { |
216 return IsOpaque(xfer.get(), opacityType); | 213 return IsOpaque(xfer.get(), opacityType); |
217 } | 214 } |
218 | 215 |
219 #if SK_SUPPORT_GPU | 216 #if SK_SUPPORT_GPU |
220 /** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentPr
ocessor. | 217 /** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentPr
ocessor. |
221 The input to the returned FP is the src color. The dst color is | 218 The input to the returned FP is the src color. The dst color is |
222 provided by the dst param which becomes a child FP of the returned FP. | 219 provided by the dst param which becomes a child FP of the returned FP. |
223 It is legal for the function to return a null output. This indicates tha
t | 220 It is legal for the function to return a null output. This indicates tha
t |
224 the output of the blend is simply the src color. | 221 the output of the blend is simply the src color. |
225 */ | 222 */ |
226 virtual sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter( | 223 virtual sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter( |
227 sk_sp<GrFragmentProc
essor> dst) const; | 224 sk_sp<GrFragmentProc
essor> dst) const; |
228 | 225 |
229 /** A subclass must implement this factory function to work with the GPU bac
kend. | 226 /** A subclass must implement this factory function to work with the GPU bac
kend. |
230 The xfermode will return a factory for which the caller will get a ref.
It is up | 227 The xfermode will return a factory for which the caller will get a ref.
It is up |
231 to the caller to install it. XferProcessors cannot use a background text
ure. | 228 to the caller to install it. XferProcessors cannot use a background text
ure. |
232 */ | 229 */ |
233 virtual sk_sp<GrXPFactory> asXPFactory() const; | 230 virtual sk_sp<GrXPFactory> asXPFactory() const; |
234 #endif | 231 #endif |
235 | 232 |
236 SK_TO_STRING_PUREVIRT() | 233 SK_TO_STRING_PUREVIRT() |
237 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 234 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
238 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) | 235 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
239 | 236 |
240 enum D32Flags { | 237 enum D32Flags { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 implementation of this method just returns dst. If performance is | 274 implementation of this method just returns dst. If performance is |
278 important, your subclass should override xfer32/xfer16/xferA8 directly. | 275 important, your subclass should override xfer32/xfer16/xferA8 directly. |
279 | 276 |
280 This method will not be called directly by the client, so it need not | 277 This method will not be called directly by the client, so it need not |
281 be implemented if your subclass has overridden xfer32/xfer16/xferA8 | 278 be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
282 */ | 279 */ |
283 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; | 280 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
284 | 281 |
285 virtual D32Proc onGetD32Proc(uint32_t flags) const; | 282 virtual D32Proc onGetD32Proc(uint32_t flags) const; |
286 virtual F16Proc onGetF16Proc(uint32_t flags) const; | 283 virtual F16Proc onGetF16Proc(uint32_t flags) const; |
287 virtual bool onAppendStages(SkRasterPipeline*) const; | |
288 | 284 |
289 private: | 285 private: |
290 enum { | 286 enum { |
291 kModeCount = kLastMode + 1 | 287 kModeCount = kLastMode + 1 |
292 }; | 288 }; |
293 | 289 |
294 typedef SkFlattenable INHERITED; | 290 typedef SkFlattenable INHERITED; |
295 }; | 291 }; |
296 | 292 |
297 #endif | 293 #endif |
OLD | NEW |