OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 /* | 8 /* |
9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
10 * | 10 * |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1403 |
1404 static int findConfig(const char config[]) { | 1404 static int findConfig(const char config[]) { |
1405 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 1405 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
1406 if (!strcmp(config, gRec[i].fName)) { | 1406 if (!strcmp(config, gRec[i].fName)) { |
1407 return (int) i; | 1407 return (int) i; |
1408 } | 1408 } |
1409 } | 1409 } |
1410 return -1; | 1410 return -1; |
1411 } | 1411 } |
1412 | 1412 |
1413 static bool skip_name(SkCommandLineFlags::StringArray array, const char name[])
{ | |
1414 // FIXME: this duplicates the logic in test/skia_test.cpp -- consolidate | |
1415 int count = array.count(); | |
1416 size_t testLen = strlen(name); | |
1417 bool anyExclude = count == 0; | |
1418 for (int i = 0; i < array.count(); ++i) { | |
1419 const char* matchName = array[i]; | |
1420 size_t matchLen = strlen(matchName); | |
1421 bool matchExclude, matchStart, matchEnd; | |
1422 if ((matchExclude = matchName[0] == '~')) { | |
1423 anyExclude = true; | |
1424 matchName++; | |
1425 matchLen--; | |
1426 } | |
1427 if ((matchStart = matchName[0] == '^')) { | |
1428 matchName++; | |
1429 matchLen--; | |
1430 } | |
1431 if ((matchEnd = matchName[matchLen - 1] == '$')) { | |
1432 matchLen--; | |
1433 } | |
1434 if (matchStart ? (!matchEnd || matchLen == testLen) | |
1435 && strncmp(name, matchName, matchLen) == 0 | |
1436 : matchEnd ? matchLen <= testLen | |
1437 && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 | |
1438 : strstr(name, matchName) != 0) { | |
1439 return matchExclude; | |
1440 } | |
1441 } | |
1442 return !anyExclude; | |
1443 } | |
1444 | |
1445 namespace skiagm { | 1413 namespace skiagm { |
1446 #if SK_SUPPORT_GPU | 1414 #if SK_SUPPORT_GPU |
1447 SkAutoTUnref<GrContext> gGrContext; | 1415 SkAutoTUnref<GrContext> gGrContext; |
1448 /** | 1416 /** |
1449 * Sets the global GrContext, accessible by individual GMs | 1417 * Sets the global GrContext, accessible by individual GMs |
1450 */ | 1418 */ |
1451 static void SetGr(GrContext* grContext) { | 1419 static void SetGr(GrContext* grContext) { |
1452 SkSafeRef(grContext); | 1420 SkSafeRef(grContext); |
1453 gGrContext.reset(grContext); | 1421 gGrContext.reset(grContext); |
1454 } | 1422 } |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 SkAutoTDelete<GM> adgm(gm); | 2037 SkAutoTDelete<GM> adgm(gm); |
2070 ++gmIndex; | 2038 ++gmIndex; |
2071 if (moduloRemainder >= 0) { | 2039 if (moduloRemainder >= 0) { |
2072 if ((gmIndex % moduloDivisor) != moduloRemainder) { | 2040 if ((gmIndex % moduloDivisor) != moduloRemainder) { |
2073 continue; | 2041 continue; |
2074 } | 2042 } |
2075 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); | 2043 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); |
2076 } | 2044 } |
2077 | 2045 |
2078 const char* shortName = gm->shortName(); | 2046 const char* shortName = gm->shortName(); |
2079 if (skip_name(FLAGS_match, shortName)) { | 2047 |
| 2048 SkTDArray<const char*> matchStrs; |
| 2049 for (int i = 0; i < FLAGS_match.count(); ++i) { |
| 2050 matchStrs.push(FLAGS_match[i]); |
| 2051 } |
| 2052 if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { |
2080 continue; | 2053 continue; |
2081 } | 2054 } |
2082 | 2055 |
2083 gmsRun++; | 2056 gmsRun++; |
2084 SkISize size = gm->getISize(); | 2057 SkISize size = gm->getISize(); |
2085 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, | 2058 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, |
2086 size.width(), size.height()); | 2059 size.width(), size.height()); |
2087 | 2060 |
2088 run_multiple_configs(gmmain, gm, configs, grFactory); | 2061 run_multiple_configs(gmmain, gm, configs, grFactory); |
2089 | 2062 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 if (FLAGS_forceBWtext) { | 2135 if (FLAGS_forceBWtext) { |
2163 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2136 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2164 } | 2137 } |
2165 } | 2138 } |
2166 | 2139 |
2167 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2140 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2168 int main(int argc, char * const argv[]) { | 2141 int main(int argc, char * const argv[]) { |
2169 return tool_main(argc, (char**) argv); | 2142 return tool_main(argc, (char**) argv); |
2170 } | 2143 } |
2171 #endif | 2144 #endif |
OLD | NEW |