| 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 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 kDC_Coeff, /** dst color */ | 50 kDC_Coeff, /** dst color */ |
| 51 kIDC_Coeff, /** inverse dst color (i.e. 1 - dc) */ | 51 kIDC_Coeff, /** inverse dst color (i.e. 1 - dc) */ |
| 52 kSA_Coeff, /** src alpha */ | 52 kSA_Coeff, /** src alpha */ |
| 53 kISA_Coeff, /** inverse src alpha (i.e. 1 - sa) */ | 53 kISA_Coeff, /** inverse src alpha (i.e. 1 - sa) */ |
| 54 kDA_Coeff, /** dst alpha */ | 54 kDA_Coeff, /** dst alpha */ |
| 55 kIDA_Coeff, /** inverse dst alpha (i.e. 1 - da) */ | 55 kIDA_Coeff, /** inverse dst alpha (i.e. 1 - da) */ |
| 56 | 56 |
| 57 kCoeffCount | 57 kCoeffCount |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 /** If the xfermode can be expressed as an equation using the coefficients | |
| 61 in Coeff, then asCoeff() returns true, and sets (if not null) src and | |
| 62 dst accordingly. | |
| 63 | |
| 64 result = src_coeff * src_color + dst_coeff * dst_color; | |
| 65 | |
| 66 As examples, here are some of the porterduff coefficients | |
| 67 | |
| 68 MODE SRC_COEFF DST_COEFF | |
| 69 clear zero zero | |
| 70 src one zero | |
| 71 dst zero one | |
| 72 srcover one isa | |
| 73 dstover ida one | |
| 74 */ | |
| 75 virtual bool asCoeff(Coeff* src, Coeff* dst) const; | |
| 76 | |
| 77 /** | |
| 78 * The same as calling xfermode->asCoeff(..), except that this also checks | |
| 79 * if the xfermode is NULL, and if so, treats it as kSrcOver_Mode. | |
| 80 */ | |
| 81 static bool AsCoeff(const SkXfermode*, Coeff* src, Coeff* dst); | |
| 82 | |
| 83 /** List of predefined xfermodes. | 60 /** List of predefined xfermodes. |
| 84 The algebra for the modes uses the following symbols: | 61 The algebra for the modes uses the following symbols: |
| 85 Sa, Sc - source alpha and color | 62 Sa, Sc - source alpha and color |
| 86 Da, Dc - destination alpha and color (before compositing) | 63 Da, Dc - destination alpha and color (before compositing) |
| 87 [a, c] - Resulting (alpha, color) values | 64 [a, c] - Resulting (alpha, color) values |
| 88 For these equations, the colors are in premultiplied state. | 65 For these equations, the colors are in premultiplied state. |
| 89 If no xfermode is specified, kSrcOver is assumed. | 66 If no xfermode is specified, kSrcOver is assumed. |
| 90 The modes are ordered by those that can be expressed as a pair of Coeffs
, followed by those | 67 The modes are ordered by those that can be expressed as a pair of Coeffs
, followed by those |
| 91 that aren't Coeffs but have separable r,g,b computations, and finally | 68 that aren't Coeffs but have separable r,g,b computations, and finally |
| 92 those that are not separable. | 69 those that are not separable. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 * not representable as a pair of Coeffs, return false and ignore the | 160 * not representable as a pair of Coeffs, return false and ignore the |
| 184 * src and dst parameters. | 161 * src and dst parameters. |
| 185 */ | 162 */ |
| 186 static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst); | 163 static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst); |
| 187 | 164 |
| 188 SK_ATTR_DEPRECATED("use AsMode(...)") | 165 SK_ATTR_DEPRECATED("use AsMode(...)") |
| 189 static bool IsMode(const SkXfermode* xfer, Mode* mode) { | 166 static bool IsMode(const SkXfermode* xfer, Mode* mode) { |
| 190 return AsMode(xfer, mode); | 167 return AsMode(xfer, mode); |
| 191 } | 168 } |
| 192 | 169 |
| 170 /** |
| 171 * Returns whether or not the xfer mode can support treating coverage as alp
ha |
| 172 */ |
| 173 virtual bool supportsCoverageAsAlpha() const; |
| 174 |
| 175 /** |
| 176 * The same as calling xfermode->supportsCoverageAsAlpha(), except that thi
s also checks if |
| 177 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
| 178 */ |
| 179 static bool SupportsCoverageAsAlpha(const SkXfermode* xfer); |
| 180 |
| 181 enum SrcColorOpacity { |
| 182 // The src color is known to be opaque (alpha == 255) |
| 183 kOpaque_SrcColorOpacity = 0, |
| 184 // The src color is known to be fully transparent (color == 0) |
| 185 kTransparentBlack_SrcColorOpacity = 1, |
| 186 // The src alpha is known to be fully transparent (alpha == 0) |
| 187 kTransparentAlpha_SrcColorOpacity = 2, |
| 188 // The src color opacity is unknown |
| 189 kUnknown_SrcColorOpacity = 3 |
| 190 }; |
| 191 |
| 192 /** |
| 193 * Returns whether or not the result of the draw with the xfer mode will be
opaque or not. The |
| 194 * input to this call is an enum describing known information about the opac
ity of the src color |
| 195 * that will be given to the xfer mode. |
| 196 */ |
| 197 virtual bool isOpaque(SrcColorOpacity opacityType) const; |
| 198 |
| 199 /** |
| 200 * The same as calling xfermode->isOpaque(...), except that this also check
s if |
| 201 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
| 202 */ |
| 203 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); |
| 204 |
| 193 /** Implemented by a subclass to support use as an image filter in the GPU b
ackend. When used as | 205 /** Implemented by a subclass to support use as an image filter in the GPU b
ackend. When used as |
| 194 an image filter the xfer mode blends the source color against a backgrou
nd texture rather | 206 an image filter the xfer mode blends the source color against a backgrou
nd texture rather |
| 195 than the destination. It is implemented as a fragment processor. This ca
n be called with | 207 than the destination. It is implemented as a fragment processor. This ca
n be called with |
| 196 both params set to NULL to query whether it would succeed. Otherwise, bo
th params are | 208 both params set to NULL to query whether it would succeed. Otherwise, bo
th params are |
| 197 required. Upon success the function returns true and the caller owns a r
ef to the fragment | 209 required. Upon success the function returns true and the caller owns a r
ef to the fragment |
| 198 parameter. Upon failure false is returned and the processor param is not
written to. | 210 parameter. Upon failure false is returned and the processor param is not
written to. |
| 199 */ | 211 */ |
| 200 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun
d) const; | 212 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun
d) const; |
| 201 | 213 |
| 202 /** A subclass may implement this factory function to work with the GPU back
end. It is legal | 214 /** A subclass may implement this factory function to work with the GPU back
end. It is legal |
| (...skipping 28 matching lines...) Expand all Loading... |
| 231 | 243 |
| 232 private: | 244 private: |
| 233 enum { | 245 enum { |
| 234 kModeCount = kLastMode + 1 | 246 kModeCount = kLastMode + 1 |
| 235 }; | 247 }; |
| 236 | 248 |
| 237 typedef SkFlattenable INHERITED; | 249 typedef SkFlattenable INHERITED; |
| 238 }; | 250 }; |
| 239 | 251 |
| 240 #endif | 252 #endif |
| OLD | NEW |