OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 GrXferProcessor_DEFINED | 8 #ifndef GrXferProcessor_DEFINED |
9 #define GrXferProcessor_DEFINED | 9 #define GrXferProcessor_DEFINED |
10 | 10 |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
12 #include "GrProcessor.h" | 12 #include "GrProcessor.h" |
13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
14 #include "GrTypes.h" | 14 #include "GrTypes.h" |
15 #include "SkXfermode.h" | 15 #include "SkXfermode.h" |
16 | 16 |
17 class GrShaderCaps; | 17 class GrShaderCaps; |
18 class GrGLSLCaps; | 18 class GrGLSLCaps; |
19 class GrGLXferProcessor; | 19 class GrGLXferProcessor; |
20 class GrProcOptInfo; | 20 class GrProcOptInfo; |
21 | 21 |
22 /** | 22 /** |
23 * Equations for alpha-blending. | 23 * Equations for alpha-blending. |
24 */ | 24 */ |
25 enum GrBlendEquation { | 25 enum GrBlendEquation { |
26 kInvalid_GrBlendEquation = -1, | |
27 | |
28 // Basic blend equations. | 26 // Basic blend equations. |
29 kAdd_GrBlendEquation, //<! Cs*S + Cd*D | 27 kAdd_GrBlendEquation, //<! Cs*S + Cd*D |
30 kSubtract_GrBlendEquation, //<! Cs*S - Cd*D | 28 kSubtract_GrBlendEquation, //<! Cs*S - Cd*D |
31 kReverseSubtract_GrBlendEquation, //<! Cd*D - Cs*S | 29 kReverseSubtract_GrBlendEquation, //<! Cd*D - Cs*S |
32 | 30 |
33 // Advanced blend equations. These are described in the SVG and PDF specs. | 31 // Advanced blend equations. These are described in the SVG and PDF specs. |
34 kScreen_GrBlendEquation, | 32 kScreen_GrBlendEquation, |
35 kOverlay_GrBlendEquation, | 33 kOverlay_GrBlendEquation, |
36 kDarken_GrBlendEquation, | 34 kDarken_GrBlendEquation, |
37 kLighten_GrBlendEquation, | 35 kLighten_GrBlendEquation, |
38 kColorDodge_GrBlendEquation, | 36 kColorDodge_GrBlendEquation, |
39 kColorBurn_GrBlendEquation, | 37 kColorBurn_GrBlendEquation, |
40 kHardLight_GrBlendEquation, | 38 kHardLight_GrBlendEquation, |
41 kSoftLight_GrBlendEquation, | 39 kSoftLight_GrBlendEquation, |
42 kDifference_GrBlendEquation, | 40 kDifference_GrBlendEquation, |
43 kExclusion_GrBlendEquation, | 41 kExclusion_GrBlendEquation, |
44 kMultiply_GrBlendEquation, | 42 kMultiply_GrBlendEquation, |
45 kHSLHue_GrBlendEquation, | 43 kHSLHue_GrBlendEquation, |
46 kHSLSaturation_GrBlendEquation, | 44 kHSLSaturation_GrBlendEquation, |
47 kHSLColor_GrBlendEquation, | 45 kHSLColor_GrBlendEquation, |
48 kHSLLuminosity_GrBlendEquation, | 46 kHSLLuminosity_GrBlendEquation, |
49 | 47 |
50 kTotalGrBlendEquationCount, | 48 kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation, |
| 49 kLast_GrBlendEquation = kHSLLuminosity_GrBlendEquation |
| 50 }; |
51 | 51 |
52 kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation | 52 static const int kGrBlendEquationCnt = kLast_GrBlendEquation + 1; |
53 }; | |
54 | 53 |
55 inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) { | 54 inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) { |
56 return equation >= kFirstAdvancedGrBlendEquation; | 55 return equation >= kFirstAdvancedGrBlendEquation; |
57 } | 56 } |
58 | 57 |
59 /** | 58 /** |
60 * Coeffecients for alpha-blending. | 59 * Coeffecients for alpha-blending. |
61 */ | 60 */ |
62 enum GrBlendCoeff { | 61 enum GrBlendCoeff { |
63 kInvalid_GrBlendCoeff = -1, | |
64 | |
65 kZero_GrBlendCoeff, //<! 0 | 62 kZero_GrBlendCoeff, //<! 0 |
66 kOne_GrBlendCoeff, //<! 1 | 63 kOne_GrBlendCoeff, //<! 1 |
67 kSC_GrBlendCoeff, //<! src color | 64 kSC_GrBlendCoeff, //<! src color |
68 kISC_GrBlendCoeff, //<! one minus src color | 65 kISC_GrBlendCoeff, //<! one minus src color |
69 kDC_GrBlendCoeff, //<! dst color | 66 kDC_GrBlendCoeff, //<! dst color |
70 kIDC_GrBlendCoeff, //<! one minus dst color | 67 kIDC_GrBlendCoeff, //<! one minus dst color |
71 kSA_GrBlendCoeff, //<! src alpha | 68 kSA_GrBlendCoeff, //<! src alpha |
72 kISA_GrBlendCoeff, //<! one minus src alpha | 69 kISA_GrBlendCoeff, //<! one minus src alpha |
73 kDA_GrBlendCoeff, //<! dst alpha | 70 kDA_GrBlendCoeff, //<! dst alpha |
74 kIDA_GrBlendCoeff, //<! one minus dst alpha | 71 kIDA_GrBlendCoeff, //<! one minus dst alpha |
75 kConstC_GrBlendCoeff, //<! constant color | 72 kConstC_GrBlendCoeff, //<! constant color |
76 kIConstC_GrBlendCoeff, //<! one minus constant color | 73 kIConstC_GrBlendCoeff, //<! one minus constant color |
77 kConstA_GrBlendCoeff, //<! constant color alpha | 74 kConstA_GrBlendCoeff, //<! constant color alpha |
78 kIConstA_GrBlendCoeff, //<! one minus constant color alpha | 75 kIConstA_GrBlendCoeff, //<! one minus constant color alpha |
79 kS2C_GrBlendCoeff, | 76 kS2C_GrBlendCoeff, |
80 kIS2C_GrBlendCoeff, | 77 kIS2C_GrBlendCoeff, |
81 kS2A_GrBlendCoeff, | 78 kS2A_GrBlendCoeff, |
82 kIS2A_GrBlendCoeff, | 79 kIS2A_GrBlendCoeff, |
83 | 80 |
84 kTotalGrBlendCoeffCount | 81 kLast_GrBlendCoeff = kIS2A_GrBlendCoeff |
85 }; | 82 }; |
86 | 83 |
| 84 static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1; |
| 85 |
87 /** | 86 /** |
88 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier
is sometimes | 87 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier
is sometimes |
89 * required after a pixel has been written, before it can be safely read again. | 88 * required after a pixel has been written, before it can be safely read again. |
90 */ | 89 */ |
91 enum GrXferBarrierType { | 90 enum GrXferBarrierType { |
92 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders to
the same texture. | 91 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders to
the same texture. |
93 kBlend_GrXferBarrierType, //<! Required by certain blend extensions. | 92 kBlend_GrXferBarrierType, //<! Required by certain blend extensions. |
94 }; | 93 }; |
95 | 94 |
96 /** | 95 /** |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 179 |
181 struct BlendInfo { | 180 struct BlendInfo { |
182 void reset() { | 181 void reset() { |
183 fEquation = kAdd_GrBlendEquation; | 182 fEquation = kAdd_GrBlendEquation; |
184 fSrcBlend = kOne_GrBlendCoeff; | 183 fSrcBlend = kOne_GrBlendCoeff; |
185 fDstBlend = kZero_GrBlendCoeff; | 184 fDstBlend = kZero_GrBlendCoeff; |
186 fBlendConstant = 0; | 185 fBlendConstant = 0; |
187 fWriteColor = true; | 186 fWriteColor = true; |
188 } | 187 } |
189 | 188 |
| 189 SkDEBUGCODE(SkString dump() const;) |
| 190 |
190 GrBlendEquation fEquation; | 191 GrBlendEquation fEquation; |
191 GrBlendCoeff fSrcBlend; | 192 GrBlendCoeff fSrcBlend; |
192 GrBlendCoeff fDstBlend; | 193 GrBlendCoeff fDstBlend; |
193 GrColor fBlendConstant; | 194 GrColor fBlendConstant; |
194 bool fWriteColor; | 195 bool fWriteColor; |
195 }; | 196 }; |
196 | 197 |
197 void getBlendInfo(BlendInfo* blendInfo) const { | 198 void getBlendInfo(BlendInfo* blendInfo) const { |
198 blendInfo->reset(); | 199 blendInfo->reset(); |
199 this->onGetBlendInfo(blendInfo); | 200 this->onGetBlendInfo(blendInfo); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 enum { | 400 enum { |
400 kIllegalXPFClassID = 0, | 401 kIllegalXPFClassID = 0, |
401 }; | 402 }; |
402 static int32_t gCurrXPFClassID; | 403 static int32_t gCurrXPFClassID; |
403 | 404 |
404 typedef GrProgramElement INHERITED; | 405 typedef GrProgramElement INHERITED; |
405 }; | 406 }; |
406 | 407 |
407 #endif | 408 #endif |
408 | 409 |
OLD | NEW |