| 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 "GrProcessor.h" |
| 10 #include "builders/GrGLFragmentShaderBuilder.h" | 11 #include "builders/GrGLFragmentShaderBuilder.h" |
| 11 #include "builders/GrGLProgramBuilder.h" | 12 #include "builders/GrGLProgramBuilder.h" |
| 12 | 13 |
| 13 void GrGLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman, | 14 void GrGLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman, |
| 14 const GrFragmentProcessor& processor) { | 15 const GrFragmentProcessor& processor) { |
| 15 this->onSetData(pdman, processor); | 16 this->onSetData(pdman, processor); |
| 16 SkASSERT(fChildProcessors.count() == processor.numChildProcessors()); | 17 SkASSERT(fChildProcessors.count() == processor.numChildProcessors()); |
| 17 for (int i = 0; i < fChildProcessors.count(); ++i) { | 18 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 18 fChildProcessors[i]->setData(pdman, processor.childProcessor(i)); | 19 fChildProcessors[i]->setData(pdman, processor.childProcessor(i)); |
| 19 } | 20 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 * subtree has 3 transforms (using B.numTransforms()), so we know the start
of D's transforms is | 73 * subtree has 3 transforms (using B.numTransforms()), so we know the start
of D's transforms is |
| 73 * 4 after the start of A's transforms. | 74 * 4 after the start of A's transforms. |
| 74 * Textures work the same way as transforms. | 75 * Textures work the same way as transforms. |
| 75 */ | 76 */ |
| 76 int firstCoordAt = args.fFp.numTransformsExclChildren(); | 77 int firstCoordAt = args.fFp.numTransformsExclChildren(); |
| 77 int firstSamplerAt = args.fFp.numTexturesExclChildren(); | 78 int firstSamplerAt = args.fFp.numTexturesExclChildren(); |
| 78 for (int i = 0; i < childIndex; ++i) { | 79 for (int i = 0; i < childIndex; ++i) { |
| 79 firstCoordAt += args.fFp.childProcessor(i).numTransforms(); | 80 firstCoordAt += args.fFp.childProcessor(i).numTransforms(); |
| 80 firstSamplerAt += args.fFp.childProcessor(i).numTextures(); | 81 firstSamplerAt += args.fFp.childProcessor(i).numTextures(); |
| 81 } | 82 } |
| 82 TransformedCoordsArray childCoords; | 83 GrGLSLTransformedCoordsArray childCoords; |
| 83 TextureSamplerArray childSamplers; | 84 TextureSamplerArray childSamplers; |
| 84 if (childProc.numTransforms() > 0) { | 85 if (childProc.numTransforms() > 0) { |
| 85 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo
ordAt]); | 86 childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCo
ordAt]); |
| 86 } | 87 } |
| 87 if (childProc.numTextures() > 0) { | 88 if (childProc.numTextures() > 0) { |
| 88 childSamplers.push_back_n(childProc.numTextures(), &args.fSamplers[first
SamplerAt]); | 89 childSamplers.push_back_n(childProc.numTextures(), &args.fSamplers[first
SamplerAt]); |
| 89 } | 90 } |
| 90 | 91 |
| 91 // emit the code for the child in its own scope | 92 // emit the code for the child in its own scope |
| 92 fb->codeAppend("{\n"); | 93 fb->codeAppend("{\n"); |
| 93 fb->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex, | 94 fb->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex, |
| 94 fb->getMangleString().c_str(), childProc.name()); | 95 fb->getMangleString().c_str(), childProc.name()); |
| 95 EmitArgs childArgs(args.fBuilder, | 96 EmitArgs childArgs(args.fBuilder, |
| 96 childProc, | 97 childProc, |
| 97 outputColor, | 98 outputColor, |
| 98 inputColor, | 99 inputColor, |
| 99 childCoords, | 100 childCoords, |
| 100 childSamplers); | 101 childSamplers); |
| 101 this->childProcessor(childIndex)->emitCode(childArgs); | 102 this->childProcessor(childIndex)->emitCode(childArgs); |
| 102 fb->codeAppend("}\n"); | 103 fb->codeAppend("}\n"); |
| 103 | 104 |
| 104 fb->onAfterChildProcEmitCode(); | 105 fb->onAfterChildProcEmitCode(); |
| 105 } | 106 } |
| OLD | NEW |