Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: samplecode/SampleFilterFuzz.cpp

Issue 116773002: Fixed more fuzzer issues (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Changed isAvailable for validateAvailable Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samplecode/SampleFilterFuzz.cpp
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 06e14f0e7da7b3549d086942d7f875ca565146af..8fa147aca4d9fd6e42756cee2f033521f8981ae6 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -111,8 +111,10 @@ static SkDisplacementMapEffect::ChannelSelectorType make_channel_selector_type()
}
static void make_g_bitmap(SkBitmap& bitmap) {
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, kBitmapSize, kBitmapSize);
- bitmap.allocPixels();
+ bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
+ while (!bitmap.allocPixels()) {
+ bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
+ }
SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
canvas.clear(0x00000000);
@@ -126,8 +128,10 @@ static void make_g_bitmap(SkBitmap& bitmap) {
}
static void make_checkerboard_bitmap(SkBitmap& bitmap) {
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, kBitmapSize, kBitmapSize);
- bitmap.allocPixels();
+ bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
+ while (!bitmap.allocPixels()) {
+ bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
+ }
SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
canvas.clear(0x00000000);
@@ -312,18 +316,24 @@ static void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& pai
}
static void do_fuzz(SkCanvas* canvas) {
+ SkImageFilter* filter = make_serialized_image_filter();
+
#ifdef SK_FUZZER_IS_VERBOSE
- static uint32_t filterId = 0;
- if (0 == filterId) {
+ static uint32_t numFilters = 0;
+ static uint32_t numValidFilters = 0;
+ if (0 == numFilters) {
printf("Fuzzing with %u\n", kSeed);
}
- printf("Filter no %u\r", filterId);
+ numFilters++;
+ if (NULL != filter) {
+ numValidFilters++;
+ }
+ printf("Filter no : %u. Valid filters so far : %u\r", numFilters, numValidFilters);
fflush(stdout);
- filterId++;
#endif
SkPaint paint;
- SkSafeUnref(paint.setImageFilter(make_serialized_image_filter()));
+ SkSafeUnref(paint.setImageFilter(filter));
drawClippedBitmap(canvas, 0, 0, paint);
}

Powered by Google App Engine
This is Rietveld 408576698