Reland "Better first-class shader & color filter support in runtime effects"

This is a reland of adadb95a9f1ef21ccc5264c7d0bdc83b56cf91e9
... adds a temporary workaround for some Android framework code.

Original change's description:
> Better first-class shader & color filter support in runtime effects
>
> This does a few things, because they're all intertwined:
>
> 1) SkRuntimeEffect's API now includes details about children (which Skia
>    stage was declared, not just the name). The factories verify that the
>    declared types in the SkSL match up with the C++ types being passed.
>    Today, we still only support adding children of the same type, so the
>    checks are simple. Once we allow mixing types, we'll be testing the
>    declared type against the actual C++ type supplied for each slot.
> 2) Adds sample variants that supply the input color to the child. This
>    is now the only way to invoke a colorFilter child. Internally, we
>    support passing a color when invoking a child shader, but I'm not
>    exposing that. It's not clearly part of the semantics of the Skia
>    pipeline, and is almost never useful. It also exposes users to
>    several inconsistencies (skbug.com/11942).
> 3) Because of #2, it's possible that we can't compute a reusable program
>    to filter individual colors. In that case, we don't set the constant
>    output for constant input optimization, and filterColor4f falls back
>    to the slower base-class implementation.
>
> Bug: skia:11813 skia:11942
> Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

Bug: skia:11813 skia:11942
Change-Id: I2c31b147ed86fa8c4dddefb7066bc1d07fe0d285
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404637
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index a6ba883..88fce0b 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -128,15 +128,43 @@
     // Sampling a child shader requires that we pass explicit coords
     test_valid("uniform shader child;"
                "half4 main(half4 c) { return sample(child, c.rg); }");
+    // Trying to pass a color as well. (Works internally with FPs, but not in runtime effects).
+    test_invalid("uniform shader child;"
+                 "half4 main(half4 c) { return sample(child, c.rg, c); }",
+                 "no match for sample(shader, half2, half4)");
 
+    // Shader with just a color
+    test_invalid("uniform shader child;"
+                 "half4 main(half4 c) { return sample(child, c); }",
+                 "no match for sample(shader, half4)");
+    // Coords and color in a differet order
+    test_invalid("uniform shader child;"
+                 "half4 main(half4 c) { return sample(child, c, c.rg); }",
+                 "no match for sample(shader, half4, half2)");
+
+    // Older variants that are no longer allowed
     test_invalid(
             "uniform shader child;"
             "half4 main(half4 c) { return sample(child); }",
-            "expected 2 arguments");
+            "no match for sample(shader)");
     test_invalid(
             "uniform shader child;"
             "half4 main(half4 c) { return sample(child, float3x3(1)); }",
-            "expected 'float2'");
+            "no match for sample(shader, float3x3)");
+
+    // Sampling a colorFilter requires a color. No other signatures are valid.
+    test_valid("uniform colorFilter child;"
+               "half4 main(half4 c) { return sample(child, c); }");
+
+    test_invalid("uniform colorFilter child;"
+                 "half4 main(half4 c) { return sample(child); }",
+                 "sample(colorFilter)");
+    test_invalid("uniform colorFilter child;"
+                 "half4 main(half4 c) { return sample(child, c.rg); }",
+                 "sample(colorFilter, half2)");
+    test_invalid("uniform colorFilter child;"
+                 "half4 main(half4 c) { return sample(child, c.rg, c); }",
+                 "sample(colorFilter, half2, half4)");
 }
 
 DEF_TEST(SkRuntimeEffectForShader, r) {
@@ -185,14 +213,43 @@
     test_valid("uniform shader child;"
                "half4 main(float2 p) { return sample(child, p); }");
 
+    // Trying to pass a color as well. (Works internally with FPs, but not in runtime effects).
+    test_invalid("uniform shader child;"
+                 "half4 main(float2 p, half4 c) { return sample(child, p, c); }",
+                 "no match for sample(shader, float2, half4)");
+
+    // Shader with just a color
+    test_invalid("uniform shader child;"
+                 "half4 main(float2 p, half4 c) { return sample(child, c); }",
+                 "no match for sample(shader, half4)");
+    // Coords and color in a different order
+    test_invalid("uniform shader child;"
+                 "half4 main(float2 p, half4 c) { return sample(child, c, p); }",
+                 "no match for sample(shader, half4, float2)");
+
+    // Older variants that are no longer allowed
     test_invalid(
             "uniform shader child;"
             "half4 main(float2 p) { return sample(child); }",
-            "expected 2 arguments");
+            "no match for sample(shader)");
     test_invalid(
             "uniform shader child;"
             "half4 main(float2 p) { return sample(child, float3x3(1)); }",
-            "expected 'float2'");
+            "no match for sample(shader, float3x3)");
+
+    // Sampling a colorFilter requires a color. No other signatures are valid.
+    test_valid("uniform colorFilter child;"
+               "half4 main(float2 p, half4 c) { return sample(child, c); }");
+
+    test_invalid("uniform colorFilter child;"
+                 "half4 main(float2 p) { return sample(child); }",
+                 "sample(colorFilter)");
+    test_invalid("uniform colorFilter child;"
+                 "half4 main(float2 p) { return sample(child, p); }",
+                 "sample(colorFilter, float2)");
+    test_invalid("uniform colorFilter child;"
+                 "half4 main(float2 p, half4 c) { return sample(child, p, c); }",
+                 "sample(colorFilter, float2, half4)");
 }
 
 class TestEffect {