allow client to pass null if there are no uniforms

Relies on https://skia-review.googlesource.com/c/skia/+/271738

Change-Id: I990ed71c847af472252b6efc3abde83fc741abfa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271698
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/gm/runtimecolorfilter.cpp b/gm/runtimecolorfilter.cpp
index 84a7bb3..8093c46 100644
--- a/gm/runtimecolorfilter.cpp
+++ b/gm/runtimecolorfilter.cpp
@@ -21,8 +21,6 @@
 #include <utility>
 
 const char* SKSL_TEST_SRC = R"(
-    uniform half b;
-
     void main(inout half4 color) {
         color.a = color.r*0.3 + color.g*0.6 + color.b*0.1;
         color.r = 0;
@@ -35,11 +33,9 @@
     auto img = GetResourceAsImage("images/mandrill_256.png");
     canvas->drawImage(img, 0, 0, nullptr);
 
-    float b = 0.75;
-    sk_sp<SkData> data = SkData::MakeWithCopy(&b, sizeof(b));
     sk_sp<SkRuntimeEffect> effect = std::get<0>(SkRuntimeEffect::Make(SkString(SKSL_TEST_SRC)));
 
-    auto cf1 = effect->makeColorFilter(data);
+    auto cf1 = effect->makeColorFilter(nullptr);
     SkPaint p;
     p.setColorFilter(cf1);
     canvas->drawImage(img, 256, 0, &p);
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 926b1f4..283e540 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -296,7 +296,10 @@
 sk_sp<SkShader> SkRuntimeEffect::makeShader(sk_sp<SkData> inputs,
                                             sk_sp<SkShader> children[], size_t childCount,
                                             const SkMatrix* localMatrix, bool isOpaque) {
-    return inputs && inputs->size() == this->inputSize() && childCount == fChildren.size()
+    if (!inputs) {
+        inputs = SkData::MakeEmpty();
+    }
+    return inputs->size() == this->inputSize() && childCount == fChildren.size()
         ? sk_sp<SkShader>(new SkRTShader(sk_ref_sp(this), std::move(inputs), localMatrix,
                                          children, childCount, isOpaque))
         : nullptr;
@@ -308,7 +311,10 @@
     extern sk_sp<SkColorFilter> SkMakeRuntimeColorFilter(sk_sp<SkRuntimeEffect>, sk_sp<SkData>,
                                                          sk_sp<SkColorFilter>[], size_t);
 
-    return inputs && inputs->size() == this->inputSize() && childCount == fChildren.size()
+    if (!inputs) {
+        inputs = SkData::MakeEmpty();
+    }
+    return inputs->size() == this->inputSize() && childCount == fChildren.size()
         ? SkMakeRuntimeColorFilter(sk_ref_sp(this), std::move(inputs), children, childCount)
         : nullptr;
 }