.fp files now support user-defined functions
Bug: skia:
Change-Id: I9903f4c7751474a066b52b1feab39b58a9cb7af2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238439
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/tests/SkSLFPTest.cpp b/tests/SkSLFPTest.cpp
index aba444b..ce6a971 100644
--- a/tests/SkSLFPTest.cpp
+++ b/tests/SkSLFPTest.cpp
@@ -710,3 +710,22 @@
"_sample110.c_str());\n"
});
}
+
+DEF_TEST(SkSLFPFunction, r) {
+ test(r,
+ "in fragmentProcessor? child;"
+ "half4 flip(half4 c) { return c.abgr; }"
+ "void main() {"
+ " sk_OutColor = flip(sk_InColor);"
+ "}",
+ *SkSL::ShaderCapsFactory::Default(),
+ {},
+ {
+ "SkString flip_name;",
+ "const GrShaderVar flip_args[] = { GrShaderVar(\"c\", kHalf4_GrSLType)};",
+ "fragBuilder->emitFunction(kHalf4_GrSLType, \"flip\", 1, flip_args, "
+ "\"return c.wzyx;\\n\", &flip_name);",
+ "fragBuilder->codeAppendf(\"%s = %s(%s);\\n\", args.fOutputColor, flip_name.c_str(), "
+ "args.fInputColor);"
+ });
+}