SkSL: Allow invoking children (shaders, etc) like functions
Previously, you would declare child objects (shaders, colorFilters, etc.)
and "sample" them like this:
uniform shader input;
uniform colorFilter filter;
half4 main(float2 coord) {
half4 inColor = sample(input, coord);
return sample(filter, inColor);
}
With the new syntax, those child objects become directly callable,
reflecting the way that Skia assembles all parts of the paint (as functions)
in the overall fragment shader:
uniform shader input;
uniform colorFilter filter;
half4 main(float2 coord) {
half4 inColor = input(coord);
return filter(inColor);
}
Bug: skia:12302
Change-Id: Ia12351964dc5d2300660187933188e738671cd83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436517
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/SkSLDehydrator.cpp b/src/sksl/SkSLDehydrator.cpp
index f99f396..bce5b94 100644
--- a/src/sksl/SkSLDehydrator.cpp
+++ b/src/sksl/SkSLDehydrator.cpp
@@ -277,6 +277,11 @@
this->writeU8(b.value());
break;
}
+
+ case Expression::Kind::kChildCall:
+ SkDEBUGFAIL("unimplemented--not expected to be used from within an include file");
+ break;
+
case Expression::Kind::kCodeString:
SkDEBUGFAIL("shouldn't be able to receive kCodeString here");
break;