OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Fuzz.h" | 8 #include "Fuzz.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 int fuzz_color_deserialize(sk_sp<SkData> bytes) { | 399 int fuzz_color_deserialize(sk_sp<SkData> bytes) { |
400 sk_sp<SkColorSpace> space(SkColorSpace::Deserialize(bytes->data(), bytes->si
ze())); | 400 sk_sp<SkColorSpace> space(SkColorSpace::Deserialize(bytes->data(), bytes->si
ze())); |
401 if (!space) { | 401 if (!space) { |
402 SkDebugf("[terminated] Couldn't deserialize Colorspace.\n"); | 402 SkDebugf("[terminated] Couldn't deserialize Colorspace.\n"); |
403 return 1; | 403 return 1; |
404 } | 404 } |
405 SkDebugf("[terminated] Success! deserialized Colorspace.\n"); | 405 SkDebugf("[terminated] Success! deserialized Colorspace.\n"); |
406 return 0; | 406 return 0; |
407 } | 407 } |
408 | 408 |
409 static SkSL::GLCaps default_caps() { | |
410 return { | |
411 400, | |
412 SkSL::GLCaps::kGL_Standard, | |
413 false, // isCoreProfile | |
414 false, // usesPrecisionModifiers; | |
415 false, // mustDeclareFragmentShaderOutput | |
416 true, // canUseMinAndAbsTogether | |
417 false // mustForceNegatedAtanParamToFloat | |
418 }; | |
419 } | |
420 | |
421 int fuzz_sksl2glsl(sk_sp<SkData> bytes) { | 409 int fuzz_sksl2glsl(sk_sp<SkData> bytes) { |
422 SkSL::Compiler compiler; | 410 SkSL::Compiler compiler; |
423 std::string output; | 411 std::string output; |
424 bool result = compiler.toGLSL(SkSL::Program::kFragment_Kind, | 412 bool result = compiler.toGLSL(SkSL::Program::kFragment_Kind, |
425 (const char*)bytes->data(), default_caps(), &output); | 413 (const char*)bytes->data(), SkSL::GLCaps(), &output); |
426 | 414 |
427 if (!result) { | 415 if (!result) { |
428 SkDebugf("[terminated] Couldn't compile input.\n"); | 416 SkDebugf("[terminated] Couldn't compile input.\n"); |
429 return 1; | 417 return 1; |
430 } | 418 } |
431 SkDebugf("[terminated] Success! Compiled input.\n"); | 419 SkDebugf("[terminated] Success! Compiled input.\n"); |
432 return 0; | 420 return 0; |
433 } | 421 } |
434 | 422 |
435 Fuzz::Fuzz(sk_sp<SkData> bytes) : fBytes(bytes), fNextByte(0) {} | 423 Fuzz::Fuzz(sk_sp<SkData> bytes) : fBytes(bytes), fNextByte(0) {} |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 if (min > max) { | 471 if (min > max) { |
484 SkDebugf("Check mins and maxes (%f, %f)\n", min, max); | 472 SkDebugf("Check mins and maxes (%f, %f)\n", min, max); |
485 this->signalBoring(); | 473 this->signalBoring(); |
486 } | 474 } |
487 float f = std::abs(this->nextF()); | 475 float f = std::abs(this->nextF()); |
488 if (!std::isnormal(f) && f != 0.0) { | 476 if (!std::isnormal(f) && f != 0.0) { |
489 this->signalBoring(); | 477 this->signalBoring(); |
490 } | 478 } |
491 return min + fmod(f, (max - min + 1)); | 479 return min + fmod(f, (max - min + 1)); |
492 } | 480 } |
OLD | NEW |