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

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

Issue 746423007: Draft change to start pulling uniform color into GP (Closed) Base URL: https://skia.googlesource.com/skia.git@no_factories
Patch Set: missed some places to update uniform cache Created 6 years 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 * 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 textureAccess.getParams(), 125 textureAccess.getParams(),
126 static_cast<GrGLTexture*>(textureAccess.getTexture())) ; 126 static_cast<GrGLTexture*>(textureAccess.getTexture())) ;
127 } 127 }
128 } 128 }
129 129
130 130
131 /////////////////////////////////////////////////////////////////////////////// 131 ///////////////////////////////////////////////////////////////////////////////
132 132
133 void GrGLProgram::setData(const GrOptDrawState& optState) { 133 void GrGLProgram::setData(const GrOptDrawState& optState) {
134 GrColor color = optState.getColor(); 134 GrColor color = optState.getColor();
135 uint8_t coverage = optState.getCoverage();
136 135
136 // TODO delete this once the path processor can set color
137 this->setColor(optState, color); 137 this->setColor(optState, color);
138 this->setCoverage(optState, coverage);
139 this->setMatrixAndRenderTargetHeight(optState); 138 this->setMatrixAndRenderTargetHeight(optState);
140 139
141 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy(); 140 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
142 if (dstCopy) { 141 if (dstCopy) {
143 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) { 142 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) {
144 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni, 143 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni,
145 static_cast<GrGLfloat>(dstCopy->offset(). fX), 144 static_cast<GrGLfloat>(dstCopy->offset(). fX),
146 static_cast<GrGLfloat>(dstCopy->offset(). fY)); 145 static_cast<GrGLfloat>(dstCopy->offset(). fY));
147 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni, 146 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni,
148 1.f / dstCopy->texture()->width(), 147 1.f / dstCopy->texture()->width(),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 transforms[t].fCurrentValue = matrix; 202 transforms[t].fCurrentValue = matrix;
204 } 203 }
205 } 204 }
206 } 205 }
207 206
208 void GrGLProgram::didSetData(GrGpu::DrawType drawType) { 207 void GrGLProgram::didSetData(GrGpu::DrawType drawType) {
209 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType)); 208 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
210 } 209 }
211 210
212 void GrGLProgram::setColor(const GrOptDrawState& optState, GrColor color) { 211 void GrGLProgram::setColor(const GrOptDrawState& optState, GrColor color) {
213 const GrProgramDesc::KeyHeader& header = fDesc.header(); 212 const GrGLProgramDescBuilder::GLKeyHeader& header = GrGLProgramDescBuilder:: GetHeader(fDesc);
214 switch (header.fColorInput) { 213 if (header.fUseNvpr) {
215 case GrProgramDesc::kAttribute_ColorInput: 214 if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid()) {
216 // Attribute case is handled in GrGpuGL::setupGeometry 215 // OpenGL ES doesn't support unsigned byte varieties of glUniform
217 break; 216 GrGLfloat c[4];
218 case GrProgramDesc::kUniform_ColorInput: 217 GrColorToRGBAFloat(color, c);
219 if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid()) { 218 fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni, 1, c);
220 // OpenGL ES doesn't support unsigned byte varieties of glUnifor m 219 fColor = color;
221 GrGLfloat c[4]; 220 }
222 GrColorToRGBAFloat(color, c);
223 fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni, 1, c);
224 fColor = color;
225 }
226 break;
227 case GrProgramDesc::kAllOnes_ColorInput:
228 // Handled by shader creation
229 break;
230 default:
231 SkFAIL("Unexpected color type.");
232 } 221 }
233 } 222 }
234 223
235 void GrGLProgram::setCoverage(const GrOptDrawState& optState, uint8_t coverage) {
236 const GrProgramDesc::KeyHeader& header = fDesc.header();
237 switch (header.fCoverageInput) {
238 case GrProgramDesc::kAttribute_ColorInput:
239 // Attribute case is handled in GrGpuGL::setupGeometry
240 break;
241 case GrProgramDesc::kUniform_ColorInput:
242 if (fCoverage != coverage) {
243 // OpenGL ES doesn't support unsigned byte varieties of glUnifor m
244 GrGLfloat c = GrNormalizeByteToFloat(coverage);
245 fProgramDataManager.set1f(fBuiltinUniformHandles.fCoverageUni, c );
246 fCoverage = coverage;
247 }
248 break;
249 case GrProgramDesc::kAllOnes_ColorInput:
250 // Handled by shader creation
251 break;
252 default:
253 SkFAIL("Unexpected coverage type.");
254 }
255 }
256
257 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { 224 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
258 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. 225 // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
259 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && 226 if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
260 fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->he ight()) { 227 fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->he ight()) {
261 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, 228 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
262 SkIntToScalar(optState.getRenderTarget()->hei ght())); 229 SkIntToScalar(optState.getRenderTarget()->hei ght()));
263 } 230 }
264 231
265 // call subclasses to set the actual view matrix 232 // call subclasses to set the actual view matrix
266 this->onSetMatrixAndRenderTargetHeight(optState); 233 this->onSetMatrixAndRenderTargetHeight(optState);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 for (int t = 0; t < numTransforms; ++t) { 357 for (int t = 0; t < numTransforms; ++t) {
391 const SkMatrix& transform = get_transform_matrix(proc, t); 358 const SkMatrix& transform = get_transform_matrix(proc, t);
392 GrGLPathRendering::PathTexGenComponents components = 359 GrGLPathRendering::PathTexGenComponents components =
393 GrGLPathRendering::kST_PathTexGenComponents; 360 GrGLPathRendering::kST_PathTexGenComponents;
394 if (proc.isPerspectiveCoordTransform(t)) { 361 if (proc.isPerspectiveCoordTransform(t)) {
395 components = GrGLPathRendering::kSTR_PathTexGenComponents; 362 components = GrGLPathRendering::kSTR_PathTexGenComponents;
396 } 363 }
397 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform); 364 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
398 } 365 }
399 } 366 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698