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

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

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder Created 5 years, 1 month 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/gl/builders/GrGLProgramBuilder.cpp ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.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 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 "glsl/GrGLSL.h" 10 #include "glsl/GrGLSL.h"
11 #include "glsl/GrGLSLCaps.h" 11 #include "glsl/GrGLSLCaps.h"
12 #include "glsl/GrGLSLProgramBuilder.h" 12 #include "glsl/GrGLSLProgramBuilder.h"
13 #include "glsl/GrGLSLVarying.h"
13 14
14 const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; 15 const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
15 16
16 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { 17 static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
17 SkASSERT(GrBlendEquationIsAdvanced(equation)); 18 SkASSERT(GrBlendEquationIsAdvanced(equation));
18 19
19 static const char* kLayoutQualifierNames[] = { 20 static const char* kLayoutQualifierNames[] = {
20 "blend_support_screen", 21 "blend_support_screen",
21 "blend_support_overlay", 22 "blend_support_overlay",
22 "blend_support_darken", 23 "blend_support_darken",
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor"; 231 return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor";
231 } 232 }
232 233
233 const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const { 234 const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const {
234 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps(); 235 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
235 return caps.mustDeclareFragmentShaderOutput() ? DeclaredSecondaryColorOutput Name() 236 return caps.mustDeclareFragmentShaderOutput() ? DeclaredSecondaryColorOutput Name()
236 : "gl_SecondaryFragColorEXT"; 237 : "gl_SecondaryFragColorEXT";
237 } 238 }
238 239
239 void GrGLSLFragmentShaderBuilder::onFinalize() { 240 void GrGLSLFragmentShaderBuilder::onFinalize() {
241 fProgramBuilder->varyingHandler()->getFragDecls(&this->inputs(), &this->outp uts());
240 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, 242 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
241 *fProgramBuilder->glslCaps(), 243 *fProgramBuilder->glslCaps(),
242 &this->precisionQualifier()); 244 &this->precisionQualifier());
243 } 245 }
244 246
245 void GrGLSLFragmentShaderBuilder::addVarying(GrGLSLVarying* v, GrSLPrecision fsP rec) {
246 v->fFsIn = v->fVsOut;
247 if (v->fGsOut) {
248 v->fFsIn = v->fGsOut;
249 }
250 fInputs.push_back().set(v->fType, GrGLSLShaderVar::kVaryingIn_TypeModifier, v->fFsIn, fsPrec);
251 }
252
253 void GrGLSLFragmentBuilder::onBeforeChildProcEmitCode() { 247 void GrGLSLFragmentBuilder::onBeforeChildProcEmitCode() {
254 SkASSERT(fSubstageIndices.count() >= 1); 248 SkASSERT(fSubstageIndices.count() >= 1);
255 fSubstageIndices.push_back(0); 249 fSubstageIndices.push_back(0);
256 // second-to-last value in the fSubstageIndices stack is the index of the ch ild proc 250 // second-to-last value in the fSubstageIndices stack is the index of the ch ild proc
257 // at that level which is currently emitting code. 251 // at that level which is currently emitting code.
258 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] ); 252 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] );
259 } 253 }
260 254
261 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() { 255 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() {
262 SkASSERT(fSubstageIndices.count() >= 2); 256 SkASSERT(fSubstageIndices.count() >= 2);
263 fSubstageIndices.pop_back(); 257 fSubstageIndices.pop_back();
264 fSubstageIndices.back()++; 258 fSubstageIndices.back()++;
265 int removeAt = fMangleString.findLastOf('_'); 259 int removeAt = fMangleString.findLastOf('_');
266 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 260 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
267 } 261 }
268 262
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698