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

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

Issue 1321253003: emitChild() takes an outputColor instead of generating one (Closed) Base URL: https://skia.googlesource.com/skia@cs3_composeshader2
Patch Set: rebase Created 5 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/gl/GrGLFragmentProcessor.h ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.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 "GrGLFragmentProcessor.h" 8 #include "GrGLFragmentProcessor.h"
9 #include "GrFragmentProcessor.h" 9 #include "GrFragmentProcessor.h"
10 #include "builders/GrGLFragmentShaderBuilder.h" 10 #include "builders/GrGLFragmentShaderBuilder.h"
11 #include "builders/GrGLProgramBuilder.h" 11 #include "builders/GrGLProgramBuilder.h"
12 12
13 void GrGLFragmentProcessor::setData(const GrGLProgramDataManager& pdman, 13 void GrGLFragmentProcessor::setData(const GrGLProgramDataManager& pdman,
14 const GrFragmentProcessor& processor) { 14 const GrFragmentProcessor& processor) {
15 this->onSetData(pdman, processor); 15 this->onSetData(pdman, processor);
16 SkASSERT(fChildProcessors.count() == processor.numChildProcessors()); 16 SkASSERT(fChildProcessors.count() == processor.numChildProcessors());
17 for (int i = 0; i < fChildProcessors.count(); ++i) { 17 for (int i = 0; i < fChildProcessors.count(); ++i) {
18 fChildProcessors[i]->setData(pdman, processor.childProcessor(i)); 18 fChildProcessors[i]->setData(pdman, processor.childProcessor(i));
19 } 19 }
20 } 20 }
21 21
22 void GrGLFragmentProcessor::emitChild(int childIndex, const char* inputColor, 22 void GrGLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
23 SkString* outputColor, EmitArgs& args) { 23 const char* outputColor, EmitArgs& args) {
24 GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder(); 24 GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder();
25 fb->onBeforeChildProcEmitCode(); // call first so mangleString is updated 25 fb->onBeforeChildProcEmitCode(); // call first so mangleString is updated
26 26
27 const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex); 27 const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
28 28
29 // Mangle the name of the outputColor
30 outputColor->set(args.fOutputColor);
31 outputColor->append(fb->getMangleStringThisLevel());
32
33 /* 29 /*
34 * We now want to find the subset of coords and samplers that belong to the child and its 30 * We now want to find the subset of coords and samplers that belong to the child and its
35 * descendants and put that into childCoords and childSamplers. To do so, we 'll do a forwards 31 * descendants and put that into childCoords and childSamplers. To do so, we 'll do a forwards
36 * linear search. 32 * linear search.
37 * 33 *
38 * Explanation: 34 * Explanation:
39 * Each GrFragmentProcessor has a copy of all the transforms and textures of itself and 35 * Each GrFragmentProcessor has a copy of all the transforms and textures of itself and
40 * all procs in its subtree. For example, suppose we have frag proc A, who h as two children B 36 * all procs in its subtree. For example, suppose we have frag proc A, who h as two children B
41 * and D. B has a child C, and D has two children E and F. Each frag proc's transforms array 37 * and D. B has a child C, and D has two children E and F. Each frag proc's transforms array
42 * contains its own transforms, followed by the transforms of all its descen dants (i.e. preorder 38 * contains its own transforms, followed by the transforms of all its descen dants (i.e. preorder
(...skipping 28 matching lines...) Expand all
71 TransformedCoordsArray childCoords; 67 TransformedCoordsArray childCoords;
72 TextureSamplerArray childSamplers; 68 TextureSamplerArray childSamplers;
73 if (childProc.numTransforms() > 0) { 69 if (childProc.numTransforms() > 0) {
74 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo ordAt]); 70 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo ordAt]);
75 } 71 }
76 if (childProc.numTextures() > 0) { 72 if (childProc.numTextures() > 0) {
77 childSamplers.push_back_n(childProc.numTextures(), &args.fSamplers[first SamplerAt]); 73 childSamplers.push_back_n(childProc.numTextures(), &args.fSamplers[first SamplerAt]);
78 } 74 }
79 75
80 // emit the code for the child in its own scope 76 // emit the code for the child in its own scope
81 fb->codeAppendf("vec4 %s;\n", outputColor->c_str());
82 fb->codeAppend("{\n"); 77 fb->codeAppend("{\n");
83 fb->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex, 78 fb->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex,
84 fb->getMangleString().c_str(), childProc.name()); 79 fb->getMangleString().c_str(), childProc.name());
85 EmitArgs childArgs(args.fBuilder, 80 EmitArgs childArgs(args.fBuilder,
86 childProc, 81 childProc,
87 outputColor->c_str(), 82 outputColor,
88 inputColor, 83 inputColor,
89 childCoords, 84 childCoords,
90 childSamplers); 85 childSamplers);
91 this->childProcessor(childIndex)->emitCode(childArgs); 86 this->childProcessor(childIndex)->emitCode(childArgs);
92 fb->codeAppend("}\n"); 87 fb->codeAppend("}\n");
93 88
94 fb->onAfterChildProcEmitCode(); 89 fb->onAfterChildProcEmitCode();
95 } 90 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLFragmentProcessor.h ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698