OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "SkCanvas.h" | 5 #include "SkCanvas.h" |
6 #include "SkFlattenableSerialization.h" | 6 #include "SkFlattenableSerialization.h" |
7 #include "SkImageFilter.h" | 7 #include "SkImageFilter.h" |
8 #include "SkOSFile.h" | 8 #include "SkOSFile.h" |
9 #include "SkString.h" | 9 #include "SkString.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 testdata->resize(len); | 24 testdata->resize(len); |
25 (void) sk_fread(testdata->writable_str(), len, file); | 25 (void) sk_fread(testdata->writable_str(), len, file); |
26 return true; | 26 return true; |
27 } | 27 } |
28 | 28 |
29 static void run_test_case(const SkString& testdata, const SkBitmap& bitmap, | 29 static void run_test_case(const SkString& testdata, const SkBitmap& bitmap, |
30 SkCanvas* canvas) { | 30 SkCanvas* canvas) { |
31 // This call shouldn't crash or cause ASAN to flag any memory issues | 31 // This call shouldn't crash or cause ASAN to flag any memory issues |
32 // If nothing bad happens within this call, everything is fine | 32 // If nothing bad happens within this call, everything is fine |
33 SkFlattenable* flattenable = SkValidatingDeserializeFlattenable( | 33 SkFlattenable* flattenable = SkValidatingDeserializeFlattenable( |
34 testdata.c_str(), testdata.size()); | 34 testdata.c_str(), testdata.size(), SkImageFilter::GetFlattenableType()); |
35 | 35 |
36 // Adding some info, but the test passed if we got here without any trouble | 36 // Adding some info, but the test passed if we got here without any trouble |
37 if (flattenable != nullptr) { | 37 if (flattenable != nullptr) { |
38 SkDebugf("Valid stream detected.\n"); | 38 SkDebugf("Valid stream detected.\n"); |
39 // Let's see if using the filters can cause any trouble... | 39 // Let's see if using the filters can cause any trouble... |
40 SkPaint paint; | 40 SkPaint paint; |
41 paint.setImageFilter(static_cast<SkImageFilter*>(flattenable))->unref(); | 41 paint.setImageFilter(static_cast<SkImageFilter*>(flattenable))->unref(); |
42 canvas->save(); | 42 canvas->save(); |
43 canvas->clipRect(SkRect::MakeXYWH( | 43 canvas->clipRect(SkRect::MakeXYWH( |
44 0, 0, SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize))); | 44 0, 0, SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize))); |
(...skipping 27 matching lines...) Expand all Loading... |
72 SkCanvas canvas(bitmap); | 72 SkCanvas canvas(bitmap); |
73 canvas.clear(0x00000000); | 73 canvas.clear(0x00000000); |
74 for (int i = 1; i < argc; i++) | 74 for (int i = 1; i < argc; i++) |
75 if (!read_and_run_test_case(argv[i], bitmap, &canvas)) | 75 if (!read_and_run_test_case(argv[i], bitmap, &canvas)) |
76 ret = 2; | 76 ret = 2; |
77 // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish | 77 // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish |
78 // successful runs from crashes. | 78 // successful runs from crashes. |
79 SkDebugf("#EOF\n"); | 79 SkDebugf("#EOF\n"); |
80 return ret; | 80 return ret; |
81 } | 81 } |
OLD | NEW |