Honor return value of `registerChildProcessor` when creating child FPs.
The current implementation ignores return value from
`registerChildProcessor` and, surprisingly, assumes that a cloned FP
index will match the original FP index. This version honors the return
value.
(In practice, I have not seen any cases where the current implementation
has caused actual breakage.)
Updating common code-gen had large ripple effects in the SkSL unit
tests. While repairing the tests, I also took the opportunity to use
raw-strings to pass the source SkSL text, and annotated the `expectedH`
and `expectedCPP` blocks to make the tests easier to understand at a
glance.
Change-Id: I71be69d9e4620963b3ef49ad8e0dba3b40af7f4f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295452
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/effects/generated/GrComposeLerpEffect.cpp b/src/gpu/effects/generated/GrComposeLerpEffect.cpp
index 78aabac..7c06231 100644
--- a/src/gpu/effects/generated/GrComposeLerpEffect.cpp
+++ b/src/gpu/effects/generated/GrComposeLerpEffect.cpp
@@ -66,23 +66,20 @@
return true;
}
GrComposeLerpEffect::GrComposeLerpEffect(const GrComposeLerpEffect& src)
- : INHERITED(kGrComposeLerpEffect_ClassID, src.optimizationFlags())
- , child1_index(src.child1_index)
- , child2_index(src.child2_index)
- , weight(src.weight) {
- if (child1_index >= 0) {
- auto clone = src.childProcessor(child1_index).clone();
- if (src.childProcessor(child1_index).isSampledWithExplicitCoords()) {
- clone->setSampledWithExplicitCoords();
+ : INHERITED(kGrComposeLerpEffect_ClassID, src.optimizationFlags()), weight(src.weight) {
+ if (src.child1_index >= 0) {
+ auto child1_clone = src.childProcessor(src.child1_index).clone();
+ if (src.childProcessor(src.child1_index).isSampledWithExplicitCoords()) {
+ child1_clone->setSampledWithExplicitCoords();
}
- this->registerChildProcessor(std::move(clone));
+ child1_index = this->registerChildProcessor(std::move(child1_clone));
}
- if (child2_index >= 0) {
- auto clone = src.childProcessor(child2_index).clone();
- if (src.childProcessor(child2_index).isSampledWithExplicitCoords()) {
- clone->setSampledWithExplicitCoords();
+ if (src.child2_index >= 0) {
+ auto child2_clone = src.childProcessor(src.child2_index).clone();
+ if (src.childProcessor(src.child2_index).isSampledWithExplicitCoords()) {
+ child2_clone->setSampledWithExplicitCoords();
}
- this->registerChildProcessor(std::move(clone));
+ child2_index = this->registerChildProcessor(std::move(child2_clone));
}
}
std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const {