Store float value for settings in SkSL v2
If you used 'in float foo' in a runtime effect it would always have the
value cast to an int. I don't think we saw this in .fp files because
the cpp generation handled those values directly (if I remember correctly)
Just uses a union of float and int, differentiated by fKind, so that it
compiles in standalone mode (vs. using SkFloat2Bits, etc.).
Also updated to add a unit test.
Change-Id: I420f43d1b54638883af0b8df6ccba2416c587868
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292315
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index d28b3e4..66dacd3 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -146,6 +146,10 @@
pickColor.test(r, surface, 0x7F00007F); // Tests that we clamp to valid premul
pickColor["flag"] = 1;
pickColor.test(r, surface, 0xFF00FF00);
+
+ TestEffect inlineColor(r, "in half c;", "color = half4(c, c, c, 1);");
+ inlineColor["c"] = 0.498f;
+ inlineColor.test(r, surface, 0xFF7F7F7F);
}
DEF_TEST(SkRuntimeEffectSimple, r) {