OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 GR_STATIC_ASSERT(8 == kColorBurn_GrBlendEquation); | 73 GR_STATIC_ASSERT(8 == kColorBurn_GrBlendEquation); |
74 GR_STATIC_ASSERT(9 == kHardLight_GrBlendEquation); | 74 GR_STATIC_ASSERT(9 == kHardLight_GrBlendEquation); |
75 GR_STATIC_ASSERT(10 == kSoftLight_GrBlendEquation); | 75 GR_STATIC_ASSERT(10 == kSoftLight_GrBlendEquation); |
76 GR_STATIC_ASSERT(11 == kDifference_GrBlendEquation); | 76 GR_STATIC_ASSERT(11 == kDifference_GrBlendEquation); |
77 GR_STATIC_ASSERT(12 == kExclusion_GrBlendEquation); | 77 GR_STATIC_ASSERT(12 == kExclusion_GrBlendEquation); |
78 GR_STATIC_ASSERT(13 == kMultiply_GrBlendEquation); | 78 GR_STATIC_ASSERT(13 == kMultiply_GrBlendEquation); |
79 GR_STATIC_ASSERT(14 == kHSLHue_GrBlendEquation); | 79 GR_STATIC_ASSERT(14 == kHSLHue_GrBlendEquation); |
80 GR_STATIC_ASSERT(15 == kHSLSaturation_GrBlendEquation); | 80 GR_STATIC_ASSERT(15 == kHSLSaturation_GrBlendEquation); |
81 GR_STATIC_ASSERT(16 == kHSLColor_GrBlendEquation); | 81 GR_STATIC_ASSERT(16 == kHSLColor_GrBlendEquation); |
82 GR_STATIC_ASSERT(17 == kHSLLuminosity_GrBlendEquation); | 82 GR_STATIC_ASSERT(17 == kHSLLuminosity_GrBlendEquation); |
83 GR_STATIC_ASSERT(18 == kTotalGrBlendEquationCount); | 83 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gXfermodeEquation2Blend) == kGrBlendEquationCnt)
; |
84 | 84 |
85 static const GrGLenum gXfermodeCoeff2Blend[] = { | 85 static const GrGLenum gXfermodeCoeff2Blend[] = { |
86 GR_GL_ZERO, | 86 GR_GL_ZERO, |
87 GR_GL_ONE, | 87 GR_GL_ONE, |
88 GR_GL_SRC_COLOR, | 88 GR_GL_SRC_COLOR, |
89 GR_GL_ONE_MINUS_SRC_COLOR, | 89 GR_GL_ONE_MINUS_SRC_COLOR, |
90 GR_GL_DST_COLOR, | 90 GR_GL_DST_COLOR, |
91 GR_GL_ONE_MINUS_DST_COLOR, | 91 GR_GL_ONE_MINUS_DST_COLOR, |
92 GR_GL_SRC_ALPHA, | 92 GR_GL_SRC_ALPHA, |
93 GR_GL_ONE_MINUS_SRC_ALPHA, | 93 GR_GL_ONE_MINUS_SRC_ALPHA, |
(...skipping 28 matching lines...) Expand all Loading... |
122 true, | 122 true, |
123 true, | 123 true, |
124 | 124 |
125 // extended blend coeffs | 125 // extended blend coeffs |
126 false, | 126 false, |
127 false, | 127 false, |
128 false, | 128 false, |
129 false, | 129 false, |
130 }; | 130 }; |
131 return gCoeffReferencesBlendConst[coeff]; | 131 return gCoeffReferencesBlendConst[coeff]; |
132 GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == | 132 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendCon
st)); |
133 SK_ARRAY_COUNT(gCoeffReferencesBlendConst)); | |
134 | 133 |
135 GR_STATIC_ASSERT(0 == kZero_GrBlendCoeff); | 134 GR_STATIC_ASSERT(0 == kZero_GrBlendCoeff); |
136 GR_STATIC_ASSERT(1 == kOne_GrBlendCoeff); | 135 GR_STATIC_ASSERT(1 == kOne_GrBlendCoeff); |
137 GR_STATIC_ASSERT(2 == kSC_GrBlendCoeff); | 136 GR_STATIC_ASSERT(2 == kSC_GrBlendCoeff); |
138 GR_STATIC_ASSERT(3 == kISC_GrBlendCoeff); | 137 GR_STATIC_ASSERT(3 == kISC_GrBlendCoeff); |
139 GR_STATIC_ASSERT(4 == kDC_GrBlendCoeff); | 138 GR_STATIC_ASSERT(4 == kDC_GrBlendCoeff); |
140 GR_STATIC_ASSERT(5 == kIDC_GrBlendCoeff); | 139 GR_STATIC_ASSERT(5 == kIDC_GrBlendCoeff); |
141 GR_STATIC_ASSERT(6 == kSA_GrBlendCoeff); | 140 GR_STATIC_ASSERT(6 == kSA_GrBlendCoeff); |
142 GR_STATIC_ASSERT(7 == kISA_GrBlendCoeff); | 141 GR_STATIC_ASSERT(7 == kISA_GrBlendCoeff); |
143 GR_STATIC_ASSERT(8 == kDA_GrBlendCoeff); | 142 GR_STATIC_ASSERT(8 == kDA_GrBlendCoeff); |
144 GR_STATIC_ASSERT(9 == kIDA_GrBlendCoeff); | 143 GR_STATIC_ASSERT(9 == kIDA_GrBlendCoeff); |
145 GR_STATIC_ASSERT(10 == kConstC_GrBlendCoeff); | 144 GR_STATIC_ASSERT(10 == kConstC_GrBlendCoeff); |
146 GR_STATIC_ASSERT(11 == kIConstC_GrBlendCoeff); | 145 GR_STATIC_ASSERT(11 == kIConstC_GrBlendCoeff); |
147 GR_STATIC_ASSERT(12 == kConstA_GrBlendCoeff); | 146 GR_STATIC_ASSERT(12 == kConstA_GrBlendCoeff); |
148 GR_STATIC_ASSERT(13 == kIConstA_GrBlendCoeff); | 147 GR_STATIC_ASSERT(13 == kIConstA_GrBlendCoeff); |
149 | 148 |
150 GR_STATIC_ASSERT(14 == kS2C_GrBlendCoeff); | 149 GR_STATIC_ASSERT(14 == kS2C_GrBlendCoeff); |
151 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); | 150 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); |
152 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); | 151 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); |
153 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); | 152 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); |
154 | 153 |
155 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope | 154 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope |
156 GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == | 155 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); |
157 SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); | |
158 } | 156 } |
159 | 157 |
160 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
161 | 159 |
162 static bool gPrintStartupSpew; | 160 static bool gPrintStartupSpew; |
163 | 161 |
164 GrGLGpu::GrGLGpu(const GrGLContext& ctx, GrContext* context) | 162 GrGLGpu::GrGLGpu(const GrGLContext& ctx, GrContext* context) |
165 : GrGpu(context) | 163 : GrGpu(context) |
166 , fGLContext(ctx) { | 164 , fGLContext(ctx) { |
167 | 165 |
(...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2112 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2115 fMSAAEnabled = kNo_TriState; | 2113 fMSAAEnabled = kNo_TriState; |
2116 } | 2114 } |
2117 } | 2115 } |
2118 } | 2116 } |
2119 } | 2117 } |
2120 | 2118 |
2121 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { | 2119 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
2122 // Any optimization to disable blending should have already been applied and | 2120 // Any optimization to disable blending should have already been applied and |
2123 // tweaked the equation to "add" or "subtract", and the coeffs to (1, 0). | 2121 // tweaked the equation to "add" or "subtract", and the coeffs to (1, 0). |
2124 | 2122 |
2125 GrBlendEquation equation = blendInfo.fEquation; | 2123 GrBlendEquation equation = blendInfo.fEquation; |
2126 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2124 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
2127 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; | 2125 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
2128 bool blendOff = (kAdd_GrBlendEquation == equation || kSubtract_GrBlendEquati
on == equation) && | 2126 bool blendOff = (kAdd_GrBlendEquation == equation || kSubtract_GrBlendEquati
on == equation) && |
2129 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; | 2127 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; |
2130 if (blendOff) { | 2128 if (blendOff) { |
2131 if (kNo_TriState != fHWBlendState.fEnabled) { | 2129 if (kNo_TriState != fHWBlendState.fEnabled) { |
2132 GL_CALL(Disable(GR_GL_BLEND)); | 2130 GL_CALL(Disable(GR_GL_BLEND)); |
2133 fHWBlendState.fEnabled = kNo_TriState; | 2131 fHWBlendState.fEnabled = kNo_TriState; |
2134 } | 2132 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2851 this->setVertexArrayID(gpu, 0); | 2849 this->setVertexArrayID(gpu, 0); |
2852 } | 2850 } |
2853 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2851 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2854 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2852 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2855 fDefaultVertexArrayAttribState.resize(attrCount); | 2853 fDefaultVertexArrayAttribState.resize(attrCount); |
2856 } | 2854 } |
2857 attribState = &fDefaultVertexArrayAttribState; | 2855 attribState = &fDefaultVertexArrayAttribState; |
2858 } | 2856 } |
2859 return attribState; | 2857 return attribState; |
2860 } | 2858 } |
OLD | NEW |