Chromium Code Reviews| 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 // Reminder of how to run: | 8 // Reminder of how to run: |
| 9 // $ env CC=afl-clang CXX=afl-clang++ ./gyp_skia | 9 // $ env CC=afl-clang CXX=afl-clang++ ./gyp_skia |
| 10 // $ ninja -C out/Debug fuzz | 10 // $ ninja -C out/Debug fuzz |
| 11 // $ afl-fuzz -i fuzz-in -o fuzz-out out/Debug/fuzz -n ScaleToSides -b @@ | 11 // $ afl-fuzz -i fuzz-in -o fuzz-out out/Debug/fuzz -n ScaleToSides -b @@ |
| 12 // where you seed fuzz-in/ with one or more small files. | 12 // where you seed fuzz-in/ with one or more small files. |
| 13 | 13 |
| 14 #include "Fuzz.h" | 14 #include "Fuzz.h" |
| 15 #include "SkScaleToSides.h" | 15 #include "SkScaleToSides.h" |
| 16 #include <cmath> | 16 #include <cmath> |
| 17 | 17 |
| 18 DEF_FUZZ(ScaleToSides, fuzz) { | 18 DEF_FUZZ(ScaleToSides, fuzz) { |
| 19 float radius1 = fuzz->nextF(), | 19 float radius1 = fuzz->nextF(), |
| 20 radius2 = fuzz->nextF(), | 20 radius2 = fuzz->nextF(), |
| 21 width = fuzz->nextF(); | 21 width = fuzz->nextF(); |
| 22 SkDebugf("%g %g %g\n", radius1, radius2, width); | |
| 23 | 22 |
| 24 if (!std::isfinite(radius1) || | 23 if (!std::isfinite(radius1) || |
| 25 !std::isfinite(radius2) || | 24 !std::isfinite(radius2) || |
| 26 !std::isfinite(width)) | 25 !std::isfinite(width) || |
| 26 radius1 <= 0.0f || | |
| 27 radius2 <= 0.0f) | |
| 27 { | 28 { |
| 28 fuzz->signalBoring(); | 29 fuzz->signalBoring(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 if (width <= 0.0f) { | 32 if (width <= 0.0f) { |
|
mtklein
2016/01/22 14:02:04
might want to merge this one with the previous che
herb_g
2016/01/22 16:01:05
Done.
| |
| 32 fuzz->signalBoring(); | 33 fuzz->signalBoring(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 double scale = (double)width / ((double)radius1 + (double)radius2); | 36 double scale = (double)width / ((double)radius1 + (double)radius2); |
| 36 if (scale >= 1.0) { | 37 if (scale >= 1.0 || scale <= 0.0) { |
| 37 fuzz->signalBoring(); | 38 fuzz->signalBoring(); |
| 38 } | 39 } |
| 40 SkDebugf("%g %g %g %g\n", radius1, radius2, width, scale); | |
| 39 ScaleToSides::AdjustRadii(width, scale, &radius1, &radius2); | 41 ScaleToSides::AdjustRadii(width, scale, &radius1, &radius2); |
| 40 | 42 |
| 41 // TODO(mtklein): add fuzz->keepResult() | 43 // TODO(mtklein): add fuzz->keepResult() |
| 42 volatile float junk = 0.0f; | 44 volatile float junk = 0.0f; |
| 43 junk *= radius1; | 45 junk *= radius1; |
| 44 junk *= radius2; | 46 junk *= radius2; |
| 45 } | 47 } |
| OLD | NEW |