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/GrDeviceSpaceEffect.cpp b/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
index cf0032d..3832502 100644
--- a/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
+++ b/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
@@ -57,15 +57,13 @@
return true;
}
GrDeviceSpaceEffect::GrDeviceSpaceEffect(const GrDeviceSpaceEffect& src)
- : INHERITED(kGrDeviceSpaceEffect_ClassID, src.optimizationFlags())
- , fp_index(src.fp_index)
- , matrix(src.matrix) {
+ : INHERITED(kGrDeviceSpaceEffect_ClassID, src.optimizationFlags()), matrix(src.matrix) {
{
- auto clone = src.childProcessor(fp_index).clone();
- if (src.childProcessor(fp_index).isSampledWithExplicitCoords()) {
- clone->setSampledWithExplicitCoords();
+ auto fp_clone = src.childProcessor(src.fp_index).clone();
+ if (src.childProcessor(src.fp_index).isSampledWithExplicitCoords()) {
+ fp_clone->setSampledWithExplicitCoords();
}
- this->registerChildProcessor(std::move(clone));
+ fp_index = this->registerChildProcessor(std::move(fp_clone));
}
}
std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceEffect::clone() const {