Separate SkVM's SampleChild into two callbacks.
Previously, one callback was used and the caller needed to infer from
the passed-in index what type of effect to invoke, and which arguments
were valid.
Now, each type of effect has a separate callback with a unique
signature. (In particular, SkColorFilters lack coordinates entirely.)
In a later CL, SkBlenders will also be supported, and those will have
a different signature again, as they take two colors and no coords.
Change-Id: Ibcb39c91c35256c5339e4d2790ed0c36e434f191
Bug: skia:12257
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431656
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/codegen/SkSLVMCodeGenerator.h b/src/sksl/codegen/SkSLVMCodeGenerator.h
index 76a63df..9017e6b 100644
--- a/src/sksl/codegen/SkSLVMCodeGenerator.h
+++ b/src/sksl/codegen/SkSLVMCodeGenerator.h
@@ -20,7 +20,8 @@
class FunctionDefinition;
struct Program;
-using SampleChildFn = std::function<skvm::Color(int, skvm::Coord, skvm::Color)>;
+using SampleShaderFn = std::function<skvm::Color(int, skvm::Coord, skvm::Color)>;
+using SampleColorFilterFn = std::function<skvm::Color(int, skvm::Color)>;
// Convert 'function' to skvm instructions in 'builder', for use by blends, shaders, & color filters
skvm::Color ProgramToSkVM(const Program& program,
@@ -31,7 +32,8 @@
skvm::Coord local,
skvm::Color inputColor,
skvm::Color destColor,
- SampleChildFn sampleChild);
+ SampleShaderFn sampleShader,
+ SampleColorFilterFn sampleColorFilter);
struct SkVMSignature {
size_t fParameterSlots = 0;