In FPs, store pointers for all child slots, even nullptr
This simplifies things like ConstantOutputForConstantInput and
invokeChild. It also removes the need for child indices: generated
FPs now directly refer to their children by slot number.
Change-Id: I69bbb042d5d72d21b999256f969c467702d0774d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302436
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp
index 3d46c1d..e9ab69d 100644
--- a/src/sksl/SkSLHCodeGenerator.cpp
+++ b/src/sksl/SkSLHCodeGenerator.cpp
@@ -288,8 +288,7 @@
}
std::string usageArg = usage.constructor(std::move(perspExpression));
- this->writef(" %s_index = this->registerChild(std::move(%s), %s);",
- FieldName(String(param->fName).c_str()).c_str(),
+ this->writef(" this->registerChild(std::move(%s), %s);",
String(param->fName).c_str(),
usageArg.c_str());
}
@@ -305,7 +304,7 @@
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
String name = FieldName(String(param->fName).c_str());
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
- this->writef(" int %s_index = -1;\n", name.c_str());
+ // Don't need to write any fields, FPs are held as children
} else {
this->writef(" %s %s;\n", FieldType(fContext, param->fType,
param->fModifiers.fLayout).c_str(),