OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This small program is used to measure the performance of the various | 5 // This small program is used to measure the performance of the various |
6 // resize algorithms offered by the ImageOperations::Resize function. | 6 // resize algorithms offered by the ImageOperations::Resize function. |
7 // It will generate an empty source bitmap, and rescale it to specified | 7 // It will generate an empty source bitmap, and rescale it to specified |
8 // dimensions. It will repeat this operation multiple time to get more accurate | 8 // dimensions. It will repeat this operation multiple time to get more accurate |
9 // average throughput. Because it uses elapsed time to do its math, it is only | 9 // average throughput. Because it uses elapsed time to do its math, it is only |
10 // accurate on an idle system (but that approach was deemed more accurate | 10 // accurate on an idle system (but that approach was deemed more accurate |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ADD_METHOD(HAMMING1), | 43 ADD_METHOD(HAMMING1), |
44 ADD_METHOD(LANCZOS2), | 44 ADD_METHOD(LANCZOS2), |
45 ADD_METHOD(LANCZOS3), | 45 ADD_METHOD(LANCZOS3), |
46 }; | 46 }; |
47 | 47 |
48 // converts a string into one of the image operation method to resize. | 48 // converts a string into one of the image operation method to resize. |
49 // Returns true on success, false otherwise. | 49 // Returns true on success, false otherwise. |
50 bool StringToMethod(const std::string& arg, | 50 bool StringToMethod(const std::string& arg, |
51 skia::ImageOperations::ResizeMethod* method) { | 51 skia::ImageOperations::ResizeMethod* method) { |
52 for (size_t i = 0; i < arraysize(resize_methods); ++i) { | 52 for (size_t i = 0; i < arraysize(resize_methods); ++i) { |
53 if (base::strcasecmp(arg.c_str(), resize_methods[i].name) == 0) { | 53 if (base::EqualsCaseInsensitiveASCII(arg, resize_methods[i].name)) { |
54 *method = resize_methods[i].method; | 54 *method = resize_methods[i].method; |
55 return true; | 55 return true; |
56 } | 56 } |
57 } | 57 } |
58 return false; | 58 return false; |
59 } | 59 } |
60 | 60 |
61 const char* MethodToString(skia::ImageOperations::ResizeMethod method) { | 61 const char* MethodToString(skia::ImageOperations::ResizeMethod method) { |
62 for (size_t i = 0; i < arraysize(resize_methods); ++i) { | 62 for (size_t i = 0; i < arraysize(resize_methods); ++i) { |
63 if (method == resize_methods[i].method) { | 63 if (method == resize_methods[i].method) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return 1; | 281 return 1; |
282 } | 282 } |
283 | 283 |
284 if (!bench.Run()) { | 284 if (!bench.Run()) { |
285 printf("Failed to run benchmark\n"); | 285 printf("Failed to run benchmark\n"); |
286 return 1; | 286 return 1; |
287 } | 287 } |
288 | 288 |
289 return 0; | 289 return 0; |
290 } | 290 } |
OLD | NEW |