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

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

Issue 1457543003: Add ShaderBuilders to EmitArgs and remove gettings from ProgBuilder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/glsl/GrGLSLFragmentProcessor.h ('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 2015 Google Inc. 2 * Copyright 2015 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 "GrGLSLFragmentProcessor.h" 8 #include "GrGLSLFragmentProcessor.h"
9 #include "GrFragmentProcessor.h" 9 #include "GrFragmentProcessor.h"
10 #include "GrProcessor.h" 10 #include "GrProcessor.h"
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" 11 #include "glsl/GrGLSLFragmentShaderBuilder.h"
12 #include "glsl/GrGLSLProgramBuilder.h" 12 #include "glsl/GrGLSLProgramBuilder.h"
13 13
14 void GrGLSLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman, 14 void GrGLSLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman,
15 const GrFragmentProcessor& processor) { 15 const GrFragmentProcessor& processor) {
16 this->onSetData(pdman, processor); 16 this->onSetData(pdman, processor);
17 SkASSERT(fChildProcessors.count() == processor.numChildProcessors()); 17 SkASSERT(fChildProcessors.count() == processor.numChildProcessors());
18 for (int i = 0; i < fChildProcessors.count(); ++i) { 18 for (int i = 0; i < fChildProcessors.count(); ++i) {
19 fChildProcessors[i]->setData(pdman, processor.childProcessor(i)); 19 fChildProcessors[i]->setData(pdman, processor.childProcessor(i));
20 } 20 }
21 } 21 }
22 22
23 void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor, EmitArgs& args) { 23 void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor, EmitArgs& args) {
24 this->internalEmitChild(childIndex, inputColor, args.fOutputColor, args); 24 this->internalEmitChild(childIndex, inputColor, args.fOutputColor, args);
25 } 25 }
26 26
27 void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor, 27 void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
28 SkString* outputColor, EmitArgs& args) { 28 SkString* outputColor, EmitArgs& args) {
29 29
30 SkASSERT(outputColor); 30 SkASSERT(outputColor);
31 GrGLSLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder(); 31 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
32 outputColor->append(fb->getMangleString()); 32 outputColor->append(fragBuilder->getMangleString());
33 fb->codeAppendf("vec4 %s;", outputColor->c_str()); 33 fragBuilder->codeAppendf("vec4 %s;", outputColor->c_str());
34 this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args); 34 this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args);
35 } 35 }
36 36
37 void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu tColor, 37 void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu tColor,
38 const char* outputColor, EmitArg s& args) { 38 const char* outputColor, EmitArg s& args) {
39 GrGLSLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder(); 39 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
40 40
41 fb->onBeforeChildProcEmitCode(); // call first so mangleString is updated 41 fragBuilder->onBeforeChildProcEmitCode(); // call first so mangleString is updated
42 42
43 const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex); 43 const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
44 44
45 /* 45 /*
46 * We now want to find the subset of coords and samplers that belong to the child and its 46 * We now want to find the subset of coords and samplers that belong to the child and its
47 * descendants and put that into childCoords and childSamplers. To do so, we 'll do a forwards 47 * descendants and put that into childCoords and childSamplers. To do so, we 'll do a forwards
48 * linear search. 48 * linear search.
49 * 49 *
50 * Explanation: 50 * Explanation:
51 * Each GrFragmentProcessor has a copy of all the transforms and textures of itself and 51 * Each GrFragmentProcessor has a copy of all the transforms and textures of itself and
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 GrGLSLTransformedCoordsArray childCoords; 83 GrGLSLTransformedCoordsArray childCoords;
84 TextureSamplerArray childSamplers; 84 TextureSamplerArray childSamplers;
85 if (childProc.numTransforms() > 0) { 85 if (childProc.numTransforms() > 0) {
86 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo ordAt]); 86 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo ordAt]);
87 } 87 }
88 if (childProc.numTextures() > 0) { 88 if (childProc.numTextures() > 0) {
89 childSamplers.push_back_n(childProc.numTextures(), &args.fSamplers[first SamplerAt]); 89 childSamplers.push_back_n(childProc.numTextures(), &args.fSamplers[first SamplerAt]);
90 } 90 }
91 91
92 // emit the code for the child in its own scope 92 // emit the code for the child in its own scope
93 fb->codeAppend("{\n"); 93 fragBuilder->codeAppend("{\n");
94 fb->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex, 94 fragBuilder->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex,
95 fb->getMangleString().c_str(), childProc.name()); 95 fragBuilder->getMangleString().c_str(), childProc.n ame());
96 EmitArgs childArgs(args.fBuilder, 96 EmitArgs childArgs(args.fBuilder,
97 fragBuilder,
97 childProc, 98 childProc,
98 outputColor, 99 outputColor,
99 inputColor, 100 inputColor,
100 childCoords, 101 childCoords,
101 childSamplers); 102 childSamplers);
102 this->childProcessor(childIndex)->emitCode(childArgs); 103 this->childProcessor(childIndex)->emitCode(childArgs);
103 fb->codeAppend("}\n"); 104 fragBuilder->codeAppend("}\n");
104 105
105 fb->onAfterChildProcEmitCode(); 106 fragBuilder->onAfterChildProcEmitCode();
106 } 107 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698