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

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

Issue 23826002: Rename ShaderType enum to ShaderVisibility (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLEffectMatrix.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 case GrGLProgramDesc::kAttribute_ColorInput: { 224 case GrGLProgramDesc::kAttribute_ColorInput: {
225 builder->addAttribute(kVec4f_GrSLType, COL_ATTR_NAME); 225 builder->addAttribute(kVec4f_GrSLType, COL_ATTR_NAME);
226 const char *vsName, *fsName; 226 const char *vsName, *fsName;
227 builder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName); 227 builder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName);
228 builder->vsCodeAppendf("\t%s = " COL_ATTR_NAME ";\n", vsName); 228 builder->vsCodeAppendf("\t%s = " COL_ATTR_NAME ";\n", vsName);
229 *inColor = fsName; 229 *inColor = fsName;
230 return kNone_GrSLConstantVec; 230 return kNone_GrSLConstantVec;
231 } 231 }
232 case GrGLProgramDesc::kUniform_ColorInput: { 232 case GrGLProgramDesc::kUniform_ColorInput: {
233 const char* name; 233 const char* name;
234 fUniformHandles.fColorUni = builder->addUniform(GrGLShaderBuilder::k Fragment_ShaderType, 234 fUniformHandles.fColorUni = builder->addUniform(GrGLShaderBuilder::k Fragment_Visibility,
235 kVec4f_GrSLType, "Co lor", &name); 235 kVec4f_GrSLType, "Co lor", &name);
236 *inColor = name; 236 *inColor = name;
237 return kNone_GrSLConstantVec; 237 return kNone_GrSLConstantVec;
238 } 238 }
239 case GrGLProgramDesc::kTransBlack_ColorInput: 239 case GrGLProgramDesc::kTransBlack_ColorInput:
240 inColor->reset(); 240 inColor->reset();
241 return kZeros_GrSLConstantVec; 241 return kZeros_GrSLConstantVec;
242 case GrGLProgramDesc::kSolidWhite_ColorInput: 242 case GrGLProgramDesc::kSolidWhite_ColorInput:
243 inColor->reset(); 243 inColor->reset();
244 return kOnes_GrSLConstantVec; 244 return kOnes_GrSLConstantVec;
245 default: 245 default:
246 GrCrash("Unknown color type."); 246 GrCrash("Unknown color type.");
247 return kNone_GrSLConstantVec; 247 return kNone_GrSLConstantVec;
248 } 248 }
249 } 249 }
250 250
251 GrSLConstantVec GrGLProgram::genInputCoverage(GrGLShaderBuilder* builder, SkStri ng* inCoverage) { 251 GrSLConstantVec GrGLProgram::genInputCoverage(GrGLShaderBuilder* builder, SkStri ng* inCoverage) {
252 switch (fDesc.getHeader().fCoverageInput) { 252 switch (fDesc.getHeader().fCoverageInput) {
253 case GrGLProgramDesc::kAttribute_ColorInput: { 253 case GrGLProgramDesc::kAttribute_ColorInput: {
254 builder->addAttribute(kVec4f_GrSLType, COV_ATTR_NAME); 254 builder->addAttribute(kVec4f_GrSLType, COV_ATTR_NAME);
255 const char *vsName, *fsName; 255 const char *vsName, *fsName;
256 builder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &fsName); 256 builder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &fsName);
257 builder->vsCodeAppendf("\t%s = " COV_ATTR_NAME ";\n", vsName); 257 builder->vsCodeAppendf("\t%s = " COV_ATTR_NAME ";\n", vsName);
258 *inCoverage = fsName; 258 *inCoverage = fsName;
259 return kNone_GrSLConstantVec; 259 return kNone_GrSLConstantVec;
260 } 260 }
261 case GrGLProgramDesc::kUniform_ColorInput: { 261 case GrGLProgramDesc::kUniform_ColorInput: {
262 const char* name; 262 const char* name;
263 fUniformHandles.fCoverageUni = 263 fUniformHandles.fCoverageUni =
264 builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, 264 builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
265 kVec4f_GrSLType, "Coverage", &name); 265 kVec4f_GrSLType, "Coverage", &name);
266 *inCoverage = name; 266 *inCoverage = name;
267 return kNone_GrSLConstantVec; 267 return kNone_GrSLConstantVec;
268 } 268 }
269 case GrGLProgramDesc::kTransBlack_ColorInput: 269 case GrGLProgramDesc::kTransBlack_ColorInput:
270 inCoverage->reset(); 270 inCoverage->reset();
271 return kZeros_GrSLConstantVec; 271 return kZeros_GrSLConstantVec;
272 case GrGLProgramDesc::kSolidWhite_ColorInput: 272 case GrGLProgramDesc::kSolidWhite_ColorInput:
273 inCoverage->reset(); 273 inCoverage->reset();
274 return kOnes_GrSLConstantVec; 274 return kOnes_GrSLConstantVec;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 392 }
393 } 393 }
394 394
395 } 395 }
396 396
397 // compiles all the shaders from builder and stores the shader IDs 397 // compiles all the shaders from builder and stores the shader IDs
398 bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { 398 bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
399 399
400 SkString shader; 400 SkString shader;
401 401
402 builder.getShader(GrGLShaderBuilder::kVertex_ShaderType, &shader); 402 builder.vsGetShader(&shader);
403 if (c_PrintShaders) { 403 if (c_PrintShaders) {
404 GrPrintf(shader.c_str()); 404 GrPrintf(shader.c_str());
405 GrPrintf("\n"); 405 GrPrintf("\n");
406 } 406 }
407 407
408 if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader))) { 408 if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader))) {
409 return false; 409 return false;
410 } 410 }
411 411
412 fGShaderID = 0; 412 fGShaderID = 0;
413 #if GR_GL_EXPERIMENTAL_GS 413 #if GR_GL_EXPERIMENTAL_GS
414 if (fDesc.getHeader().fExperimentalGS) { 414 if (fDesc.getHeader().fExperimentalGS) {
415 builder.getShader(GrGLShaderBuilder::kGeometry_ShaderType, &shader); 415 builder.gsGetShader(&shader);
416 if (c_PrintShaders) { 416 if (c_PrintShaders) {
417 GrPrintf(shader.c_str()); 417 GrPrintf(shader.c_str());
418 GrPrintf("\n"); 418 GrPrintf("\n");
419 } 419 }
420 if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, shade r))) { 420 if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, shade r))) {
421 return false; 421 return false;
422 } 422 }
423 } 423 }
424 #endif 424 #endif
425 425
426 builder.getShader(GrGLShaderBuilder::kFragment_ShaderType, &shader); 426 builder.fsGetShader(&shader);
427 if (c_PrintShaders) { 427 if (c_PrintShaders) {
428 GrPrintf(shader.c_str()); 428 GrPrintf(shader.c_str());
429 GrPrintf("\n"); 429 GrPrintf("\n");
430 } 430 }
431 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) { 431 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) {
432 return false; 432 return false;
433 } 433 }
434 434
435 return true; 435 return true;
436 } 436 }
(...skipping 12 matching lines...) Expand all
449 449
450 GrGLShaderVar colorOutput; 450 GrGLShaderVar colorOutput;
451 bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneratio n(), 451 bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneratio n(),
452 declared_color_output_name(), 452 declared_color_output_name(),
453 &colorOutput); 453 &colorOutput);
454 if (isColorDeclared) { 454 if (isColorDeclared) {
455 builder.fFSOutputs.push_back(colorOutput); 455 builder.fFSOutputs.push_back(colorOutput);
456 } 456 }
457 457
458 const char* viewMName; 458 const char* viewMName;
459 fUniformHandles.fViewMatrixUni = builder.addUniform(GrGLShaderBuilder::kVert ex_ShaderType, 459 fUniformHandles.fViewMatrixUni = builder.addUniform(GrGLShaderBuilder::kVert ex_Visibility,
460 kMat33f_GrSLType, "ViewM ", &viewMName); 460 kMat33f_GrSLType, "ViewM ", &viewMName);
461 461
462 462
463 builder.vsCodeAppendf("\tvec3 pos3 = %s * vec3(%s, 1);\n" 463 builder.vsCodeAppendf("\tvec3 pos3 = %s * vec3(%s, 1);\n"
464 "\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n", 464 "\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n",
465 viewMName, builder.positionAttribute().getName().c_str ()); 465 viewMName, builder.positionAttribute().getName().c_str ());
466 466
467 // incoming color to current stage being processed. 467 // incoming color to current stage being processed.
468 SkString inColor; 468 SkString inColor;
469 GrSLConstantVec knownColorValue = this->genInputColor(&builder, &inColor); 469 GrSLConstantVec knownColorValue = this->genInputColor(&builder, &inColor);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 glEffects.get()); 507 glEffects.get());
508 508
509 for (int e = 0; e < fDesc.numColorEffects(); ++e) { 509 for (int e = 0; e < fDesc.numColorEffects(); ++e) {
510 fColorEffects[e].fGLEffect = glEffects[e]; 510 fColorEffects[e].fGLEffect = glEffects[e];
511 } 511 }
512 } 512 }
513 513
514 // Insert the color filter. This will soon be replaced by a color effect. 514 // Insert the color filter. This will soon be replaced by a color effect.
515 if (SkXfermode::kDst_Mode != header.fColorFilterXfermode) { 515 if (SkXfermode::kDst_Mode != header.fColorFilterXfermode) {
516 const char* colorFilterColorUniName = NULL; 516 const char* colorFilterColorUniName = NULL;
517 fUniformHandles.fColorFilterUni = builder.addUniform(GrGLShaderBuilder:: kFragment_ShaderType, 517 fUniformHandles.fColorFilterUni = builder.addUniform(GrGLShaderBuilder:: kFragment_Visibility,
518 kVec4f_GrSLType, "F ilterColor", 518 kVec4f_GrSLType, "F ilterColor",
519 &colorFilterColorUn iName); 519 &colorFilterColorUn iName);
520 520
521 builder.fsCodeAppend("\tvec4 filteredColor;\n"); 521 builder.fsCodeAppend("\tvec4 filteredColor;\n");
522 const char* color; 522 const char* color;
523 // add_color_filter requires a real input string. 523 // add_color_filter requires a real input string.
524 if (knownColorValue == kOnes_GrSLConstantVec) { 524 if (knownColorValue == kOnes_GrSLConstantVec) {
525 color = GrGLSLOnesVecf(4); 525 color = GrGLSLOnesVecf(4);
526 } else if (knownColorValue == kZeros_GrSLConstantVec) { 526 } else if (knownColorValue == kZeros_GrSLConstantVec) {
527 color = GrGLSLZerosVecf(4); 527 color = GrGLSLZerosVecf(4);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 SkScalarToFloat(m[SkMatrix::kMTransX]), 992 SkScalarToFloat(m[SkMatrix::kMTransX]),
993 SkScalarToFloat(m[SkMatrix::kMTransY]), 993 SkScalarToFloat(m[SkMatrix::kMTransY]),
994 SkScalarToFloat(m[SkMatrix::kMPersp2]) 994 SkScalarToFloat(m[SkMatrix::kMPersp2])
995 }; 995 };
996 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); 996 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt);
997 fMatrixState.fViewMatrix = drawState.getViewMatrix(); 997 fMatrixState.fViewMatrix = drawState.getViewMatrix();
998 fMatrixState.fRenderTargetSize = size; 998 fMatrixState.fRenderTargetSize = size;
999 fMatrixState.fRenderTargetOrigin = rt->origin(); 999 fMatrixState.fRenderTargetOrigin = rt->origin();
1000 } 1000 }
1001 } 1001 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLEffectMatrix.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698