| OLD | NEW |
| 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, Em
itArgs& args) { |
| 23 this->internalEmitChild(childIndex, inputColor, args.fOutputColor, args); |
| 24 } |
| 25 |
| 22 void GrGLFragmentProcessor::emitChild(int childIndex, const char* inputColor, | 26 void GrGLFragmentProcessor::emitChild(int childIndex, const char* inputColor, |
| 23 const char* outputColor, EmitArgs& args) { | 27 SkString* outputColor, EmitArgs& args) { |
| 28 |
| 29 SkASSERT(outputColor); |
| 24 GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder(); | 30 GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder(); |
| 31 outputColor->append(fb->getMangleString()); |
| 32 fb->codeAppendf("vec4 %s;", outputColor->c_str()); |
| 33 this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args); |
| 34 } |
| 35 |
| 36 void GrGLFragmentProcessor::internalEmitChild(int childIndex, const char* inputC
olor, |
| 37 const char* outputColor, EmitArgs
& args) { |
| 38 GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder(); |
| 39 |
| 25 fb->onBeforeChildProcEmitCode(); // call first so mangleString is updated | 40 fb->onBeforeChildProcEmitCode(); // call first so mangleString is updated |
| 26 | 41 |
| 27 const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex); | 42 const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex); |
| 28 | 43 |
| 29 /* | 44 /* |
| 30 * We now want to find the subset of coords and samplers that belong to the
child and its | 45 * We now want to find the subset of coords and samplers that belong to the
child and its |
| 31 * descendants and put that into childCoords and childSamplers. To do so, we
'll do a forwards | 46 * descendants and put that into childCoords and childSamplers. To do so, we
'll do a forwards |
| 32 * linear search. | 47 * linear search. |
| 33 * | 48 * |
| 34 * Explanation: | 49 * Explanation: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 childProc, | 96 childProc, |
| 82 outputColor, | 97 outputColor, |
| 83 inputColor, | 98 inputColor, |
| 84 childCoords, | 99 childCoords, |
| 85 childSamplers); | 100 childSamplers); |
| 86 this->childProcessor(childIndex)->emitCode(childArgs); | 101 this->childProcessor(childIndex)->emitCode(childArgs); |
| 87 fb->codeAppend("}\n"); | 102 fb->codeAppend("}\n"); |
| 88 | 103 |
| 89 fb->onAfterChildProcEmitCode(); | 104 fb->onAfterChildProcEmitCode(); |
| 90 } | 105 } |
| OLD | NEW |