| 158 | } |
| 159 | |
| 160 | void FragmentProcessor::internalEmitChild( |
| 161 | size_t childIndex, const std::string& inputColor, const std::string& outputColor, |
| 162 | EmitArgs& args, std::function<std::string(std::string_view)> coordFunc) const { |
| 163 | auto fragBuilder = args.fragBuilder; |
| 164 | const auto childProc = childProcessor(childIndex); |
| 165 | fragBuilder->onBeforeChildProcEmitCode(childProc); // call first so mangleString is updated |
| 166 | auto programInfo = fragBuilder->getProgramInfo(); |
| 167 | // Prepare a mangled input color variable if the default is not used, |
| 168 | // inputName remains the empty string if no variable is needed. |
| 169 | std::string inputName; |
| 170 | if (!inputColor.empty() && inputColor != "vec4(1.0)") { |
| 171 | // The input name is based off of the current mangle string, and |
| 172 | // since this is called after onBeforeChildProcEmitCode(), it will be |
| 173 | // unique to the child processor (exactly what we want for its input). |
| 174 | inputName += "_childInput"; |
| 175 | inputName += programInfo->getMangledSuffix(childProc); |
| 176 | fragBuilder->codeAppendf("vec4 %s = %s;", inputName.c_str(), inputColor.c_str()); |
| 177 | } |
| 178 | |
| 179 | // emit the code for the child in its own scope |
| 180 | fragBuilder->codeAppend("{\n"); |
| 181 | fragBuilder->codeAppendf("// Processor%d : %s\n", programInfo->getProcessorIndex(childProc), |
| 182 | childProc->name().c_str()); |
| 183 | TransformedCoordVars coordVars = args.transformedCoords->childInputs(childIndex); |
| 184 | TextureSamplers textureSamplers = args.textureSamplers->childInputs(childIndex); |
| 185 | |
| 186 | EmitArgs childArgs(fragBuilder, args.uniformHandler, outputColor, |
| 187 | inputName.empty() ? "vec4(1.0)" : inputName, args.inputSubset, &coordVars, |
| 188 | &textureSamplers, std::move(coordFunc)); |
| 189 | childProcessor(childIndex)->emitCode(childArgs); |
| 190 | fragBuilder->codeAppend("}\n"); |
| 191 | |
| 192 | fragBuilder->onAfterChildProcEmitCode(); |
| 193 | } |
| 194 | |
| 195 | template <typename T, size_t (FragmentProcessor::*COUNT)() const> |
| 196 | FragmentProcessor::BuilderInputProvider<T, COUNT> |
nothing calls this directly
no test coverage detected