Revert "allow client to pass null if there are no uniforms"
This reverts commit 0185eb19d417fe2480da345dfcfdc62aad57d468.
Reason for revert: Asserts on ASAN bots
Original change's description:
> allow client to pass null if there are no uniforms
>
> Change-Id: I788574ccd1f66cfa29556d7d84ae813d108a39c7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271318
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=brianosman@google.com,reed@google.com
Change-Id: I497b657095570055066c4964150bfb16cd33b027
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271697
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gm/runtimecolorfilter.cpp b/gm/runtimecolorfilter.cpp
index 8093c46..84a7bb3 100644
--- a/gm/runtimecolorfilter.cpp
+++ b/gm/runtimecolorfilter.cpp
@@ -21,6 +21,8 @@
#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;
@@ -33,9 +35,11 @@
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(nullptr);
+ auto cf1 = effect->makeColorFilter(data);
SkPaint p;
p.setColorFilter(cf1);
canvas->drawImage(img, 256, 0, &p);
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 283e540..926b1f4 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -296,10 +296,7 @@
sk_sp<SkShader> SkRuntimeEffect::makeShader(sk_sp<SkData> inputs,
sk_sp<SkShader> children[], size_t childCount,
const SkMatrix* localMatrix, bool isOpaque) {
- if (!inputs) {
- inputs = SkData::MakeEmpty();
- }
- return inputs->size() == this->inputSize() && childCount == fChildren.size()
+ return inputs && inputs->size() == this->inputSize() && childCount == fChildren.size()
? sk_sp<SkShader>(new SkRTShader(sk_ref_sp(this), std::move(inputs), localMatrix,
children, childCount, isOpaque))
: nullptr;
@@ -311,10 +308,7 @@
extern sk_sp<SkColorFilter> SkMakeRuntimeColorFilter(sk_sp<SkRuntimeEffect>, sk_sp<SkData>,
sk_sp<SkColorFilter>[], size_t);
- if (!inputs) {
- inputs = SkData::MakeEmpty();
- }
- return inputs->size() == this->inputSize() && childCount == fChildren.size()
+ return inputs && inputs->size() == this->inputSize() && childCount == fChildren.size()
? SkMakeRuntimeColorFilter(sk_ref_sp(this), std::move(inputs), children, childCount)
: nullptr;
}