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 19 matching lines...) Expand all Loading... |
30 #include "SkImageDecoder.h" | 30 #include "SkImageDecoder.h" |
31 #include "SkImageEncoder.h" | 31 #include "SkImageEncoder.h" |
32 #include "SkOSFile.h" | 32 #include "SkOSFile.h" |
33 #include "SkPicture.h" | 33 #include "SkPicture.h" |
34 #include "SkRefCnt.h" | 34 #include "SkRefCnt.h" |
35 #include "SkStream.h" | 35 #include "SkStream.h" |
36 #include "SkTArray.h" | 36 #include "SkTArray.h" |
37 #include "SkTDict.h" | 37 #include "SkTDict.h" |
38 #include "SkTileGridPicture.h" | 38 #include "SkTileGridPicture.h" |
39 #include "SamplePipeControllers.h" | 39 #include "SamplePipeControllers.h" |
40 | 40 #include "ToolUtils.h" |
41 __SK_FORCE_IMAGE_DECODER_LINKING; | |
42 | 41 |
43 #ifdef SK_BUILD_FOR_WIN | 42 #ifdef SK_BUILD_FOR_WIN |
44 // json includes xlocale which generates warning 4530 because we're compilin
g without | 43 // json includes xlocale which generates warning 4530 because we're compilin
g without |
45 // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 | 44 // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 |
46 #pragma warning(push) | 45 #pragma warning(push) |
47 #pragma warning(disable : 4530) | 46 #pragma warning(disable : 4530) |
48 #endif | 47 #endif |
49 #include "json/value.h" | 48 #include "json/value.h" |
50 #ifdef SK_BUILD_FOR_WIN | 49 #ifdef SK_BUILD_FOR_WIN |
51 #pragma warning(pop) | 50 #pragma warning(pop) |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1402 |
1404 static int findConfig(const char config[]) { | 1403 static int findConfig(const char config[]) { |
1405 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 1404 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
1406 if (!strcmp(config, gRec[i].fName)) { | 1405 if (!strcmp(config, gRec[i].fName)) { |
1407 return (int) i; | 1406 return (int) i; |
1408 } | 1407 } |
1409 } | 1408 } |
1410 return -1; | 1409 return -1; |
1411 } | 1410 } |
1412 | 1411 |
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 { | 1412 namespace skiagm { |
1446 #if SK_SUPPORT_GPU | 1413 #if SK_SUPPORT_GPU |
1447 SkAutoTUnref<GrContext> gGrContext; | 1414 SkAutoTUnref<GrContext> gGrContext; |
1448 /** | 1415 /** |
1449 * Sets the global GrContext, accessible by individual GMs | 1416 * Sets the global GrContext, accessible by individual GMs |
1450 */ | 1417 */ |
1451 static void SetGr(GrContext* grContext) { | 1418 static void SetGr(GrContext* grContext) { |
1452 SkSafeRef(grContext); | 1419 SkSafeRef(grContext); |
1453 gGrContext.reset(grContext); | 1420 gGrContext.reset(grContext); |
1454 } | 1421 } |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 SkAutoTDelete<GM> adgm(gm); | 2036 SkAutoTDelete<GM> adgm(gm); |
2070 ++gmIndex; | 2037 ++gmIndex; |
2071 if (moduloRemainder >= 0) { | 2038 if (moduloRemainder >= 0) { |
2072 if ((gmIndex % moduloDivisor) != moduloRemainder) { | 2039 if ((gmIndex % moduloDivisor) != moduloRemainder) { |
2073 continue; | 2040 continue; |
2074 } | 2041 } |
2075 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); | 2042 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); |
2076 } | 2043 } |
2077 | 2044 |
2078 const char* shortName = gm->shortName(); | 2045 const char* shortName = gm->shortName(); |
2079 if (skip_name(FLAGS_match, shortName)) { | 2046 |
| 2047 SkTDArray<const char*> matchStrs; |
| 2048 for (int i = 0; i < FLAGS_match.count(); ++i) { |
| 2049 matchStrs.push(FLAGS_match[i]); |
| 2050 } |
| 2051 if (shouldSkip(matchStrs, shortName)) { |
2080 continue; | 2052 continue; |
2081 } | 2053 } |
2082 | 2054 |
2083 gmsRun++; | 2055 gmsRun++; |
2084 SkISize size = gm->getISize(); | 2056 SkISize size = gm->getISize(); |
2085 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, | 2057 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, |
2086 size.width(), size.height()); | 2058 size.width(), size.height()); |
2087 | 2059 |
2088 run_multiple_configs(gmmain, gm, configs, grFactory); | 2060 run_multiple_configs(gmmain, gm, configs, grFactory); |
2089 | 2061 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 if (FLAGS_forceBWtext) { | 2134 if (FLAGS_forceBWtext) { |
2163 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2135 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2164 } | 2136 } |
2165 } | 2137 } |
2166 | 2138 |
2167 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2139 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2168 int main(int argc, char * const argv[]) { | 2140 int main(int argc, char * const argv[]) { |
2169 return tool_main(argc, (char**) argv); | 2141 return tool_main(argc, (char**) argv); |
2170 } | 2142 } |
2171 #endif | 2143 #endif |
OLD | NEW |