OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkXfermode_DEFINED | 10 #ifndef SkXfermode_DEFINED |
11 #define SkXfermode_DEFINED | 11 #define SkXfermode_DEFINED |
12 | 12 |
13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
14 #include "SkColor.h" | 14 #include "SkColor.h" |
15 | 15 |
16 class GrFragmentProcessor; | 16 class GrFragmentProcessor; |
17 class GrTexture; | 17 class GrTexture; |
18 class GrXPFactory; | |
18 class SkString; | 19 class SkString; |
19 | 20 |
20 /** \class SkXfermode | 21 /** \class SkXfermode |
21 * | 22 * |
22 * SkXfermode is the base class for objects that are called to implement custom | 23 * SkXfermode is the base class for objects that are called to implement custom |
23 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) | 24 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) |
24 * can be called to return an instance of any of the predefined subclasses as | 25 * can be called to return an instance of any of the predefined subclasses as |
25 * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, | 26 * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, |
26 * then objects drawn with that paint have the xfermode applied. | 27 * then objects drawn with that paint have the xfermode applied. |
27 * | 28 * |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 to call this with all params NULL to simply test the return value. If ef fect is non-NULL | 194 to call this with all params NULL to simply test the return value. If ef fect is non-NULL |
194 then the xfermode may optionally allocate an effect to return and the ca ller as *effect. | 195 then the xfermode may optionally allocate an effect to return and the ca ller as *effect. |
195 The caller will install it and own a ref to it. Since the xfermode may o r may not assign | 196 The caller will install it and own a ref to it. Since the xfermode may o r may not assign |
196 *effect, the caller should set *effect to NULL beforehand. background sp ecifies the | 197 *effect, the caller should set *effect to NULL beforehand. background sp ecifies the |
197 texture to use as the background for compositing, and should be accessed in the effect's | 198 texture to use as the background for compositing, and should be accessed in the effect's |
198 fragment shader. If NULL, the effect should request access to destinatio n color | 199 fragment shader. If NULL, the effect should request access to destinatio n color |
199 (setWillReadDstColor()), and use that in the fragment shader (builder->d stColor()). | 200 (setWillReadDstColor()), and use that in the fragment shader (builder->d stColor()). |
200 */ | 201 */ |
201 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun d = NULL) const; | 202 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun d = NULL) const; |
202 | 203 |
203 /** Returns true if the xfermode can be expressed as coeffs (src, dst), or a s an effect | 204 /** A subclass may implement this factory function to work with the GPU back end. It is legal |
204 (effect). This helper calls the asCoeff() and asFragmentProcessor() virt uals. If the | 205 to call this with xpf NULL to simply test the return value. If effect is non-NULL |
bsalomon
2014/11/26 21:02:44
Use "factory" instead of "effect"? I don't really
egdaniel
2014/12/01 18:18:24
Done.
| |
205 xfermode is NULL, it is treated as kSrcOver_Mode. It is legal to call th is with all params | 206 then the xfermode may optionally allocate an effect to return and the ca ller as *effect. |
206 NULL to simply test the return value. effect, src, and dst must all be NULL or all | 207 The caller will install it and own a ref to it. Since the xfermode may o r may not assign |
207 non-NULL. | 208 *effect, the caller should set *effect to NULL beforehand. XP's cannot u se a background |
209 texture since they have no coord transforms. | |
208 */ | 210 */ |
209 static bool asFragmentProcessorOrCoeff(SkXfermode*, GrFragmentProcessor**, C oeff* src, | 211 virtual bool asXPFactory(GrXPFactory** xpf) const; |
210 Coeff* dst, GrTexture* background = N ULL); | 212 |
213 /** Returns true if the xfermode can be expressed as coeffs (src, dst), a xf er processor | |
214 (returned as xpFactory), or a fragment processor. This helper calls the asCoeff(), | |
215 asXPFactor(), and asFragmentProcessor() virtuals. If the xfermode is NUL L, it is treated | |
216 as kSrcOver_Mode. It is legal to call this with all params NULL to simpl y test the return | |
217 value. effect, src, and dst must all be NULL or all non-NULL. | |
218 */ | |
219 static bool asFragmentProcessorOrXPFactoryOrCoeff(SkXfermode*, GrFragmentPro cessor**, | |
bsalomon
2014/11/26 21:02:44
Yikes! I guess its just temporary. Do we really ne
egdaniel
2014/12/01 18:18:24
Better for now?
| |
220 GrXPFactory**, Coeff* src, Coeff* dst, | |
221 GrTexture* background = NU LL); | |
211 | 222 |
212 SK_TO_STRING_PUREVIRT() | 223 SK_TO_STRING_PUREVIRT() |
213 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 224 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
214 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) | 225 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
215 | 226 |
216 protected: | 227 protected: |
217 SkXfermode() {} | 228 SkXfermode() {} |
218 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 229 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
219 explicit SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {} | 230 explicit SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {} |
220 #endif | 231 #endif |
(...skipping 10 matching lines...) Expand all Loading... | |
231 | 242 |
232 private: | 243 private: |
233 enum { | 244 enum { |
234 kModeCount = kLastMode + 1 | 245 kModeCount = kLastMode + 1 |
235 }; | 246 }; |
236 | 247 |
237 typedef SkFlattenable INHERITED; | 248 typedef SkFlattenable INHERITED; |
238 }; | 249 }; |
239 | 250 |
240 #endif | 251 #endif |
OLD | NEW |