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>
This commit is contained in:
parent
c5ff41f297
commit
ba9e8171c1
@ -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 @@ DEF_SIMPLE_GM(runtimecolorfilter, canvas, 512, 256) {
|
||||
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);
|
||||
|
@ -296,7 +296,10 @@ SkRuntimeEffect::ByteCodeResult SkRuntimeEffect::toByteCode(const void* inputs)
|
||||
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 @@ sk_sp<SkColorFilter> SkRuntimeEffect::makeColorFilter(sk_sp<SkData> inputs,
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user