| 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 GrContext; | 16 class GrContext; |
| 17 class GrEffectRef; | 17 class GrEffectRef; |
| 18 class GrTexture; |
| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return AsMode(xfer, mode); | 191 return AsMode(xfer, mode); |
| 191 } | 192 } |
| 192 | 193 |
| 193 /** A subclass may implement this factory function to work with the GPU back
end. It is legal | 194 /** A subclass may implement this factory function to work with the GPU back
end. It is legal |
| 194 to call this with all but the context param NULL to simply test the retu
rn value. effect, | 195 to call this with all but the context param NULL to simply test the retu
rn value. effect, |
| 195 src, and dst must all be NULL or all non-NULL. If effect is non-NULL the
n the xfermode may | 196 src, and dst must all be NULL or all non-NULL. If effect is non-NULL the
n the xfermode may |
| 196 optionally allocate an effect to return and the caller as *effect. The c
aller will install | 197 optionally allocate an effect to return and the caller as *effect. The c
aller will install |
| 197 it and own a ref to it. Since the xfermode may or may not assign *effect
, the caller should | 198 it and own a ref to it. Since the xfermode may or may not assign *effect
, the caller should |
| 198 set *effect to NULL beforehand. If the function returns true and *effect
is NULL then the | 199 set *effect to NULL beforehand. If the function returns true and *effect
is NULL then the |
| 199 src and dst coeffs will be applied to the draw. When *effect is non-NULL
the coeffs are | 200 src and dst coeffs will be applied to the draw. When *effect is non-NULL
the coeffs are |
| 200 ignored. | 201 ignored. background specifies the texture to use as the background for c
ompositing, and |
| 202 should be accessed in the effect's fragment shader. If NULL, the effect
should request |
| 203 access to destination color (setWillReadDstColor()), and use that in the
fragment shader |
| 204 (builder->dstColor()). |
| 201 */ | 205 */ |
| 202 virtual bool asNewEffectOrCoeff(GrContext*, | 206 virtual bool asNewEffectOrCoeff(GrContext*, |
| 203 GrEffectRef** effect, | 207 GrEffectRef** effect, |
| 204 Coeff* src, | 208 Coeff* src, |
| 205 Coeff* dst) const; | 209 Coeff* dst, |
| 210 GrTexture* background = NULL) const; |
| 206 | 211 |
| 207 /** | 212 /** |
| 208 * The same as calling xfermode->asNewEffect(...), except that this also ch
ecks if the xfermode | 213 * The same as calling xfermode->asNewEffect(...), except that this also ch
ecks if the xfermode |
| 209 * is NULL, and if so, treats it as kSrcOver_Mode. | 214 * is NULL, and if so, treats it as kSrcOver_Mode. |
| 210 */ | 215 */ |
| 211 static bool AsNewEffectOrCoeff(SkXfermode*, | 216 static bool AsNewEffectOrCoeff(SkXfermode*, |
| 212 GrContext*, | 217 GrContext*, |
| 213 GrEffectRef** effect, | 218 GrEffectRef** effect, |
| 214 Coeff* src, | 219 Coeff* src, |
| 215 Coeff* dst); | 220 Coeff* dst, |
| 221 GrTexture* background = NULL); |
| 216 | 222 |
| 217 SkDEVCODE(virtual void toString(SkString* str) const = 0;) | 223 SkDEVCODE(virtual void toString(SkString* str) const = 0;) |
| 218 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 224 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 219 protected: | 225 protected: |
| 220 SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} | 226 SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} |
| 221 | 227 |
| 222 /** The default implementation of xfer32/xfer16/xferA8 in turn call this | 228 /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
| 223 method, 1 color at a time (upscaled to a SkPMColor). The default | 229 method, 1 color at a time (upscaled to a SkPMColor). The default |
| 224 implmentation of this method just returns dst. If performance is | 230 implmentation of this method just returns dst. If performance is |
| 225 important, your subclass should override xfer32/xfer16/xferA8 directly. | 231 important, your subclass should override xfer32/xfer16/xferA8 directly. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 fProc = proc; | 275 fProc = proc; |
| 270 } | 276 } |
| 271 | 277 |
| 272 private: | 278 private: |
| 273 SkXfermodeProc fProc; | 279 SkXfermodeProc fProc; |
| 274 | 280 |
| 275 typedef SkXfermode INHERITED; | 281 typedef SkXfermode INHERITED; |
| 276 }; | 282 }; |
| 277 | 283 |
| 278 #endif | 284 #endif |
| OLD | NEW |