Index: fuzz/fuzz.cpp |
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp |
index 549194619a7d1b3bd3578fec258fc0eb56f30d5f..4114f6692818efb784bdbda0dade910e18e61348 100644 |
--- a/fuzz/fuzz.cpp |
+++ b/fuzz/fuzz.cpp |
@@ -16,6 +16,7 @@ |
#include "SkPicture.h" |
#include "SkPicture.h" |
#include "SkPicture.h" |
+#include "SkSLCompiler.h" |
#include "SkStream.h" |
#include <cmath> |
@@ -39,6 +40,7 @@ static int fuzz_img(sk_sp<SkData>, uint8_t, uint8_t); |
static int fuzz_skp(sk_sp<SkData>); |
static int fuzz_icc(sk_sp<SkData>); |
static int fuzz_color_deserialize(sk_sp<SkData>); |
+static int fuzz_sksl2glsl(sk_sp<SkData>); |
int main(int argc, char** argv) { |
SkCommandLineFlags::Parse(argc, argv); |
@@ -68,7 +70,11 @@ int main(int argc, char** argv) { |
} |
// image_mode |
return fuzz_img(bytes, 0, option); |
- case 's': return fuzz_skp(bytes); |
+ case 's': |
+ if (FLAGS_type[0][2] == 's') { //sksl2glsl |
mtklein_C
2016/10/14 15:26:18
It may be time to rewrite this parsing. It's gett
kjlubick
2016/10/14 16:28:05
Done. I'm keeping sksl2glsl because I imagine we'
|
+ return fuzz_sksl2glsl(bytes); |
+ } |
+ return fuzz_skp(bytes); |
} |
} |
return printUsage(argv[0]); |
@@ -400,6 +406,34 @@ int fuzz_color_deserialize(sk_sp<SkData> bytes) { |
return 0; |
} |
+static SkSL::GLCaps default_caps() { |
+ return { |
+ 400, |
+ SkSL::GLCaps::kGL_Standard, |
+ false, // isCoreProfile |
+ false, // usesPrecisionModifiers; |
+ false, // mustDeclareFragmentShaderOutput |
+ true, // canUseMinAndAbsTogether |
+ false // mustForceNegatedAtanParamToFloat |
+ }; |
+} |
+ |
+int fuzz_sksl2glsl(sk_sp<SkData> bytes) { |
+ SkSL::Compiler compiler; |
+ std::string output; |
+ bool result = compiler.toGLSL(SkSL::Program::kFragment_Kind, |
+ reinterpret_cast<const char*>(bytes->data()), default_caps(), &output); |
mtklein_C
2016/10/14 15:26:18
This probably shouldn't be reinterpret_cast. It'l
kjlubick
2016/10/14 16:28:05
Done. bytes->bytes() did not work
|
+ |
+ if (!result) { |
+ //SkDebugf("%s\n", compiler.errorText().c_str()); |
+ SkDebugf("[terminated] Couldn't compile input.\n"); |
+ return 1; |
+ } |
+ //SkDebugf("%s\n", output.c_str()); |
+ SkDebugf("[terminated] Success! Compiled input.\n"); |
+ return 0; |
+} |
+ |
Fuzz::Fuzz(sk_sp<SkData> bytes) : fBytes(bytes), fNextByte(0) {} |
void Fuzz::signalBug () { SkDebugf("Signal bug\n"); raise(SIGSEGV); } |