Initial checkin of new SkSL interpreter.
Not quite feature complete yet, but at a point where it's worth checking
in.
Bug: skia:
Change-Id: I21141d30e8582a79e94450d84e56bacc067249e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201685
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/gm/runtimecolorfilter.cpp b/gm/runtimecolorfilter.cpp
index ebc6a20..0f84dff 100644
--- a/gm/runtimecolorfilter.cpp
+++ b/gm/runtimecolorfilter.cpp
@@ -33,7 +33,7 @@
canvas->drawImage(img, 0, 0, nullptr);
float b = 0.75;
- sk_sp<SkData> data = SkData::MakeWithoutCopy(&b, sizeof(b));
+ sk_sp<SkData> data = SkData::MakeWithCopy(&b, sizeof(b));
auto cf1 = SkRuntimeColorFilterFactory(SkString(SKSL_TEST_SRC), runtimeCpuFunc).make(data);
SkPaint p;
p.setColorFilter(cf1);
@@ -49,3 +49,25 @@
p.setColorFilter(cf2);
canvas->drawImage(img, 512, 0, &p);
}
+
+DEF_SIMPLE_GM(runtimecolorfilter_interpreted, canvas, 768, 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));
+ auto cf1 = SkRuntimeColorFilterFactory(SkString(SKSL_TEST_SRC), nullptr).make(data);
+ SkPaint p;
+ p.setColorFilter(cf1);
+ canvas->drawImage(img, 256, 0, &p);
+
+ static constexpr size_t kBufferSize = 512;
+ char buffer[kBufferSize];
+ SkBinaryWriteBuffer wb(buffer, kBufferSize);
+ wb.writeFlattenable(cf1.get());
+ SkReadBuffer rb(buffer, kBufferSize);
+ auto cf2 = rb.readColorFilter();
+ SkASSERT(cf2);
+ p.setColorFilter(cf2);
+ canvas->drawImage(img, 512, 0, &p);
+}