Convert internal sample() calls to shade/filter/blend

Bug: skia:12302
Change-Id: I8cf958acf9214d0de903a4097647afd74f2a659e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441541
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/demos.skia.org/demos/image_sampling/index.html b/demos.skia.org/demos/image_sampling/index.html
index 8b41cda..80b7979 100644
--- a/demos.skia.org/demos/image_sampling/index.html
+++ b/demos.skia.org/demos/image_sampling/index.html
@@ -66,10 +66,10 @@
     }
 
     half4 main(float2 p) {
-        half4 pa = sample(image, float2(p.x-0.5, p.y-0.5));
-        half4 pb = sample(image, float2(p.x+0.5, p.y-0.5));
-        half4 pc = sample(image, float2(p.x-0.5, p.y+0.5));
-        half4 pd = sample(image, float2(p.x+0.5, p.y+0.5));
+        half4 pa = shade(image, float2(p.x-0.5, p.y-0.5));
+        half4 pb = shade(image, float2(p.x+0.5, p.y-0.5));
+        half4 pc = shade(image, float2(p.x-0.5, p.y+0.5));
+        half4 pd = shade(image, float2(p.x+0.5, p.y+0.5));
         float2 w = sharpen(fract(p + 0.5));
         if (do_smooth > 0) {
             w = smooth(w);
diff --git a/demos.skia.org/demos/up_scaling/index.html b/demos.skia.org/demos/up_scaling/index.html
index a5c70c2..3a4019f 100644
--- a/demos.skia.org/demos/up_scaling/index.html
+++ b/demos.skia.org/demos/up_scaling/index.html
@@ -64,10 +64,10 @@
       float h = nearly_center(p) ? 0.0 : 0.5;
 
       // Manual bilerp logic
-      half4 pa = sample(image, float2(p.x-h, p.y-h));
-      half4 pb = sample(image, float2(p.x+h, p.y-h));
-      half4 pc = sample(image, float2(p.x-h, p.y+h));
-      half4 pd = sample(image, float2(p.x+h, p.y+h));
+      half4 pa = shade(image, float2(p.x-h, p.y-h));
+      half4 pb = shade(image, float2(p.x+h, p.y-h));
+      half4 pc = shade(image, float2(p.x-h, p.y+h));
+      half4 pd = shade(image, float2(p.x+h, p.y+h));
 
       // Now 'sharpen' the weighting. This is the magic sauce where we different
       // from a normal bilerp
diff --git a/fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp b/fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp
index 7e3d987..e321338 100644
--- a/fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp
+++ b/fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp
@@ -38,20 +38,15 @@
         void declareGlobal(const char* /*declaration*/) override {}
 
         String sampleShader(int index, String coords) override {
-            return "sample(" + SkSL::to_string(index) + ", " + coords + ")";
+            return "shade(" + SkSL::to_string(index) + ", " + coords + ")";
         }
 
         String sampleColorFilter(int index, String color) override {
-            String result = "sample(" + SkSL::to_string(index);
-            if (!color.empty()) {
-                result += ", " + color;
-            }
-            result += ")";
-            return result;
+            return "filter(" + SkSL::to_string(index) + ", " + color + ")";
         }
 
         String sampleBlender(int index, String src, String dst) override {
-            return "sample(" + SkSL::to_string(index) + ", " + src + ", " + dst + ")";
+            return "blend(" + SkSL::to_string(index) + ", " + src + ", " + dst + ")";
         }
     };
 
diff --git a/gm/composecolorfilter.cpp b/gm/composecolorfilter.cpp
index 218d36c..9c2847b 100644
--- a/gm/composecolorfilter.cpp
+++ b/gm/composecolorfilter.cpp
@@ -66,7 +66,7 @@
         auto [effect, error] = SkRuntimeEffect::MakeForColorFilter(SkString(R"(
             uniform colorFilter inner;
             uniform colorFilter outer;
-            half4 main(half4 c) { return sample(outer, sample(inner, c)); }
+            half4 main(half4 c) { return filter(outer, filter(inner, c)); }
         )"));
         SkASSERT(effect);
         SkASSERT(SkRuntimeEffectPriv::SupportsConstantOutputForConstantInput(effect));
diff --git a/gm/runtimeeffectimage.cpp b/gm/runtimeeffectimage.cpp
index c24f77a..f3ba590 100644
--- a/gm/runtimeeffectimage.cpp
+++ b/gm/runtimeeffectimage.cpp
@@ -35,7 +35,7 @@
                 half b = fract((p.x + 5)/10);
                 half a = min(distance(p, vec2(50, 50))/50 + 0.3, 1);
                 half4 result = half4(r, g, b, a);
-                result *= sample(child, p);
+                result *= shade(child, p);
                 if (gAlphaType == 0) {
                    result.rgb *= a;
                 }
diff --git a/gm/runtimeimagefilter.cpp b/gm/runtimeimagefilter.cpp
index 283376f..2fcc371 100644
--- a/gm/runtimeimagefilter.cpp
+++ b/gm/runtimeimagefilter.cpp
@@ -27,7 +27,7 @@
         uniform shader input;
         half4 main(float2 coord) {
             coord.x += sin(coord.y / 3) * 4;
-            return sample(input, coord);
+            return shade(input, coord);
         }
     )")).effect;
     return SkMakeRuntimeImageFilter(std::move(effect),
diff --git a/gm/runtimeshader.cpp b/gm/runtimeshader.cpp
index e96f2de..8c25aa8 100644
--- a/gm/runtimeshader.cpp
+++ b/gm/runtimeshader.cpp
@@ -137,10 +137,10 @@
         }
 
         half4 main(float2 xy) {
-            half4 before = sample(before_map, xy);
-            half4 after = sample(after_map, xy);
+            half4 before = shade(before_map, xy);
+            half4 after = shade(after_map, xy);
 
-            float m = smooth_cutoff(sample(threshold_map, xy).a);
+            float m = smooth_cutoff(shade(threshold_map, xy).a);
             return mix(before, after, m);
         }
     )", kAnimate_RTFlag | kBench_RTFlag) {}
@@ -228,11 +228,11 @@
     UnsharpRT() : RuntimeShaderGM("unsharp_rt", {512, 256}, R"(
         uniform shader input;
         half4 main(float2 xy) {
-            half4 c = sample(input, xy) * 5;
-            c -= sample(input, xy + float2( 1,  0));
-            c -= sample(input, xy + float2(-1,  0));
-            c -= sample(input, xy + float2( 0,  1));
-            c -= sample(input, xy + float2( 0, -1));
+            half4 c = shade(input, xy) * 5;
+            c -= shade(input, xy + float2( 1,  0));
+            c -= shade(input, xy + float2(-1,  0));
+            c -= shade(input, xy + float2( 0,  1));
+            c -= shade(input, xy + float2( 0, -1));
             return c;
         }
     )") {}
@@ -273,7 +273,7 @@
         uniform float inv_size;
 
         half4 main(float2 xy) {
-            float4 c = unpremul(sample(input, xy));
+            float4 c = unpremul(shade(input, xy));
 
             // Map to cube coords:
             float3 cubeCoords = float3(c.rg * rg_scale + rg_bias, c.b * b_scale);
@@ -283,7 +283,7 @@
             float2 coords2 = float2(( ceil(cubeCoords.b) + cubeCoords.r) * inv_size, cubeCoords.g);
 
             // Two bilinear fetches, plus a manual lerp for the third axis:
-            half4 color = mix(sample(color_cube, coords1), sample(color_cube, coords2),
+            half4 color = mix(shade(color_cube, coords1), shade(color_cube, coords2),
                               fract(cubeCoords.b));
 
             // Premul again
@@ -366,7 +366,7 @@
             float2 coords2 = float2(( ceil(cubeCoords.b) + cubeCoords.r) * inv_size, cubeCoords.g);
 
             // Two bilinear fetches, plus a manual lerp for the third axis:
-            half4 color = mix(sample(color_cube, coords1), sample(color_cube, coords2),
+            half4 color = mix(shade(color_cube, coords1), shade(color_cube, coords2),
                               fract(cubeCoords.b));
 
             // Premul again
@@ -429,7 +429,7 @@
     DefaultColorRT() : RuntimeShaderGM("default_color_rt", {512, 256}, R"(
         uniform shader input;
         half4 main(float2 xy) {
-            return sample(input, xy);
+            return shade(input, xy);
         }
     )") {}
 
@@ -624,7 +624,7 @@
     static constexpr char scale[] =
         "uniform shader child;"
         "half4 main(float2 xy) {"
-        "    return sample(child, xy*0.1);"
+        "    return shade(child, xy*0.1);"
         "}";
 
     SkPaint p;
diff --git a/modules/canvaskit/npm_build/extra.html b/modules/canvaskit/npm_build/extra.html
index 40ad87c..4fdb4ea 100644
--- a/modules/canvaskit/npm_build/extra.html
+++ b/modules/canvaskit/npm_build/extra.html
@@ -463,10 +463,10 @@
       }
 
       half4 main(float2 xy) {
-          half4 before = sample(before_map, xy);
-          half4 after = sample(after_map, xy);
+          half4 before = shade(before_map, xy);
+          half4 after = shade(after_map, xy);
 
-          float m = smooth_cutoff(sample(threshold_map, xy).r);
+          float m = smooth_cutoff(shade(threshold_map, xy).r);
           return mix(before, after, half(m));
       }`;
 
diff --git a/modules/canvaskit/tests/rtshader.spec.js b/modules/canvaskit/tests/rtshader.spec.js
index 1cc7805..5bcf7d2 100644
--- a/modules/canvaskit/tests/rtshader.spec.js
+++ b/modules/canvaskit/tests/rtshader.spec.js
@@ -117,10 +117,10 @@
 }
 
 half4 main(float2 xy) {
-    half4 before = sample(before_map, xy);
-    half4 after = sample(after_map, xy);
+    half4 before = shade(before_map, xy);
+    half4 after = shade(after_map, xy);
 
-    float m = smooth_cutoff(sample(threshold_map, xy).r);
+    float m = smooth_cutoff(shade(threshold_map, xy).r);
     return mix(before, after, half(m));
 }`;
 
diff --git a/modules/skottie/src/effects/DisplacementMapEffect.cpp b/modules/skottie/src/effects/DisplacementMapEffect.cpp
index 187f7d3..d8d1b5f 100644
--- a/modules/skottie/src/effects/DisplacementMapEffect.cpp
+++ b/modules/skottie/src/effects/DisplacementMapEffect.cpp
@@ -48,11 +48,11 @@
     uniform half4   selector_offset;
 
     half4 main(float2 xy) {
-        half4 d = sample(displ, xy);
+        half4 d = shade(displ, xy);
 
         d = selector_matrix*unpremul(d) + selector_offset;
 
-        return sample(child, xy + d.xy*d.zw);
+        return shade(child, xy + d.xy*d.zw);
     }
 )";
 
diff --git a/modules/skottie/src/effects/SphereEffect.cpp b/modules/skottie/src/effects/SphereEffect.cpp
index f74564a..ae53203 100644
--- a/modules/skottie/src/effects/SphereEffect.cpp
+++ b/modules/skottie/src/effects/SphereEffect.cpp
@@ -77,7 +77,7 @@
             0.5 + kRPI * asin(RN.y)
         );
 
-        return apply_light(EYE, N, sample(child, UV*child_scale));
+        return apply_light(EYE, N, shade(child, UV*child_scale));
     }
 )";
 
diff --git a/resources/sksl/runtime/SampleWithExplicitCoord.rts b/resources/sksl/runtime/SampleWithExplicitCoord.rts
index 6d3a6be..f9fe458 100644
--- a/resources/sksl/runtime/SampleWithExplicitCoord.rts
+++ b/resources/sksl/runtime/SampleWithExplicitCoord.rts
@@ -1,4 +1,4 @@
 uniform shader child;
 half4 main(float2 p) {
-    return sample(child, p.yx);
+    return shade(child, p.yx);
 }
diff --git a/resources/sksl/runtime_errors/IllegalShaderUse.rts b/resources/sksl/runtime_errors/IllegalShaderUse.rts
index ff61bad..797ee07 100644
--- a/resources/sksl/runtime_errors/IllegalShaderUse.rts
+++ b/resources/sksl/runtime_errors/IllegalShaderUse.rts
@@ -11,8 +11,8 @@
 in shader s4;
 
 // Various places that shaders should not be allowed:
-half4  local()             { shader s; return sample(s, xy); }
-half4  parameter(shader s) { return sample(s, xy); }
+half4  local()             { shader s; return shade(s, xy); }
+half4  parameter(shader s) { return shade(s, xy); }
 shader returned()          { return s1; }
-half4  constructed()       { return sample(shader(s1), xy); }
-half4  expression(bool b)  { return sample(b ? s1 : s2, xy); }
+half4  constructed()       { return shade(shader(s1), xy); }
+half4  expression(bool b)  { return shade(b ? s1 : s2, xy); }
diff --git a/samplecode/Sample3D.cpp b/samplecode/Sample3D.cpp
index 17e3166..2a752e5 100644
--- a/samplecode/Sample3D.cpp
+++ b/samplecode/Sample3D.cpp
@@ -389,7 +389,7 @@
             }
 
             half4 main(float2 p) {
-                float3 norm = convert_normal_sample(sample(normal_map, p));
+                float3 norm = convert_normal_sample(shade(normal_map, p));
                 float3 plane_norm = normalize(localToWorldAdjInv * norm.xyz0).xyz;
 
                 float3 plane_pos = (localToWorld * p.xy01).xyz;
@@ -399,7 +399,7 @@
                 float dp = dot(plane_norm, light_dir);
                 float scale = min(ambient + max(dp, 0), 1);
 
-                return sample(color_map, p) * scale.xxx1;
+                return shade(color_map, p) * scale.xxx1;
             }
         )";
         auto [effect, error] = SkRuntimeEffect::MakeForShader(SkString(code));
diff --git a/site/docs/user/modules/canvaskit.md b/site/docs/user/modules/canvaskit.md
index fbd7310..05b5258 100644
--- a/site/docs/user/modules/canvaskit.md
+++ b/site/docs/user/modules/canvaskit.md
@@ -559,7 +559,7 @@
       }
 
       half4 main(float2 p) {
-        float3 norm = convert_normal_sample(sample(normal_map, p));
+        float3 norm = convert_normal_sample(shade(normal_map, p));
         float3 plane_norm = normalize(localToWorldAdjInv * float4(norm, 0)).xyz;
 
         float3 plane_pos = (localToWorld * float4(p, 0, 1)).xyz;
@@ -569,7 +569,7 @@
         float dp = dot(plane_norm, light_dir);
         float scale = min(ambient + max(dp, 0), 1);
 
-        return sample(color_map, p) * half4(float4(scale, scale, scale, 1));
+        return shade(color_map, p) * half4(float4(scale, scale, scale, 1));
       }
 `;
 
diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp
index 6300b06..5bdbc38 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -850,7 +850,7 @@
             // to rearrange to avoid passing large values to length() that would overflow.
             half2 vec = half2((sk_FragCoord.xy - circleData.xy) * circleData.w);
             half dist = length(vec) + (0.5 - circleData.z) * circleData.w;
-            return inColor * sample(blurProfile, half2(dist, 0.5)).a;
+            return inColor * shade(blurProfile, half2(dist, 0.5)).a;
         }
     )");
 
@@ -994,8 +994,8 @@
                 // computations align the left edge of the integral texture with the inset rect's
                 // edge extending outward 6 * sigma from the inset rect.
                 half2 xy = max(half2(rect.LT - pos), half2(pos - rect.RB));
-                xCoverage = sample(integral, half2(xy.x, 0.5)).a;
-                yCoverage = sample(integral, half2(xy.y, 0.5)).a;
+                xCoverage = shade(integral, half2(xy.x, 0.5)).a;
+                yCoverage = shade(integral, half2(xy.y, 0.5)).a;
             } else {
                 // We just consider just the x direction here. In practice we compute x and y
                 // separately and multiply them together.
@@ -1013,10 +1013,10 @@
                 // Also, our rect uniform was pre-inset by 3 sigma from the actual rect being
                 // blurred, also factored in.
                 half4 rect = half4(half2(rect.LT - pos), half2(pos - rect.RB));
-                xCoverage = 1 - sample(integral, half2(rect.L, 0.5)).a
-                              - sample(integral, half2(rect.R, 0.5)).a;
-                yCoverage = 1 - sample(integral, half2(rect.T, 0.5)).a
-                              - sample(integral, half2(rect.B, 0.5)).a;
+                xCoverage = 1 - shade(integral, half2(rect.L, 0.5)).a
+                              - shade(integral, half2(rect.R, 0.5)).a;
+                yCoverage = 1 - shade(integral, half2(rect.T, 0.5)).a
+                              - shade(integral, half2(rect.B, 0.5)).a;
             }
             return inColor * xCoverage * yCoverage;
         }
@@ -1426,7 +1426,7 @@
             half2 proxyDims = half2(2.0 * edgeSize);
             half2 texCoord = translatedFragPosHalf / proxyDims;
 
-            return inColor * sample(ninePatchFP, texCoord).a;
+            return inColor * shade(ninePatchFP, texCoord).a;
         }
     )");
 
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 86089d6..3c6ac99 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -477,7 +477,7 @@
         "uniform colorFilter cf1;"
         "uniform half   weight;"
         "half4 main(half4 color) {"
-            "return mix(sample(cf0, color), sample(cf1, color), weight);"
+            "return mix(filter(cf0, color), filter(cf1, color), weight);"
         "}"
     );
     SkASSERT(effect);
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 5093eaf..aa84051 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -557,18 +557,9 @@
         return nullptr;
     }
 
-    // We allocate a uniform color for the input color, and one for each call to sample(). When we
-    // encounter a sample call, we record the index of the child being sampled, as well as the color
-    // being passed. In most cases, we can record enough information to perfectly re-create that
-    // call when we're later running the program. (We support calls that pass the original input
-    // color, an immediate color, or the results of a previous sample call). If the color is none
-    // of those, we are unable to use this per-effect program, and callers will need to fall back
-    // to another (slower) implementation.
-
-    // We also require that any children are *also* color filters (not shaders or blenders). In
-    // theory we could detect the coords being passed to shader children, and replicate those calls,
-    // but that's very complicated, and has diminishing returns. (eg, for table lookup color
-    // filters).
+    // We require that any children are color filters (not shaders or blenders). In theory, we could
+    // detect the coords being passed to shader children, and replicate those calls, but that's very
+    // complicated, and has diminishing returns. (eg, for table lookup color filters).
     if (!std::all_of(effect->fChildren.begin(),
                      effect->fChildren.end(),
                      [](const SkRuntimeEffect::Child& c) {
@@ -605,10 +596,13 @@
                ua.offset == ur.offset + 12;
     };
 
-    // We reserve a uniform color for each call to sample(). While processing the SkSL, we record
-    // the index of the child being sampled, and the color being filtered (in a SampleCall struct).
+    // We reserve a uniform color for each child invocation. While processing the SkSL, we record
+    // the index of the child, and the color being filtered (in a SampleCall struct).
     // When we run this program later, we use the SampleCall to evaluate the correct child, and
     // populate these uniform values. These Uniform ids are loads from the *second* arg ptr.
+    // If the color being passed is too complex for us to describe and re-create using SampleCall,
+    // we are unable to use this per-effect program, and callers will need to fall back to another
+    // (slower) implementation.
     skvm::Uniforms childColorUniforms{p.uniform(), 0};
     skvm::Color inputColor = p.uniformColor(/*placeholder*/ SkColors::kWhite, &childColorUniforms);
     std::vector<SkFilterColorProgram::SampleCall> sampleCalls;
diff --git a/src/core/SkRuntimeEffectPriv.h b/src/core/SkRuntimeEffectPriv.h
index 9865c9f..80337a3 100644
--- a/src/core/SkRuntimeEffectPriv.h
+++ b/src/core/SkRuntimeEffectPriv.h
@@ -119,10 +119,10 @@
 private:
     struct SampleCall {
         enum class Kind {
-            kInputColor,  // eg sample(child) or sample(child, inputColor)
-            kImmediate,   // eg sample(child, half4(1))
-            kPrevious,    // eg sample(child1, sample(child2))
-            kUniform,     // eg uniform half4 color; ... sample(child, color)
+            kInputColor,  // eg filter(child, inputColor)
+            kImmediate,   // eg filter(child, half4(1))
+            kPrevious,    // eg filter(child1, filter(child2, ...))
+            kUniform,     // eg uniform half4 color; ... filter(child, color)
         };
 
         int  fChild;
diff --git a/src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp
index 6156d25..5c82b02 100644
--- a/src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp
@@ -145,7 +145,7 @@
         uniform half outerThreshold;
 
         half4 main(float2 xy, half4 color) {
-            half4 mask_color = sample(maskFP, xy);
+            half4 mask_color = shade(maskFP, xy);
             if (mask_color.a < 0.5) {
                 if (color.a > outerThreshold) {
                     half scale = outerThreshold / color.a;
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 20e9c3d..9572d7e 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -315,8 +315,8 @@
         uniform half4 k;
         uniform half pmClamp;
         half4 main(float2 xy) {
-            half4 src = sample(srcFP, xy);
-            half4 dst = sample(dstFP, xy);
+            half4 src = shade(srcFP, xy);
+            half4 dst = shade(dstFP, xy);
             half4 color = saturate(k.x * src * dst +
                                    k.y * src +
                                    k.z * dst +
diff --git a/src/effects/imagefilters/SkMagnifierImageFilter.cpp b/src/effects/imagefilters/SkMagnifierImageFilter.cpp
index efda3fe..58dfbd6 100644
--- a/src/effects/imagefilters/SkMagnifierImageFilter.cpp
+++ b/src/effects/imagefilters/SkMagnifierImageFilter.cpp
@@ -126,7 +126,7 @@
                 weight = min(min(delta_squared.x, delta_squared.y), 1.0);
             }
 
-            return sample(src, mix(coord, zoom_coord, weight));
+            return shade(src, mix(coord, zoom_coord, weight));
         }
     )");
 
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 9b20bee..b7c8b4d 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -402,10 +402,10 @@
         return nullptr;
     }
     static auto effect = SkMakeRuntimeEffect(SkRuntimeEffect::MakeForColorFilter, R"(
-        uniform colorFilter fp;  // Declared as colorFilter so we can use sample(..., color)
+        uniform colorFilter fp;  // Declared as colorFilter so we can pass a color
         uniform half4 color;
         half4 main(half4 inColor) {
-            return sample(fp, color);
+            return filter(fp, color);
         }
     )");
     SkASSERT(SkRuntimeEffectPriv::SupportsConstantOutputForConstantInput(effect));
@@ -421,9 +421,9 @@
 std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::UseDestColorAsInput(
         std::unique_ptr<GrFragmentProcessor> fp) {
     static auto effect = SkMakeRuntimeEffect(SkRuntimeEffect::MakeForBlender, R"(
-        uniform colorFilter fp;  // Declared as colorFilter so we can use sample(..., color)
+        uniform colorFilter fp;  // Declared as colorFilter so we can pass a color
         half4 main(half4 src, half4 dst) {
-            return sample(fp, dst);
+            return filter(fp, dst);
         }
     )");
     return GrSkSLFP::Make(effect, "UseDestColorAsInput", /*inputFP=*/nullptr,
@@ -438,9 +438,9 @@
         return nullptr;
     }
     static auto effect = SkMakeRuntimeEffect(SkRuntimeEffect::MakeForColorFilter, R"(
-        uniform colorFilter fp;  // Declared as colorFilter so we can use sample(..., color)
+        uniform colorFilter fp;  // Declared as colorFilter so we can pass a color
         half4 main(half4 inColor) {
-            return inColor.a * sample(fp, unpremul(inColor).rgb1);
+            return inColor.a * filter(fp, unpremul(inColor).rgb1);
         }
     )");
     return GrSkSLFP::Make(effect,
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 6118f38..89dbb83 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -611,10 +611,9 @@
      *  to the child's helper function). It is legal to pass nullptr as inputColor, since all
      *  fragment processors are required to work without an input color.
      *
-     *  When skslCoords is empty, invokeChild corresponds to a call to "sample(child, color)"
-     *  in SkSL. When skslCoords is not empty, invokeChild corresponds to a call to
-     *  "sample(child, color, float2)", where skslCoords is an SkSL expression that evaluates to a
-     *  float2 and is passed in as the 3rd argument.
+     *  When skslCoords is empty, the child is invoked at the sample coordinates from parentArgs.
+     *  When skslCoords is not empty, is must be an SkSL expression that evaluates to a float2.
+     *  That expression is passed to the child's processor function as the "_coords" argument.
      */
     SkString invokeChild(int childIndex,
                          const char* inputColor,
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index e464adf..1adb44e 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -394,7 +394,7 @@
         uniform half range;
         uniform shader table;
         half4 main(float2 xy, half4 color) {
-            half value = sample(table, sk_FragCoord.xy).a - 0.5; // undo the bias in the table
+            half value = shade(table, sk_FragCoord.xy).a - 0.5; // undo the bias in the table
             // For each color channel, add the random offset to the channel value and then clamp
             // between 0 and alpha to keep the color premultiplied.
             return half4(clamp(color.rgb + value * range, 0.0, color.a), color.a);
diff --git a/src/gpu/gradients/GrGradientShader.cpp b/src/gpu/gradients/GrGradientShader.cpp
index c506c73..2d5b2cb 100644
--- a/src/gpu/gradients/GrGradientShader.cpp
+++ b/src/gpu/gradients/GrGradientShader.cpp
@@ -425,7 +425,7 @@
         uniform int layoutPreservesOpacity;  // specialized
 
         half4 main(float2 coord) {
-            half4 t = sample(gradLayout, coord);
+            half4 t = shade(gradLayout, coord);
             half4 outColor;
 
             // If t.x is below 0, use the left border color without invoking the child processor.
@@ -442,7 +442,7 @@
             } else {
                 // Always sample from (x, 0), discarding y, since the layout FP can use y as a
                 // side-channel.
-                outColor = sample(colorizer, t.x0);
+                outColor = shade(colorizer, t.x0);
             }
             if (bool(makePremul)) {
                 outColor.rgb *= outColor.a;
@@ -487,7 +487,7 @@
         uniform int useFloorAbsWorkaround;   // specialized
 
         half4 main(float2 coord) {
-            half4 t = sample(gradLayout, coord);
+            half4 t = shade(gradLayout, coord);
 
             if (!bool(layoutPreservesOpacity) && t.y < 0) {
                 // layout has rejected this fragment (rely on sksl to remove this branch if the
@@ -511,7 +511,7 @@
 
                 // Always sample from (x, 0), discarding y, since the layout FP can use y as a
                 // side-channel.
-                half4 outColor = sample(colorizer, t.x0);
+                half4 outColor = shade(colorizer, t.x0);
                 if (bool(makePremul)) {
                     outColor.rgb *= outColor.a;
                 }
diff --git a/src/sksl/SkSLAnalysis.cpp b/src/sksl/SkSLAnalysis.cpp
index bd2782e..6b31f86 100644
--- a/src/sksl/SkSLAnalysis.cpp
+++ b/src/sksl/SkSLAnalysis.cpp
@@ -569,10 +569,10 @@
 // Analysis
 
 SampleUsage Analysis::GetSampleUsage(const Program& program,
-                                     const Variable& fp,
+                                     const Variable& child,
                                      bool writesToSampleCoords,
                                      int* elidedSampleCoordCount) {
-    MergeSampleUsageVisitor visitor(*program.fContext, fp, writesToSampleCoords);
+    MergeSampleUsageVisitor visitor(*program.fContext, child, writesToSampleCoords);
     SampleUsage result = visitor.visit(program);
     if (elidedSampleCoordCount) {
         *elidedSampleCoordCount += visitor.elidedSampleCoordCount();
diff --git a/src/sksl/SkSLAnalysis.h b/src/sksl/SkSLAnalysis.h
index c2126db..2e31e1f 100644
--- a/src/sksl/SkSLAnalysis.h
+++ b/src/sksl/SkSLAnalysis.h
@@ -35,14 +35,14 @@
  */
 struct Analysis {
     /**
-     * Determines how `program` samples `fp`. By default, assumes that the sample coords
-     * (SK_MAIN_COORDS_BUILTIN) might be modified, so `sample(fp, sampleCoords)` is treated as
+     * Determines how `program` samples `child`. By default, assumes that the sample coords
+     * (SK_MAIN_COORDS_BUILTIN) might be modified, so `shade(fp, sampleCoords)` is treated as
      * Explicit. If writesToSampleCoords is false, treats that as PassThrough, instead.
      * If elidedSampleCoordCount is provided, the pointed to value will be incremented by the
      * number of sample calls where the above rewrite was performed.
      */
     static SampleUsage GetSampleUsage(const Program& program,
-                                      const Variable& fp,
+                                      const Variable& child,
                                       bool writesToSampleCoords = true,
                                       int* elidedSampleCoordCount = nullptr);
 
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index 451bbf1..6ba03c8 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -428,20 +428,15 @@
                         }
 
                         String sampleShader(int index, String coords) override {
-                            return "sample(child_" + SkSL::to_string(index) + ", " + coords + ")";
+                            return "shade(child_" + SkSL::to_string(index) + ", " + coords + ")";
                         }
 
                         String sampleColorFilter(int index, String color) override {
-                            String result = "sample(child_" + SkSL::to_string(index);
-                            if (!color.empty()) {
-                                result += ", " + color;
-                            }
-                            result += ")";
-                            return result;
+                            return "filter(child_" + SkSL::to_string(index) + ", " + color + ")";
                         }
 
                         String sampleBlender(int index, String src, String dst) override {
-                            return "sample(child_" + SkSL::to_string(index) + ", " + src + ", " +
+                            return "blend(child_" + SkSL::to_string(index) + ", " + src + ", " +
                                    dst + ")";
                         }
 
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index 312c476..297254e 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -459,7 +459,7 @@
 
     // Sampling a null child should return the paint color
     effect.build("uniform shader child;"
-                 "half4 main(float2 p) { return sample(child, p); }");
+                 "half4 main(float2 p) { return shade(child, p); }");
     effect.child("child") = nullptr;
     effect.test(0xFF00FFFF,
                 [](SkCanvas*, SkPaint* paint) { paint->setColor4f({1.0f, 1.0f, 0.0f, 1.0f}); });
@@ -468,13 +468,13 @@
 
     // Sampling a simple child at our coordinates
     effect.build("uniform shader child;"
-                 "half4 main(float2 p) { return sample(child, p); }");
+                 "half4 main(float2 p) { return shade(child, p); }");
     effect.child("child") = rgbwShader;
     effect.test({0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFFFFFF});
 
     // Sampling with explicit coordinates (reflecting about the diagonal)
     effect.build("uniform shader child;"
-                 "half4 main(float2 p) { return sample(child, p.yx); }");
+                 "half4 main(float2 p) { return shade(child, p.yx); }");
     effect.child("child") = rgbwShader;
     effect.test({0xFF0000FF, 0xFFFF0000, 0xFF00FF00, 0xFFFFFFFF});
 
@@ -560,13 +560,13 @@
 
     // Sampling a null shader/color filter should return the paint color.
     effect.build("uniform shader child;"
-                 "half4 main(half4 s, half4 d) { return sample(child, s.rg); }");
+                 "half4 main(half4 s, half4 d) { return shade(child, s.rg); }");
     effect.child("child") = nullptr;
     effect.test(0xFF00FFFF,
                 [](SkCanvas*, SkPaint* paint) { paint->setColor4f({1.0f, 1.0f, 0.0f, 1.0f}); });
 
     effect.build("uniform colorFilter child;"
-                 "half4 main(half4 s, half4 d) { return sample(child, s); }");
+                 "half4 main(half4 s, half4 d) { return filter(child, s); }");
     effect.child("child") = nullptr;
     effect.test(0xFF00FFFF,
                 [](SkCanvas*, SkPaint* paint) { paint->setColor4f({1.0f, 1.0f, 0.0f, 1.0f}); });
@@ -574,7 +574,7 @@
     // Sampling a null blender should do a src-over blend. Draw 50% black over RGBW to verify this.
     surface->getCanvas()->drawPaint(rgbwPaint);
     effect.build("uniform blender child;"
-                 "half4 main(half4 s, half4 d) { return sample(child, s, d); }");
+                 "half4 main(half4 s, half4 d) { return blend(child, s, d); }");
     effect.child("child") = nullptr;
     effect.test({0xFF000080, 0xFF008000, 0xFF800000, 0xFF808080},
                 [](SkCanvas*, SkPaint* paint) { paint->setColor4f({0.0f, 0.0f, 0.0f, 0.497f}); });
@@ -582,7 +582,7 @@
     // Sampling a shader at various coordinates
     effect.build("uniform shader child;"
                  "uniform half2 pos;"
-                 "half4 main(half4 s, half4 d) { return sample(child, pos); }");
+                 "half4 main(half4 s, half4 d) { return shade(child, pos); }");
     effect.child("child") = make_RGBW_shader();
     effect.uniform("pos") = float2{0, 0};
     effect.test(0xFF0000FF);
@@ -598,14 +598,14 @@
 
     // Sampling a color filter
     effect.build("uniform colorFilter child;"
-                 "half4 main(half4 s, half4 d) { return sample(child, half4(1)); }");
+                 "half4 main(half4 s, half4 d) { return filter(child, half4(1)); }");
     effect.child("child") = SkColorFilters::Blend(0xFF012345, SkBlendMode::kSrc);
     effect.test(0xFF452301);
 
     // Sampling a built-in blender
     surface->getCanvas()->drawPaint(rgbwPaint);
     effect.build("uniform blender child;"
-                 "half4 main(half4 s, half4 d) { return sample(child, s, d); }");
+                 "half4 main(half4 s, half4 d) { return blend(child, s, d); }");
     effect.child("child") = SkBlender::Mode(SkBlendMode::kPlus);
     effect.test({0xFF4523FF, 0xFF45FF01, 0xFFFF2301, 0xFFFFFFFF},
                 [](SkCanvas*, SkPaint* paint) { paint->setColor(0xFF012345); });
@@ -613,7 +613,7 @@
     // Sampling a runtime-effect blender
     surface->getCanvas()->drawPaint(rgbwPaint);
     effect.build("uniform blender child;"
-                 "half4 main(half4 s, half4 d) { return sample(child, s, d); }");
+                 "half4 main(half4 s, half4 d) { return blend(child, s, d); }");
     effect.child("child") = SkBlenders::Arithmetic(0, 1, 1, 0, /*enforcePremul=*/false);
     effect.test({0xFF4523FF, 0xFF45FF01, 0xFFFF2301, 0xFFFFFFFF},
                 [](SkCanvas*, SkPaint* paint) { paint->setColor(0xFF012345); });
@@ -736,7 +736,7 @@
         "uniform shader paint;"
         "struct S { half4 rgba; };"
         "void process(inout S s) { s.rgba.rgb *= 0.5; }"
-        "half4 main(float2 p) { S s; s.rgba = sample(paint, p); process(s); return s.rgba; }"
+        "half4 main(float2 p) { S s; s.rgba = shade(paint, p); process(s); return s.rgba; }"
     ));
     REPORTER_ASSERT(r, childEffect, "%s\n", err.c_str());
     sk_sp<SkShader> nullChild = nullptr;
@@ -755,7 +755,7 @@
             "uniform shader child;"
             "struct S { float2 coord; };"
             "void process(inout S s) { s.coord = s.coord.yx; }"
-            "half4 main(float2 p) { S s; s.coord = p; process(s); return sample(child, s.coord); "
+            "half4 main(float2 p) { S s; s.coord = p; process(s); return shade(child, s.coord); "
             "}");
     effect.child("child") = child;
     effect.test(0xFF00407F, [](SkCanvas*, SkPaint* paint) {
@@ -815,31 +815,31 @@
 
     // Direct use of passed-in coords. Here, the only use of sample coords is for a sample call
     // converted to passthrough, so referenceSampleCoords is *false*, despite appearing in main.
-    test("half4 main(float2 xy) { return sample(child, xy); }", false, false);
+    test("half4 main(float2 xy) { return shade(child, xy); }", false, false);
     // Sample with passed-in coords, read (but don't write) sample coords elsewhere
-    test("half4 main(float2 xy) { return sample(child, xy) + sin(xy.x); }", false, true);
+    test("half4 main(float2 xy) { return shade(child, xy) + sin(xy.x); }", false, true);
 
     // Cases where our optimization is not valid, and does not happen:
 
     // Sampling with values completely unrelated to passed-in coords
-    test("half4 main(float2 xy) { return sample(child, float2(0, 0)); }", true, false);
+    test("half4 main(float2 xy) { return shade(child, float2(0, 0)); }", true, false);
     // Use of expression involving passed in coords
-    test("half4 main(float2 xy) { return sample(child, xy * 0.5); }", true, true);
+    test("half4 main(float2 xy) { return shade(child, xy * 0.5); }", true, true);
     // Use of coords after modification
-    test("half4 main(float2 xy) { xy *= 2; return sample(child, xy); }", true, true);
+    test("half4 main(float2 xy) { xy *= 2; return shade(child, xy); }", true, true);
     // Use of coords after modification via out-param call
     test("void adjust(inout float2 xy) { xy *= 2; }"
-         "half4 main(float2 xy) { adjust(xy); return sample(child, xy); }", true, true);
+         "half4 main(float2 xy) { adjust(xy); return shade(child, xy); }", true, true);
 
     // There should (must) not be any false-positive cases. There are false-negatives.
     // In all of these cases, our optimization would be valid, but does not happen:
 
     // Direct use of passed-in coords, modified after use
-    test("half4 main(float2 xy) { half4 c = sample(child, xy); xy *= 2; return c; }", true, true);
+    test("half4 main(float2 xy) { half4 c = shade(child, xy); xy *= 2; return c; }", true, true);
     // Passed-in coords copied to a temp variable
-    test("half4 main(float2 xy) { float2 p = xy; return sample(child, p); }", true, true);
+    test("half4 main(float2 xy) { float2 p = xy; return shade(child, p); }", true, true);
     // Use of coords passed to helper function
-    test("half4 helper(float2 xy) { return sample(child, xy); }"
+    test("half4 helper(float2 xy) { return shade(child, xy); }"
          "half4 main(float2 xy) { return helper(xy); }", true, true);
 }
 
diff --git a/tests/sksl/runtime/SampleWithExplicitCoord.stage b/tests/sksl/runtime/SampleWithExplicitCoord.stage
index b7c6790..159c7c3 100644
--- a/tests/sksl/runtime/SampleWithExplicitCoord.stage
+++ b/tests/sksl/runtime/SampleWithExplicitCoord.stage
@@ -1,4 +1,4 @@
 half4 main(float2 p)
 {
-	return half4(sample(child_0, _coords.yx));
+	return half4(shade(child_0, _coords.yx));
 }
diff --git a/tools/RuntimeBlendUtils.cpp b/tools/RuntimeBlendUtils.cpp
index 2eb35dd..c432ee7 100644
--- a/tools/RuntimeBlendUtils.cpp
+++ b/tools/RuntimeBlendUtils.cpp
@@ -13,7 +13,7 @@
     static auto result = SkRuntimeEffect::MakeForBlender(SkString(R"(
         uniform blender b;
         half4 main(half4 src, half4 dst) {
-            return sample(b, src, dst);
+            return blend(b, src, dst);
         }
     )"));
 
diff --git a/tools/viewer/SkSLSlide.cpp b/tools/viewer/SkSLSlide.cpp
index 7df9cc8..ef3655a 100644
--- a/tools/viewer/SkSLSlide.cpp
+++ b/tools/viewer/SkSLSlide.cpp
@@ -43,7 +43,7 @@
         "uniform shader child;\n"
         "\n"
         "half4 main(float2 p) {\n"
-        "    return sample(child, p);\n"
+        "    return shade(child, p);\n"
         "}\n";
 
     fCodeIsDirty = true;