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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/test/test_discardable_memory_allocator.h" | 7 #include "base/test/test_discardable_memory_allocator.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "third_party/skia/include/core/SkFlattenableSerialization.h" | 9 #include "third_party/skia/include/core/SkFlattenableSerialization.h" |
10 #include "third_party/skia/include/core/SkImageFilter.h" | 10 #include "third_party/skia/include/core/SkImageFilter.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 return false; | 21 return false; |
22 } | 22 } |
23 | 23 |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 void RunTestCase(std::string& ipc_filter_message, SkBitmap& bitmap, | 27 void RunTestCase(std::string& ipc_filter_message, SkBitmap& bitmap, |
28 SkCanvas* canvas) { | 28 SkCanvas* canvas) { |
29 // This call shouldn't crash or cause ASAN to flag any memory issues | 29 // This call shouldn't crash or cause ASAN to flag any memory issues |
30 // If nothing bad happens within this call, everything is fine | 30 // If nothing bad happens within this call, everything is fine |
31 SkFlattenable* flattenable = SkValidatingDeserializeFlattenable( | 31 sk_sp<SkImageFilter> flattenable = SkValidatingDeserializeImageFilter( |
32 ipc_filter_message.c_str(), ipc_filter_message.size(), | 32 ipc_filter_message.c_str(), ipc_filter_message.size()); |
33 SkImageFilter::GetFlattenableType()); | |
34 | 33 |
35 // Adding some info, but the test passed if we got here without any trouble | 34 // Adding some info, but the test passed if we got here without any trouble |
36 if (flattenable != NULL) { | 35 if (flattenable != NULL) { |
37 LOG(INFO) << "Valid stream detected."; | 36 LOG(INFO) << "Valid stream detected."; |
38 // Let's see if using the filters can cause any trouble... | 37 // Let's see if using the filters can cause any trouble... |
39 SkPaint paint; | 38 SkPaint paint; |
40 paint.setImageFilter(static_cast<SkImageFilter*>(flattenable))->unref(); | 39 paint.setImageFilter(flattenable); |
41 canvas->save(); | 40 canvas->save(); |
42 canvas->clipRect(SkRect::MakeXYWH( | 41 canvas->clipRect(SkRect::MakeXYWH( |
43 0, 0, SkIntToScalar(BitmapSize), SkIntToScalar(BitmapSize))); | 42 0, 0, SkIntToScalar(BitmapSize), SkIntToScalar(BitmapSize))); |
44 | 43 |
45 // This call shouldn't crash or cause ASAN to flag any memory issues | 44 // This call shouldn't crash or cause ASAN to flag any memory issues |
46 // If nothing bad happens within this call, everything is fine | 45 // If nothing bad happens within this call, everything is fine |
47 canvas->drawBitmap(bitmap, 0, 0, &paint); | 46 canvas->drawBitmap(bitmap, 0, 0, &paint); |
48 | 47 |
49 LOG(INFO) << "Filter DAG rendered successfully"; | 48 LOG(INFO) << "Filter DAG rendered successfully"; |
50 canvas->restore(); | 49 canvas->restore(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (!ReadAndRunTestCase(argv[i], bitmap, &canvas)) | 84 if (!ReadAndRunTestCase(argv[i], bitmap, &canvas)) |
86 ret = 2; | 85 ret = 2; |
87 | 86 |
88 // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish | 87 // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish |
89 // successful runs from crashes. | 88 // successful runs from crashes. |
90 printf("#EOF\n"); | 89 printf("#EOF\n"); |
91 | 90 |
92 return ret; | 91 return ret; |
93 } | 92 } |
94 | 93 |
OLD | NEW |