Add testCompile function to SkRuntimeColorFilterFactory for Chrome test

Change-Id: I31f5bf4257e8404f41b146b7e64169968d3cd291
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258804
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 6db5e45..9c80faa 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -493,6 +493,14 @@
                                                          fCpuFunc));
 }
 
+bool SkRuntimeColorFilterFactory::testCompile() const {
+    SkSL::Program::Settings settings;
+    SkSL::Compiler compiler;
+    auto program = compiler.convertProgram(SkSL::Program::kPipelineStage_Kind,
+                                           SkSL::String(fSkSL.c_str(), fSkSL.size()), settings);
+    return program && !compiler.errorCount();
+}
+
 #endif // SK_SUPPORT_GPU
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkColorFilterPriv.h b/src/core/SkColorFilterPriv.h
index ca6ad35..7251ca8 100644
--- a/src/core/SkColorFilterPriv.h
+++ b/src/core/SkColorFilterPriv.h
@@ -42,6 +42,9 @@
      */
     sk_sp<SkColorFilter> make(sk_sp<SkData> inputs);
 
+    /** Can be used to test that the provided SkSL string compiles without error. */
+    bool testCompile() const;
+
 private:
     int fIndex;
     SkString fSkSL;