Allow specifying multiple configs for bench, e.g. -config 8888 -config GPU.
Patch courtesy of Guanqun Lu.
http://codereview.appspot.com/6031057/
git-svn-id: http://skia.googlecode.com/svn/trunk@3696 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 7d7a350..8372ec0 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -381,7 +381,8 @@
GLHelper* glHelper = NULL;
const char* configName = "";
Backend backend = kRaster_Backend; // for warning
- int configCount = SK_ARRAY_COUNT(gConfigs);
+ SkTDArray<int> configs;
+ bool userConfig = false;
char* const* stop = argv + argc;
for (++argv; argv < stop; ++argv) {
@@ -486,11 +487,8 @@
if (argv < stop) {
int index = findConfig(*argv);
if (index >= 0) {
- outConfig = gConfigs[index].fConfig;
- configName = gConfigs[index].fName;
- backend = gConfigs[index].fBackend;
- glHelper = gConfigs[index].fGLHelper;
- configCount = 1;
+ *configs.append() = index;
+ userConfig = true;
} else {
SkString str;
str.printf("unrecognized config %s\n", *argv);
@@ -523,6 +521,12 @@
return -1;
}
}
+ if (!userConfig) {
+ // if no config is specified by user, we add them all.
+ for (unsigned int i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
+ *configs.append() = i;
+ }
+ }
// report our current settings
{
@@ -620,13 +624,13 @@
log_progress(str);
}
- for (int configIndex = 0; configIndex < configCount; configIndex++) {
- if (configCount > 1) {
- outConfig = gConfigs[configIndex].fConfig;
- configName = gConfigs[configIndex].fName;
- backend = gConfigs[configIndex].fBackend;
- glHelper = gConfigs[configIndex].fGLHelper;
- }
+ for (int x = 0; x < configs.count(); ++x) {
+ int configIndex = configs[x];
+
+ outConfig = gConfigs[configIndex].fConfig;
+ configName = gConfigs[configIndex].fName;
+ backend = gConfigs[configIndex].fBackend;
+ glHelper = gConfigs[configIndex].fGLHelper;
if (kGPU_Backend == backend &&
(NULL == glHelper || !glHelper->isValid())) {