9 #ifndef GrBlend_DEFINED
10 #define GrBlend_DEFINED
13 #include "../private/SkTLogic.h"
18 enum GrBlendEquation {
21 kSubtract_GrBlendEquation,
22 kReverseSubtract_GrBlendEquation,
25 kScreen_GrBlendEquation,
26 kOverlay_GrBlendEquation,
27 kDarken_GrBlendEquation,
28 kLighten_GrBlendEquation,
29 kColorDodge_GrBlendEquation,
30 kColorBurn_GrBlendEquation,
31 kHardLight_GrBlendEquation,
32 kSoftLight_GrBlendEquation,
33 kDifference_GrBlendEquation,
34 kExclusion_GrBlendEquation,
35 kMultiply_GrBlendEquation,
36 kHSLHue_GrBlendEquation,
37 kHSLSaturation_GrBlendEquation,
38 kHSLColor_GrBlendEquation,
39 kHSLLuminosity_GrBlendEquation,
41 kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation,
42 kLast_GrBlendEquation = kHSLLuminosity_GrBlendEquation
45 static const int kGrBlendEquationCnt = kLast_GrBlendEquation + 1;
63 kIConstC_GrBlendCoeff,
65 kIConstA_GrBlendCoeff,
71 kLast_GrBlendCoeff = kIS2A_GrBlendCoeff
74 static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1;
82 void GrGetCoeffBlendKnownComponents(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff,
84 GrColorComponentFlags srcColorFlags,
86 GrColorComponentFlags dstColorFlags,
88 GrColorComponentFlags* outFlags);
90 template<GrBlendCoeff Coeff>
92 kISC_GrBlendCoeff == Coeff ||
93 kSA_GrBlendCoeff == Coeff ||
94 kISA_GrBlendCoeff == Coeff> {};
96 #define GR_BLEND_COEFF_REFS_SRC(COEFF) \
97 GrTBlendCoeffRefsSrc<COEFF>::value
99 inline bool GrBlendCoeffRefsSrc(GrBlendCoeff coeff) {
101 case kSC_GrBlendCoeff:
102 case kISC_GrBlendCoeff:
103 case kSA_GrBlendCoeff:
104 case kISA_GrBlendCoeff:
111 template<GrBlendCoeff Coeff>
113 kIDC_GrBlendCoeff == Coeff ||
114 kDA_GrBlendCoeff == Coeff ||
115 kIDA_GrBlendCoeff == Coeff> {};
117 #define GR_BLEND_COEFF_REFS_DST(COEFF) \
118 GrTBlendCoeffRefsDst<COEFF>::value
120 inline bool GrBlendCoeffRefsDst(GrBlendCoeff coeff) {
122 case kDC_GrBlendCoeff:
123 case kIDC_GrBlendCoeff:
124 case kDA_GrBlendCoeff:
125 case kIDA_GrBlendCoeff:
133 template<GrBlendCoeff Coeff>
135 kIS2C_GrBlendCoeff == Coeff ||
136 kS2A_GrBlendCoeff == Coeff ||
137 kIS2A_GrBlendCoeff == Coeff> {};
139 #define GR_BLEND_COEFF_REFS_SRC2(COEFF) \
140 GrTBlendCoeffRefsSrc2<COEFF>::value
142 inline bool GrBlendCoeffRefsSrc2(GrBlendCoeff coeff) {
144 case kS2C_GrBlendCoeff:
145 case kIS2C_GrBlendCoeff:
146 case kS2A_GrBlendCoeff:
147 case kIS2A_GrBlendCoeff:
155 template<GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff>
157 GR_BLEND_COEFF_REFS_SRC(DstCoeff)> {};
159 #define GR_BLEND_COEFFS_USE_SRC_COLOR(SRC_COEFF, DST_COEFF) \
160 GrTBlendCoeffsUseSrcColor<SRC_COEFF, DST_COEFF>::value
163 template<GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff>
165 kZero_GrBlendCoeff != DstCoeff> {};
167 #define GR_BLEND_COEFFS_USE_DST_COLOR(SRC_COEFF, DST_COEFF) \
168 GrTBlendCoeffsUseDstColor<SRC_COEFF, DST_COEFF>::value
171 template<GrBlendEquation Equation>
174 #define GR_BLEND_EQUATION_IS_ADVANCED(EQUATION) \
175 GrTBlendEquationIsAdvanced<EQUATION>::value
177 inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) {
178 return equation >= kFirstAdvancedGrBlendEquation;
182 template<GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff>
184 (kAdd_GrBlendEquation != BlendEquation && kReverseSubtract_GrBlendEquation != BlendEquation) ||
185 kZero_GrBlendCoeff != SrcCoeff ||
186 kOne_GrBlendCoeff != DstCoeff> {};
188 #define GR_BLEND_MODIFIES_DST(EQUATION, SRC_COEFF, DST_COEFF) \
189 GrTBlendModifiesDst<EQUATION, SRC_COEFF, DST_COEFF>::value
216 template<GrBlendEquation Equation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff>
218 GR_BLEND_EQUATION_IS_ADVANCED(Equation) ||
219 ((kAdd_GrBlendEquation == Equation || kReverseSubtract_GrBlendEquation == Equation) &&
220 !GR_BLEND_COEFF_REFS_SRC(SrcCoeff) &&
221 (kOne_GrBlendCoeff == DstCoeff ||
222 kISC_GrBlendCoeff == DstCoeff ||
223 kISA_GrBlendCoeff == DstCoeff))> {};
225 #define GR_BLEND_CAN_TWEAK_ALPHA_FOR_COVERAGE(EQUATION, SRC_COEFF, DST_COEFF) \
226 GrTBlendCanTweakAlphaForCoverage<EQUATION, SRC_COEFF, DST_COEFF>::value
Definition: GrBlend.h:134
Advanced blend equations can always tweak alpha for coverage.
Definition: GrBlend.h:217
Definition: GrBlend.h:183
Definition: GrBlend.h:164
Definition: GrBlend.h:112
Definition: GrBlend.h:156
Definition: GrBlend.h:172