Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: include/gpu/GrBlend.h

Issue 1334293003: Create fragment processor for performing input color blend with child processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: working Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
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 #include "GrTypes.h"
10 #include "../private/SkTLogic.h"
11
12 #ifndef GrBlend_DEFINED 9 #ifndef GrBlend_DEFINED
13 #define GrBlend_DEFINED 10 #define GrBlend_DEFINED
14 11
12 #include "GrColor.h"
13 #include "../private/SkTLogic.h"
14
15 /** 15 /**
16 * Equations for alpha-blending. 16 * Equations for alpha-blending.
17 */ 17 */
18 enum GrBlendEquation { 18 enum GrBlendEquation {
19 // Basic blend equations. 19 // Basic blend equations.
20 kAdd_GrBlendEquation, //<! Cs*S + Cd*D 20 kAdd_GrBlendEquation, //<! Cs*S + Cd*D
21 kSubtract_GrBlendEquation, //<! Cs*S - Cd*D 21 kSubtract_GrBlendEquation, //<! Cs*S - Cd*D
22 kReverseSubtract_GrBlendEquation, //<! Cd*D - Cs*S 22 kReverseSubtract_GrBlendEquation, //<! Cd*D - Cs*S
23 23
24 // Advanced blend equations. These are described in the SVG and PDF specs. 24 // Advanced blend equations. These are described in the SVG and PDF specs.
(...skipping 14 matching lines...) Expand all
39 kHSLLuminosity_GrBlendEquation, 39 kHSLLuminosity_GrBlendEquation,
40 40
41 kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation, 41 kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation,
42 kLast_GrBlendEquation = kHSLLuminosity_GrBlendEquation 42 kLast_GrBlendEquation = kHSLLuminosity_GrBlendEquation
43 }; 43 };
44 44
45 static const int kGrBlendEquationCnt = kLast_GrBlendEquation + 1; 45 static const int kGrBlendEquationCnt = kLast_GrBlendEquation + 1;
46 46
47 47
48 /** 48 /**
49 * Coeffecients for alpha-blending. 49 * Coefficients for alpha-blending.
50 */ 50 */
51 enum GrBlendCoeff { 51 enum GrBlendCoeff {
52 kZero_GrBlendCoeff, //<! 0 52 kZero_GrBlendCoeff, //<! 0
53 kOne_GrBlendCoeff, //<! 1 53 kOne_GrBlendCoeff, //<! 1
54 kSC_GrBlendCoeff, //<! src color 54 kSC_GrBlendCoeff, //<! src color
55 kISC_GrBlendCoeff, //<! one minus src color 55 kISC_GrBlendCoeff, //<! one minus src color
56 kDC_GrBlendCoeff, //<! dst color 56 kDC_GrBlendCoeff, //<! dst color
57 kIDC_GrBlendCoeff, //<! one minus dst color 57 kIDC_GrBlendCoeff, //<! one minus dst color
58 kSA_GrBlendCoeff, //<! src alpha 58 kSA_GrBlendCoeff, //<! src alpha
59 kISA_GrBlendCoeff, //<! one minus src alpha 59 kISA_GrBlendCoeff, //<! one minus src alpha
60 kDA_GrBlendCoeff, //<! dst alpha 60 kDA_GrBlendCoeff, //<! dst alpha
61 kIDA_GrBlendCoeff, //<! one minus dst alpha 61 kIDA_GrBlendCoeff, //<! one minus dst alpha
62 kConstC_GrBlendCoeff, //<! constant color 62 kConstC_GrBlendCoeff, //<! constant color
63 kIConstC_GrBlendCoeff, //<! one minus constant color 63 kIConstC_GrBlendCoeff, //<! one minus constant color
64 kConstA_GrBlendCoeff, //<! constant color alpha 64 kConstA_GrBlendCoeff, //<! constant color alpha
65 kIConstA_GrBlendCoeff, //<! one minus constant color alpha 65 kIConstA_GrBlendCoeff, //<! one minus constant color alpha
66 kS2C_GrBlendCoeff, 66 kS2C_GrBlendCoeff,
67 kIS2C_GrBlendCoeff, 67 kIS2C_GrBlendCoeff,
68 kS2A_GrBlendCoeff, 68 kS2A_GrBlendCoeff,
69 kIS2A_GrBlendCoeff, 69 kIS2A_GrBlendCoeff,
70 70
71 kLast_GrBlendCoeff = kIS2A_GrBlendCoeff 71 kLast_GrBlendCoeff = kIS2A_GrBlendCoeff
72 }; 72 };
73 73
74 static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1; 74 static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1;
75 75
76 /**
77 * Given a known blend equation in the form of srcCoeff * srcColor + dstCoeff * dstColor where
78 * there may be partial knowledge of the srcColor and dstColor component values, determine what
79 * components of the blended output color are known. This only works for
80 */
81 void GrGetCoeffBlendKnownComponents(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff ,
82 GrColor srcColor,
83 GrColorComponentFlags srcColorFlags,
84 GrColor dstColor,
85 GrColorComponentFlags dstColorFlags,
86 GrColor* outColor,
87 GrColorComponentFlags* outFlags);
76 88
77 template<GrBlendCoeff Coeff> 89 template<GrBlendCoeff Coeff>
78 struct GrTBlendCoeffRefsSrc : skstd::bool_constant<kSC_GrBlendCoeff == Coeff || 90 struct GrTBlendCoeffRefsSrc : skstd::bool_constant<kSC_GrBlendCoeff == Coeff ||
79 kISC_GrBlendCoeff == Coeff || 91 kISC_GrBlendCoeff == Coeff ||
80 kSA_GrBlendCoeff == Coeff || 92 kSA_GrBlendCoeff == Coeff ||
81 kISA_GrBlendCoeff == Coeff> { }; 93 kISA_GrBlendCoeff == Coeff> { };
82 94
83 #define GR_BLEND_COEFF_REFS_SRC(COEFF) \ 95 #define GR_BLEND_COEFF_REFS_SRC(COEFF) \
84 GrTBlendCoeffRefsSrc<COEFF>::value 96 GrTBlendCoeffRefsSrc<COEFF>::value
85 97
86 inline bool GrBlendCoeffRefsSrc(GrBlendCoeff coeff) { 98 inline bool GrBlendCoeffRefsSrc(GrBlendCoeff coeff) {
87 switch (coeff) { 99 switch (coeff) {
88 case kSC_GrBlendCoeff: 100 case kSC_GrBlendCoeff:
89 case kISC_GrBlendCoeff: 101 case kISC_GrBlendCoeff:
90 case kSA_GrBlendCoeff: 102 case kSA_GrBlendCoeff:
91 case kISA_GrBlendCoeff: 103 case kISA_GrBlendCoeff:
92 return true; 104 return true;
93 default: 105 default:
94 return false; 106 return false;
95 } 107 }
96 } 108 }
97 109
98
99 template<GrBlendCoeff Coeff> 110 template<GrBlendCoeff Coeff>
100 struct GrTBlendCoeffRefsDst : skstd::bool_constant<kDC_GrBlendCoeff == Coeff || 111 struct GrTBlendCoeffRefsDst : skstd::bool_constant<kDC_GrBlendCoeff == Coeff ||
101 kIDC_GrBlendCoeff == Coeff || 112 kIDC_GrBlendCoeff == Coeff ||
102 kDA_GrBlendCoeff == Coeff || 113 kDA_GrBlendCoeff == Coeff ||
103 kIDA_GrBlendCoeff == Coeff> { }; 114 kIDA_GrBlendCoeff == Coeff> { };
104 115
105 #define GR_BLEND_COEFF_REFS_DST(COEFF) \ 116 #define GR_BLEND_COEFF_REFS_DST(COEFF) \
106 GrTBlendCoeffRefsDst<COEFF>::value 117 GrTBlendCoeffRefsDst<COEFF>::value
107 118
108 inline bool GrBlendCoeffRefsDst(GrBlendCoeff coeff) { 119 inline bool GrBlendCoeffRefsDst(GrBlendCoeff coeff) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 ((kAdd_GrBlendEquation == Equation || kReverseSubtract_GrBlendEquation == Eq uation) && 218 ((kAdd_GrBlendEquation == Equation || kReverseSubtract_GrBlendEquation == Eq uation) &&
208 !GR_BLEND_COEFF_REFS_SRC(SrcCoeff) && 219 !GR_BLEND_COEFF_REFS_SRC(SrcCoeff) &&
209 (kOne_GrBlendCoeff == DstCoeff || 220 (kOne_GrBlendCoeff == DstCoeff ||
210 kISC_GrBlendCoeff == DstCoeff || 221 kISC_GrBlendCoeff == DstCoeff ||
211 kISA_GrBlendCoeff == DstCoeff))> {}; 222 kISA_GrBlendCoeff == DstCoeff))> {};
212 223
213 #define GR_BLEND_CAN_TWEAK_ALPHA_FOR_COVERAGE(EQUATION, SRC_COEFF, DST_COEFF) \ 224 #define GR_BLEND_CAN_TWEAK_ALPHA_FOR_COVERAGE(EQUATION, SRC_COEFF, DST_COEFF) \
214 GrTBlendCanTweakAlphaForCoverage<EQUATION, SRC_COEFF, DST_COEFF>::value 225 GrTBlendCanTweakAlphaForCoverage<EQUATION, SRC_COEFF, DST_COEFF>::value
215 226
216 #endif 227 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698