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" | |
26 #include "SkDeferredCanvas.h" | 25 #include "SkDeferredCanvas.h" |
27 #include "SkDevice.h" | 26 #include "SkDevice.h" |
28 #include "SkColorPriv.h" | 27 #include "SkColorPriv.h" |
29 #include "SkGraphics.h" | 28 #include "SkGraphics.h" |
30 #include "SkImageEncoder.h" | 29 #include "SkImageEncoder.h" |
31 #include "SkNWayCanvas.h" | 30 #include "SkNWayCanvas.h" |
32 #include "SkPicture.h" | 31 #include "SkPicture.h" |
33 #include "SkString.h" | 32 #include "SkString.h" |
34 #include "SkTArray.h" | 33 #include "SkTArray.h" |
35 #include "TimerData.h" | 34 #include "TimerData.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 263 |
265 static int findConfig(const char config[]) { | 264 static int findConfig(const char config[]) { |
266 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { | 265 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { |
267 if (!strcmp(config, gConfigs[i].fName)) { | 266 if (!strcmp(config, gConfigs[i].fName)) { |
268 return i; | 267 return i; |
269 } | 268 } |
270 } | 269 } |
271 return -1; | 270 return -1; |
272 } | 271 } |
273 | 272 |
| 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 |
274 static void help() { | 305 static void help() { |
275 SkString configsStr; | 306 SkString configsStr; |
276 static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); | 307 static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); |
277 for (size_t i = 0; i < kConfigCount; ++i) { | 308 for (size_t i = 0; i < kConfigCount; ++i) { |
278 configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ?
"" : "|")); | 309 configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ?
"" : "|")); |
279 } | 310 } |
280 | 311 |
281 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " | 312 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " |
282 "[--timers [wcgWC]*] [--rotate]\n" | 313 "[--timers [wcgWC]*] [--rotate]\n" |
283 " [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0]
\n" | 314 " [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0]
\n" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 | 764 |
734 bench->setForceAlpha(forceAlpha); | 765 bench->setForceAlpha(forceAlpha); |
735 bench->setForceAA(forceAA); | 766 bench->setForceAA(forceAA); |
736 bench->setForceFilter(forceFilter); | 767 bench->setForceFilter(forceFilter); |
737 bench->setDither(forceDither); | 768 bench->setDither(forceDither); |
738 if (hasStrokeWidth) { | 769 if (hasStrokeWidth) { |
739 bench->setStrokeWidth(strokeWidth); | 770 bench->setStrokeWidth(strokeWidth); |
740 } | 771 } |
741 | 772 |
742 // only run benchmarks if their name contains matchStr | 773 // only run benchmarks if their name contains matchStr |
743 if (SkCommandLineFlags::ShouldSkip(fMatches, bench->getName())) { | 774 if (skip_name(fMatches, bench->getName())) { |
744 continue; | 775 continue; |
745 } | 776 } |
746 | 777 |
747 bool loggedBenchStart = false; | 778 bool loggedBenchStart = false; |
748 | 779 |
749 AutoPrePostDraw appd(bench); | 780 AutoPrePostDraw appd(bench); |
750 | 781 |
751 for (int x = 0; x < configs.count(); ++x) { | 782 for (int x = 0; x < configs.count(); ++x) { |
752 int configIndex = configs[x]; | 783 int configIndex = configs[x]; |
753 | 784 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 997 } |
967 | 998 |
968 return 0; | 999 return 0; |
969 } | 1000 } |
970 | 1001 |
971 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1002 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
972 int main(int argc, char * const argv[]) { | 1003 int main(int argc, char * const argv[]) { |
973 return tool_main(argc, (char**) argv); | 1004 return tool_main(argc, (char**) argv); |
974 } | 1005 } |
975 #endif | 1006 #endif |
OLD | NEW |