Remove isOpaque parameter from CanvasKit SkRuntimeEffect APIs

Bug: skia:12643
Change-Id: I285d42c908c75532b78c9b80da7b6145e1b47fe7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506458
Reviewed-by: Kevin Lubick <kjlubick@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 919bb34..6626630 100644
--- a/demos.skia.org/demos/image_sampling/index.html
+++ b/demos.skia.org/demos/image_sampling/index.html
@@ -117,14 +117,14 @@
 
         // Upper left, draw image using an algorithm (written in SkSL) between nearest neighbor and
         // linear interpolation with no smoothing.
-        paint.setShader(effect.makeShaderWithChildren([m, 0], true, [imageShader], null));
+        paint.setShader(effect.makeShaderWithChildren([m, 0], [imageShader], null));
         canvas.drawRect(CanvasKit.LTRBRect(0, 0, 4, 4), paint);
 
         // Lower left, draw image using an algorithm (written in SkSL) between nearest neighbor and
         // linear interpolation with smoothing enabled.
         canvas.save();
         canvas.translate(0, 4.1);
-        paint.setShader(effect.makeShaderWithChildren([m, 1], true, [imageShader], null));
+        paint.setShader(effect.makeShaderWithChildren([m, 1], [imageShader], null));
         canvas.drawRect(CanvasKit.LTRBRect(0, 0, 4, 4), paint);
         canvas.restore();
 
diff --git a/demos.skia.org/demos/up_scaling/index.html b/demos.skia.org/demos/up_scaling/index.html
index dd1bbf7..c2f3f7f 100644
--- a/demos.skia.org/demos/up_scaling/index.html
+++ b/demos.skia.org/demos/up_scaling/index.html
@@ -111,7 +111,7 @@
   draw_one_pass = function(canvas, y, scale) {
       canvas.save();
       canvas.scale(scale, 1.0);
-      shader_paint.setShader(effect.makeShaderWithChildren([Math.round(scale)], true, [imageShader], null));
+      shader_paint.setShader(effect.makeShaderWithChildren([Math.round(scale)], [imageShader], null));
       canvas.drawRect([0, 0, size, y], shader_paint);
       canvas.restore();
   }
diff --git a/modules/canvaskit/CHANGELOG.md b/modules/canvaskit/CHANGELOG.md
index 5e09820..d5c62c0 100644
--- a/modules/canvaskit/CHANGELOG.md
+++ b/modules/canvaskit/CHANGELOG.md
@@ -6,6 +6,12 @@
 
 ## [Unreleased]
 
+### Breaking
+ - `SkRuntimeEffect.makeShader` and `SkRuntimeEffect.makeShaderWithChildren` no longer accept
+   an `isOpaque` parameter. These functions will now make a best effort to determine if your
+   shader always produces opaque output, and optimize accordingly. If you definitely want your
+   shader to produce opaque output, do so in the shader's SkSL code.
+
 ### Added
  - `SkPicture.makeShader`
 
diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp
index 4c3c36e..b659212 100644
--- a/modules/canvaskit/canvaskit_bindings.cpp
+++ b/modules/canvaskit/canvaskit_bindings.cpp
@@ -1836,7 +1836,9 @@
             return SkRuntimeEffect::MakeTraced(shader, SkIPoint::Make(traceCoordX, traceCoordY));
         }))
 #endif
-        .function("_makeShader", optional_override([](SkRuntimeEffect& self, WASMPointerF32 fPtr, size_t fLen, bool isOpaque,
+        .function("_makeShader", optional_override([](SkRuntimeEffect& self,
+                                                      WASMPointerF32 fPtr,
+                                                      size_t fLen,
                                                       WASMPointerF32 mPtr)->sk_sp<SkShader> {
             void* inputData = reinterpret_cast<void*>(fPtr);
             castUniforms(inputData, fLen, self);
@@ -1845,8 +1847,11 @@
             OptionalMatrix localMatrix(mPtr);
             return self.makeShader(inputs, nullptr, 0, &localMatrix);
         }))
-        .function("_makeShaderWithChildren", optional_override([](SkRuntimeEffect& self, WASMPointerF32 fPtr, size_t fLen, bool isOpaque,
-                                                                  WASMPointerU32 cPtrs, size_t cLen,
+        .function("_makeShaderWithChildren", optional_override([](SkRuntimeEffect& self,
+                                                                  WASMPointerF32 fPtr,
+                                                                  size_t fLen,
+                                                                  WASMPointerU32 cPtrs,
+                                                                  size_t cLen,
                                                                   WASMPointerF32 mPtr)->sk_sp<SkShader> {
             void* inputData = reinterpret_cast<void*>(fPtr);
             castUniforms(inputData, fLen, self);
diff --git a/modules/canvaskit/npm_build/extra.html b/modules/canvaskit/npm_build/extra.html
index bcbdc68..862ef0a 100644
--- a/modules/canvaskit/npm_build/extra.html
+++ b/modules/canvaskit/npm_build/extra.html
@@ -401,7 +401,7 @@
       0.5,
       150, 150,
       0, 1, 0, 1,
-      1, 0, 0, 1], true);
+      1, 0, 0, 1]);
     const paint = new CanvasKit.Paint();
     paint.setShader(shader);
     canvas.drawRect(CanvasKit.LTRBRect(0, 0, 300, 300), paint);
@@ -489,7 +489,7 @@
       rad_scale,
       quadrantSize/2, quadrantSize/2,
       1, 1, 1, 1,
-      0, 0, 0, 1], true);
+      0, 0, 0, 1]);
 
       const blur = CanvasKit.ImageFilter.MakeBlur(0.1, 0.1, CanvasKit.TileMode.Clamp, null);
 
@@ -513,7 +513,7 @@
 
       const blendShader = thresholdEffect.makeShaderWithChildren(
         [0.5, 10],
-        true, [dogShader, mandrillShader, thresholdShader]);
+        [dogShader, mandrillShader, thresholdShader]);
       draw(0, 0, blendShader);
       draw(quadrantSize, 0, thresholdShader);
       draw(0, quadrantSize, dogShader);
diff --git a/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts b/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts
index 8c7cf5d..47eb2fc 100644
--- a/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts
+++ b/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts
@@ -688,9 +688,9 @@
     });
     const someMatr = CK.Matrix.translated(2, 60);
     const s1 = rt.makeShader([0, 1]); // $ExpectType Shader
-    const s2 = rt.makeShader([0, 1], true, someMatr); // $ExpectType Shader
-    const s3 = rt.makeShaderWithChildren([4, 5], true, [s1, s2]); // $ExpectType Shader
-    const s4 = rt.makeShaderWithChildren([4, 5], true, [s1, s2], someMatr); // $ExpectType Shader
+    const s2 = rt.makeShader([0, 1], someMatr); // $ExpectType Shader
+    const s3 = rt.makeShaderWithChildren([4, 5], [s1, s2]); // $ExpectType Shader
+    const s4 = rt.makeShaderWithChildren([4, 5], [s1, s2], someMatr); // $ExpectType Shader
     const a = rt.getUniform(1); // $ExpectType SkSLUniform
     const b = rt.getUniformCount(); // $ExpectType number
     const c = rt.getUniformFloatCount(); // $ExpectType number
diff --git a/modules/canvaskit/npm_build/types/index.d.ts b/modules/canvaskit/npm_build/types/index.d.ts
index 07b18c3..3abbcc3 100644
--- a/modules/canvaskit/npm_build/types/index.d.ts
+++ b/modules/canvaskit/npm_build/types/index.d.ts
@@ -2550,20 +2550,18 @@
     /**
      * Returns a shader executed using the given uniform data.
      * @param uniforms
-     * @param isOpaque
      * @param localMatrix
      */
-    makeShader(uniforms: Float32Array | number[], isOpaque?: boolean,
+    makeShader(uniforms: Float32Array | number[],
                localMatrix?: InputMatrix): Shader;
 
     /**
      * Returns a shader executed using the given uniform data and the children as inputs.
      * @param uniforms
-     * @param isOpaque
      * @param children
      * @param localMatrix
      */
-    makeShaderWithChildren(uniforms: Float32Array | number[], isOpaque?: boolean,
+    makeShaderWithChildren(uniforms: Float32Array | number[],
                            children?: Shader[], localMatrix?: InputMatrix): Shader;
 
     /**
diff --git a/modules/canvaskit/rt_shader.js b/modules/canvaskit/rt_shader.js
index f671091..19aa440 100644
--- a/modules/canvaskit/rt_shader.js
+++ b/modules/canvaskit/rt_shader.js
@@ -15,17 +15,17 @@
     return CanvasKit.RuntimeEffect._Make(sksl, callbackObj);
   };
 
-  CanvasKit.RuntimeEffect.prototype.makeShader = function(floats, isOpaque, localMatrix) {
+  CanvasKit.RuntimeEffect.prototype.makeShader = function(floats, localMatrix) {
     // We don't need to free these floats because they will become owned by the shader.
     var fptr = copy1dArray(floats, "HEAPF32");
     var localMatrixPtr = copy3x3MatrixToWasm(localMatrix);
     // Our array has 4 bytes per float, so be sure to account for that before
     // sending it over the wire.
-    return this._makeShader(fptr, floats.length * 4, !!isOpaque, localMatrixPtr);
+    return this._makeShader(fptr, floats.length * 4, localMatrixPtr);
   }
 
   // childrenWithShaders is an array of other shaders (e.g. Image.makeShader())
-  CanvasKit.RuntimeEffect.prototype.makeShaderWithChildren = function(floats, isOpaque, childrenShaders, localMatrix) {
+  CanvasKit.RuntimeEffect.prototype.makeShaderWithChildren = function(floats, childrenShaders, localMatrix) {
     // We don't need to free these floats because they will become owned by the shader.
     var fptr = copy1dArray(floats, "HEAPF32");
     var localMatrixPtr = copy3x3MatrixToWasm(localMatrix);
@@ -38,7 +38,7 @@
     var childrenPointers = copy1dArray(barePointers, "HEAPU32");
     // Our array has 4 bytes per float, so be sure to account for that before
     // sending it over the wire.
-    return this._makeShaderWithChildren(fptr, floats.length * 4, !!isOpaque, childrenPointers,
+    return this._makeShaderWithChildren(fptr, floats.length * 4, childrenPointers,
                                         barePointers.length, localMatrixPtr);
   }
 });
diff --git a/modules/canvaskit/tests/rtshader.spec.js b/modules/canvaskit/tests/rtshader.spec.js
index ea4c4b7..4220ebe 100644
--- a/modules/canvaskit/tests/rtshader.spec.js
+++ b/modules/canvaskit/tests/rtshader.spec.js
@@ -65,7 +65,6 @@
             CANVAS_WIDTH/2, CANVAS_HEIGHT/2,
             1, 0, 0, 1, // solid red
             0, 1, 0, 1], // solid green
-            true, /*=opaque*/
             localMatrix);
         paint.setShader(shader);
         canvas.drawRect(CanvasKit.LTRBRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT), paint);
@@ -109,9 +108,8 @@
         const shader = spiral.makeShader([
             0.3,
             CANVAS_WIDTH/2, CANVAS_HEIGHT/2,
-            1, 0, 0, 1, // solid red
-            0, 1, 0, 1], // solid green
-            true /*=opaque*/);
+            1, 0, 0, 1,   // solid red
+            0, 1, 0, 1]); // solid green
 
         const traced = CanvasKit.RuntimeEffect.MakeTraced(shader, CANVAS_WIDTH/2, CANVAS_HEIGHT/2);
         paint.setShader(traced.shader);
@@ -209,11 +207,11 @@
                     0.8,
                     CANVAS_WIDTH/2, CANVAS_HEIGHT/2,
                     1, 1, 1, 1,
-                    0, 0, 0, 1], true);
+                    0, 0, 0, 1]);
 
                 const blendShader = thresholdEffect.makeShaderWithChildren(
                     [0.5, 5],
-                    true, [brickShader, mandrillShader, spiralShader], localMatrix);
+                    [brickShader, mandrillShader, spiralShader], localMatrix);
 
                 const surface = CanvasKit.MakeCanvasSurface('test');
                 expect(surface).toBeTruthy('Could not make surface');
diff --git a/site/docs/user/modules/canvaskit.md b/site/docs/user/modules/canvaskit.md
index 4ee7d32..205aa00 100644
--- a/site/docs/user/modules/canvaskit.md
+++ b/site/docs/user/modules/canvaskit.md
@@ -479,8 +479,7 @@
         Math.sin(Date.now() / 2000) / 5,
         256, 256,
         1, 0, 0, 1,
-        0, 1, 0, 1],
-        true/*=opaque*/);
+        0, 1, 0, 1]);
 
       paint.setShader(shader);
       canvas.drawRect(CanvasKit.LTRBRect(0, 0, 512, 512), paint);
@@ -660,7 +659,7 @@
       const uniforms = [...lightWorldPos, ...localToWorld, ...normalMatrix(localToWorld)];
       const paint = new CanvasKit.Paint();
       paint.setAntiAlias(true);
-      const shader = fact.makeShaderWithChildren(uniforms, true /*=opaque*/, children);
+      const shader = fact.makeShaderWithChildren(uniforms, children);
       paint.setShader(shader);
       canvas.drawRRect(rr, paint);
     }