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

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 375823005: Remove gpu shader optimatization for solid white or trans black colors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Change ignore function name Created 6 years, 5 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
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // settings in that case. 147 // settings in that case.
148 if (!fBuilderOutput.fHasVertexShader) { 148 if (!fBuilderOutput.fHasVertexShader) {
149 fGpu->flushPathTexGenSettings(fBuilderOutput.fTexCoordSetCnt); 149 fGpu->flushPathTexGenSettings(fBuilderOutput.fTexCoordSetCnt);
150 } 150 }
151 } 151 }
152 152
153 void GrGLProgram::setColor(const GrDrawState& drawState, 153 void GrGLProgram::setColor(const GrDrawState& drawState,
154 GrColor color, 154 GrColor color,
155 SharedGLState* sharedState) { 155 SharedGLState* sharedState) {
156 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); 156 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
157 if (!drawState.hasColorVertexAttribute()) { 157 if (!drawState.hasColorVertexAttribute() || drawState.canIgnoreColorAttribut e()) {
158 switch (header.fColorInput) { 158 switch (header.fColorInput) {
159 case GrGLProgramDesc::kAttribute_ColorInput: 159 case GrGLProgramDesc::kAttribute_ColorInput:
160 SkASSERT(-1 != header.fColorAttributeIndex); 160 SkASSERT(-1 != header.fColorAttributeIndex);
161 if (sharedState->fConstAttribColor != color || 161 if (sharedState->fConstAttribColor != color ||
162 sharedState->fConstAttribColorIndex != header.fColorAttribut eIndex) { 162 sharedState->fConstAttribColorIndex != header.fColorAttribut eIndex) {
163 // OpenGL ES only supports the float varieties of glVertexAt trib 163 // OpenGL ES only supports the float varieties of glVertexAt trib
164 GrGLfloat c[4]; 164 GrGLfloat c[4];
165 GrColorToRGBAFloat(color, c); 165 GrColorToRGBAFloat(color, c);
166 GL_CALL(VertexAttrib4fv(header.fColorAttributeIndex, c)); 166 GL_CALL(VertexAttrib4fv(header.fColorAttributeIndex, c));
167 sharedState->fConstAttribColor = color; 167 sharedState->fConstAttribColor = color;
168 sharedState->fConstAttribColorIndex = header.fColorAttribute Index; 168 sharedState->fConstAttribColorIndex = header.fColorAttribute Index;
169 } 169 }
170 break; 170 break;
171 case GrGLProgramDesc::kUniform_ColorInput: 171 case GrGLProgramDesc::kUniform_ColorInput:
172 if (fColor != color && fBuilderOutput.fUniformHandles.fColorUni. isValid()) { 172 if (fColor != color && fBuilderOutput.fUniformHandles.fColorUni. isValid()) {
173 // OpenGL ES doesn't support unsigned byte varieties of glUn iform 173 // OpenGL ES doesn't support unsigned byte varieties of glUn iform
174 GrGLfloat c[4]; 174 GrGLfloat c[4];
175 GrColorToRGBAFloat(color, c); 175 GrColorToRGBAFloat(color, c);
176 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fColo rUni, 1, c); 176 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fColo rUni, 1, c);
177 fColor = color; 177 fColor = color;
178 } 178 }
179 sharedState->fConstAttribColorIndex = -1; 179 sharedState->fConstAttribColorIndex = -1;
180 break; 180 break;
181 case GrGLProgramDesc::kSolidWhite_ColorInput:
182 case GrGLProgramDesc::kTransBlack_ColorInput:
183 sharedState->fConstAttribColorIndex = -1;
184 break;
185 default: 181 default:
186 SkFAIL("Unknown color type."); 182 SkFAIL("Unexpected color type.");
187 } 183 }
188 } else { 184 } else {
189 sharedState->fConstAttribColorIndex = -1; 185 sharedState->fConstAttribColorIndex = -1;
190 } 186 }
191 } 187 }
192 188
193 void GrGLProgram::setCoverage(const GrDrawState& drawState, 189 void GrGLProgram::setCoverage(const GrDrawState& drawState,
194 GrColor coverage, 190 GrColor coverage,
195 SharedGLState* sharedState) { 191 SharedGLState* sharedState) {
196 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); 192 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
(...skipping 14 matching lines...) Expand all
211 if (fCoverage != coverage) { 207 if (fCoverage != coverage) {
212 // OpenGL ES doesn't support unsigned byte varieties of glUn iform 208 // OpenGL ES doesn't support unsigned byte varieties of glUn iform
213 GrGLfloat c[4]; 209 GrGLfloat c[4];
214 GrColorToRGBAFloat(coverage, c); 210 GrColorToRGBAFloat(coverage, c);
215 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fCove rageUni, 1, c); 211 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fCove rageUni, 1, c);
216 fCoverage = coverage; 212 fCoverage = coverage;
217 } 213 }
218 sharedState->fConstAttribCoverageIndex = -1; 214 sharedState->fConstAttribCoverageIndex = -1;
219 break; 215 break;
220 case GrGLProgramDesc::kSolidWhite_ColorInput: 216 case GrGLProgramDesc::kSolidWhite_ColorInput:
221 case GrGLProgramDesc::kTransBlack_ColorInput:
222 sharedState->fConstAttribCoverageIndex = -1; 217 sharedState->fConstAttribCoverageIndex = -1;
223 break; 218 break;
224 default: 219 default:
225 SkFAIL("Unknown coverage type."); 220 SkFAIL("Unexpected coverage type.");
226 } 221 }
227 } else { 222 } else {
228 sharedState->fConstAttribCoverageIndex = -1; 223 sharedState->fConstAttribCoverageIndex = -1;
229 } 224 }
230 } 225 }
231 226
232 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrDrawState& drawState) { 227 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrDrawState& drawState) {
233 const GrRenderTarget* rt = drawState.getRenderTarget(); 228 const GrRenderTarget* rt = drawState.getRenderTarget();
234 SkISize size; 229 SkISize size;
235 size.set(rt->width(), rt->height()); 230 size.set(rt->width(), rt->height());
(...skipping 20 matching lines...) Expand all
256 251
257 GrGLfloat viewMatrix[3 * 3]; 252 GrGLfloat viewMatrix[3 * 3];
258 fMatrixState.getGLMatrix<3>(viewMatrix); 253 fMatrixState.getGLMatrix<3>(viewMatrix);
259 fUniformManager->setMatrix3f(fBuilderOutput.fUniformHandles.fViewMatrixU ni, viewMatrix); 254 fUniformManager->setMatrix3f(fBuilderOutput.fUniformHandles.fViewMatrixU ni, viewMatrix);
260 255
261 GrGLfloat rtAdjustmentVec[4]; 256 GrGLfloat rtAdjustmentVec[4];
262 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); 257 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec);
263 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); 258 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
264 } 259 }
265 } 260 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698