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

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

Issue 345083002: Stop referencing gl_FragCoord z and w components. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix circle effect Created 6 years, 6 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/effects/GrRRectEffect.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLUniformHandle.h" 10 #include "gl/GrGLUniformHandle.h"
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 SkDEBUGFAIL("GrGLEffect asked for frag position but its generating G rEffect " 492 SkDEBUGFAIL("GrGLEffect asked for frag position but its generating G rEffect "
493 "did not request access."); 493 "did not request access.");
494 return ""; 494 return "";
495 } 495 }
496 } 496 }
497 // We only declare "gl_FragCoord" when we're in the case where we want to us e layout qualifiers 497 // We only declare "gl_FragCoord" when we're in the case where we want to us e layout qualifiers
498 // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the 498 // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the
499 // declaration varies in earlier GLSL specs. So it is simpler to omit it. 499 // declaration varies in earlier GLSL specs. So it is simpler to omit it.
500 if (fTopLeftFragPosRead) { 500 if (fTopLeftFragPosRead) {
501 fSetupFragPosition = true; 501 fSetupFragPosition = true;
502 return "gl_FragCoord"; 502 return "(gl_FragCoord.xy)";
503 } else if (fGpu->glCaps().fragCoordConventionsSupport()) { 503 } else if (fGpu->glCaps().fragCoordConventionsSupport()) {
504 if (!fSetupFragPosition) { 504 if (!fSetupFragPosition) {
505 SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSL PrivateFeature)); 505 SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSL PrivateFeature));
506 fFSInputs.push_back().set(kVec4f_GrSLType, 506 fFSInputs.push_back().set(kVec4f_GrSLType,
507 GrGLShaderVar::kIn_TypeModifier, 507 GrGLShaderVar::kIn_TypeModifier,
508 "gl_FragCoord", 508 "gl_FragCoord",
509 GrGLShaderVar::kDefault_Precision, 509 GrGLShaderVar::kDefault_Precision,
510 GrGLShaderVar::kUpperLeft_Origin); 510 GrGLShaderVar::kUpperLeft_Origin);
511 fSetupFragPosition = true; 511 fSetupFragPosition = true;
512 } 512 }
513 return "gl_FragCoord"; 513 return "(gl_FragCoord.xy)";
514 } else { 514 } else {
515 static const char* kCoordName = "fragCoordYDown"; 515 static const char* kCoordName = "fragCoordYDown";
516 if (!fSetupFragPosition) { 516 if (!fSetupFragPosition) {
517 // temporarily change the stage index because we're inserting non-st age code. 517 // temporarily change the stage index because we're inserting non-st age code.
518 CodeStage::AutoStageRestore csar(&fCodeStage, NULL); 518 CodeStage::AutoStageRestore csar(&fCodeStage, NULL);
519 519
520 SkASSERT(!fOutput.fUniformHandles.fRTHeightUni.isValid()); 520 SkASSERT(!fOutput.fUniformHandles.fRTHeightUni.isValid());
521 const char* rtHeightName; 521 const char* rtHeightName;
522 522
523 fOutput.fUniformHandles.fRTHeightUni = 523 fOutput.fUniformHandles.fRTHeightUni =
524 this->addUniform(kFragment_Visibility, kFloat_GrSLType, "RTHeigh t", &rtHeightName); 524 this->addUniform(kFragment_Visibility, kFloat_GrSLType, "RTHeigh t", &rtHeightName);
525 525
526 this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_Fra gCoord.y, gl_FragCoord.zw);\n", 526 this->fFSCode.prependf("\tvec2 %s = vec2(gl_FragCoord.x, %s - gl_Fra gCoord.y);\n",
527 kCoordName, rtHeightName); 527 kCoordName, rtHeightName);
528 fSetupFragPosition = true; 528 fSetupFragPosition = true;
529 } 529 }
530 SkASSERT(fOutput.fUniformHandles.fRTHeightUni.isValid()); 530 SkASSERT(fOutput.fUniformHandles.fRTHeightUni.isValid());
531 return kCoordName; 531 return kCoordName;
532 } 532 }
533 } 533 }
534 534
535 void GrGLShaderBuilder::fsEmitFunction(GrSLType returnType, 535 void GrGLShaderBuilder::fsEmitFunction(GrSLType returnType,
536 const char* name, 536 const char* name,
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1093
1094 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, 1094 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this,
1095 effectCnt); 1095 effectCnt);
1096 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, 1096 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder,
1097 effectStages, 1097 effectStages,
1098 effectKeys, 1098 effectKeys,
1099 effectCnt, 1099 effectCnt,
1100 inOutFSColor); 1100 inOutFSColor);
1101 return pathTexGenEffectsBuilder.finish(); 1101 return pathTexGenEffectsBuilder.finish();
1102 } 1102 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrRRectEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698