OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "BenchTimer.h" | 10 #include "BenchTimer.h" |
11 | 11 |
12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrContextFactory.h" | 14 #include "GrContextFactory.h" |
15 #include "gl/GrGLDefines.h" | 15 #include "gl/GrGLDefines.h" |
16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
17 #include "SkGpuDevice.h" | 17 #include "SkGpuDevice.h" |
18 #else | 18 #else |
19 class GrContext; | 19 class GrContext; |
20 #endif // SK_SUPPORT_GPU | 20 #endif // SK_SUPPORT_GPU |
21 | 21 |
22 #include "SkBenchLogger.h" | 22 #include "SkBenchLogger.h" |
23 #include "SkBenchmark.h" | 23 #include "SkBenchmark.h" |
24 #include "SkCanvas.h" | 24 #include "SkCanvas.h" |
| 25 #include "SkCommandLineFlags.h" |
25 #include "SkDeferredCanvas.h" | 26 #include "SkDeferredCanvas.h" |
26 #include "SkDevice.h" | 27 #include "SkDevice.h" |
27 #include "SkColorPriv.h" | 28 #include "SkColorPriv.h" |
28 #include "SkGraphics.h" | 29 #include "SkGraphics.h" |
29 #include "SkImageEncoder.h" | 30 #include "SkImageEncoder.h" |
30 #include "SkNWayCanvas.h" | 31 #include "SkNWayCanvas.h" |
31 #include "SkPicture.h" | 32 #include "SkPicture.h" |
32 #include "SkString.h" | 33 #include "SkString.h" |
33 #include "SkTArray.h" | 34 #include "SkTArray.h" |
34 #include "TimerData.h" | 35 #include "TimerData.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 264 |
264 static int findConfig(const char config[]) { | 265 static int findConfig(const char config[]) { |
265 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { | 266 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { |
266 if (!strcmp(config, gConfigs[i].fName)) { | 267 if (!strcmp(config, gConfigs[i].fName)) { |
267 return i; | 268 return i; |
268 } | 269 } |
269 } | 270 } |
270 return -1; | 271 return -1; |
271 } | 272 } |
272 | 273 |
273 static bool skip_name(const SkTDArray<const char*> array, const char name[]) { | |
274 // FIXME: this duplicates the logic in skia_test.cpp, gmmain.cpp -- consolid
ate | |
275 int count = array.count(); | |
276 size_t testLen = strlen(name); | |
277 bool anyExclude = count == 0; | |
278 for (int i = 0; i < array.count(); ++i) { | |
279 const char* matchName = array[i]; | |
280 size_t matchLen = strlen(matchName); | |
281 bool matchExclude, matchStart, matchEnd; | |
282 if ((matchExclude = matchName[0] == '~')) { | |
283 anyExclude = true; | |
284 matchName++; | |
285 matchLen--; | |
286 } | |
287 if ((matchStart = matchName[0] == '^')) { | |
288 matchName++; | |
289 matchLen--; | |
290 } | |
291 if ((matchEnd = matchName[matchLen - 1] == '$')) { | |
292 matchLen--; | |
293 } | |
294 if (matchStart ? (!matchEnd || matchLen == testLen) | |
295 && strncmp(name, matchName, matchLen) == 0 | |
296 : matchEnd ? matchLen <= testLen | |
297 && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 | |
298 : strstr(name, matchName) != 0) { | |
299 return matchExclude; | |
300 } | |
301 } | |
302 return !anyExclude; | |
303 } | |
304 | |
305 static void help() { | 274 static void help() { |
306 SkString configsStr; | 275 SkString configsStr; |
307 static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); | 276 static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); |
308 for (size_t i = 0; i < kConfigCount; ++i) { | 277 for (size_t i = 0; i < kConfigCount; ++i) { |
309 configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ?
"" : "|")); | 278 configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ?
"" : "|")); |
310 } | 279 } |
311 | 280 |
312 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " | 281 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " |
313 "[--timers [wcgWC]*] [--rotate]\n" | 282 "[--timers [wcgWC]*] [--rotate]\n" |
314 " [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0]
\n" | 283 " [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0]
\n" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 733 |
765 bench->setForceAlpha(forceAlpha); | 734 bench->setForceAlpha(forceAlpha); |
766 bench->setForceAA(forceAA); | 735 bench->setForceAA(forceAA); |
767 bench->setForceFilter(forceFilter); | 736 bench->setForceFilter(forceFilter); |
768 bench->setDither(forceDither); | 737 bench->setDither(forceDither); |
769 if (hasStrokeWidth) { | 738 if (hasStrokeWidth) { |
770 bench->setStrokeWidth(strokeWidth); | 739 bench->setStrokeWidth(strokeWidth); |
771 } | 740 } |
772 | 741 |
773 // only run benchmarks if their name contains matchStr | 742 // only run benchmarks if their name contains matchStr |
774 if (skip_name(fMatches, bench->getName())) { | 743 if (SkCommandLineFlags::ShouldSkip(fMatches, bench->getName())) { |
775 continue; | 744 continue; |
776 } | 745 } |
777 | 746 |
778 bool loggedBenchStart = false; | 747 bool loggedBenchStart = false; |
779 | 748 |
780 AutoPrePostDraw appd(bench); | 749 AutoPrePostDraw appd(bench); |
781 | 750 |
782 for (int x = 0; x < configs.count(); ++x) { | 751 for (int x = 0; x < configs.count(); ++x) { |
783 int configIndex = configs[x]; | 752 int configIndex = configs[x]; |
784 | 753 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } | 966 } |
998 | 967 |
999 return 0; | 968 return 0; |
1000 } | 969 } |
1001 | 970 |
1002 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 971 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1003 int main(int argc, char * const argv[]) { | 972 int main(int argc, char * const argv[]) { |
1004 return tool_main(argc, (char**) argv); | 973 return tool_main(argc, (char**) argv); |
1005 } | 974 } |
1006 #endif | 975 #endif |
OLD | NEW |