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

Side by Side Diff: src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp

Issue 2324663004: Remove unneeded GrGLSLTransformedCoordsArray type (Closed)
Patch Set: update comments Created 4 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
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 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 "GrGLSLFragmentShaderBuilder.h" 8 #include "GrGLSLFragmentShaderBuilder.h"
9 #include "GrRenderTarget.h" 9 #include "GrRenderTarget.h"
10 #include "GrRenderTargetPriv.h" 10 #include "GrRenderTargetPriv.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (const char* extension = glslCaps.multisampleInterpolationExtensi onString()) { 118 if (const char* extension = glslCaps.multisampleInterpolationExtensi onString()) {
119 this->addFeature(1 << kMultisampleInterpolation_GLSLFeature, ext ension); 119 this->addFeature(1 << kMultisampleInterpolation_GLSLFeature, ext ension);
120 } 120 }
121 return true; 121 return true;
122 default: 122 default:
123 SkFAIL("Unexpected GLSLFeature requested."); 123 SkFAIL("Unexpected GLSLFeature requested.");
124 return false; 124 return false;
125 } 125 }
126 } 126 }
127 127
128 SkString GrGLSLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCo ordsArray& coords, 128 SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords) {
129 int index) { 129 if (kVec3f_GrSLType != coords.getType()) {
130 if (kVec3f_GrSLType != coords[index].getType()) { 130 SkASSERT(kVec2f_GrSLType == coords.getType());
131 SkASSERT(kVec2f_GrSLType == coords[index].getType()); 131 return coords.getName();
132 return coords[index].getName();
133 } 132 }
134 133
135 SkString coords2D("coords2D"); 134 SkString coords2D;
136 if (0 != index) { 135 coords2D.printf("%s_ensure2D", coords.c_str());
137 coords2D.appendf("_%i", index); 136 this->codeAppendf("\tvec2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_st r(),
138 } 137 coords.c_str());
139 this->codeAppendf("\tvec2 %s = %s.xy / %s.z;",
140 coords2D.c_str(), coords[index].c_str(), coords[index].c_s tr());
141 return coords2D; 138 return coords2D;
142 } 139 }
143 140
144 const char* GrGLSLFragmentShaderBuilder::fragmentPosition() { 141 const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
145 SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kFragmentPosition_Require dFeature;) 142 SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kFragmentPosition_Require dFeature;)
146 143
147 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); 144 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
148 // We only declare "gl_FragCoord" when we're in the case where we want to us e layout qualifiers 145 // We only declare "gl_FragCoord" when we're in the case where we want to us e layout qualifiers
149 // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the 146 // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the
150 // declaration varies in earlier GLSL specs. So it is simpler to omit it. 147 // declaration varies in earlier GLSL specs. So it is simpler to omit it.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] ); 388 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] );
392 } 389 }
393 390
394 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { 391 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() {
395 SkASSERT(fSubstageIndices.count() >= 2); 392 SkASSERT(fSubstageIndices.count() >= 2);
396 fSubstageIndices.pop_back(); 393 fSubstageIndices.pop_back();
397 fSubstageIndices.back()++; 394 fSubstageIndices.back()++;
398 int removeAt = fMangleString.findLastOf('_'); 395 int removeAt = fMangleString.findLastOf('_');
399 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 396 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
400 } 397 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698