Use SkRuntimeEffect::MakeForShader in CanvasKit

The old factory is deprecated. The new factory does stricter checking on
the signature of main and calls to sample - verifying that the SkSL is
valid as an SkShader (vs SkColorFilter) at effect creation time.

Bug: skia:11813
Change-Id: I8d70f81b5c3fa78b05add1b591caf1d26dd70402
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399077
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2021-04-21 11:30:11 -04:00 committed by Skia Commit-Bot
parent 374f96c9de
commit e37660b43c
2 changed files with 9 additions and 1 deletions

View File

@ -1708,7 +1708,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
emscripten::val errHandler
)->sk_sp<SkRuntimeEffect> {
SkString s(sksl.c_str(), sksl.length());
auto [effect, errorText] = SkRuntimeEffect::Make(s);
auto [effect, errorText] = SkRuntimeEffect::MakeForShader(s);
if (!effect) {
errHandler.call<void>("onError", val(errorText.c_str()));
return nullptr;

View File

@ -29,6 +29,14 @@ Milestone 91
syntax of 'in shader' is no longer supported.
https://review.skia.org/393081
* SkRuntimeEffect now enforces stricter rules on the signature of main, and arguments to sample().
main must be declared to return a color ('half4', 'float4', or 'vec4'). The first argument must
be coordinates ('float2' or 'vec2'). The second argument is optional, but if present, it must
be the incoming color ('half4', 'float4', or 'vec4').
Calls to sample a shader must be of the form 'sample(child, coords)', where 'child' is a uniform
shader, and 'coords' is of type 'float2' or 'vec2'.
https://review.skia.org/399077
* * *
Milestone 90