Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 #include "SkGPipe.h" | 29 #include "SkGPipe.h" |
| 30 #include "SkGraphics.h" | 30 #include "SkGraphics.h" |
| 31 #include "SkImageDecoder.h" | 31 #include "SkImageDecoder.h" |
| 32 #include "SkImageEncoder.h" | 32 #include "SkImageEncoder.h" |
| 33 #include "SkOSFile.h" | 33 #include "SkOSFile.h" |
| 34 #include "SkPDFRasterizer.h" | 34 #include "SkPDFRasterizer.h" |
| 35 #include "SkPicture.h" | 35 #include "SkPicture.h" |
| 36 #include "SkRefCnt.h" | 36 #include "SkRefCnt.h" |
| 37 #include "SkScalar.h" | 37 #include "SkScalar.h" |
| 38 #include "SkStream.h" | 38 #include "SkStream.h" |
| 39 #include "SkString.h" | |
| 39 #include "SkTArray.h" | 40 #include "SkTArray.h" |
| 40 #include "SkTDict.h" | 41 #include "SkTDict.h" |
| 41 #include "SkTileGridPicture.h" | 42 #include "SkTileGridPicture.h" |
| 42 #include "SamplePipeControllers.h" | 43 #include "SamplePipeControllers.h" |
| 43 | 44 |
| 44 #ifdef SK_DEBUG | 45 #ifdef SK_DEBUG |
| 45 static const bool kDebugOnly = true; | 46 static const bool kDebugOnly = true; |
| 46 #else | 47 #else |
| 47 static const bool kDebugOnly = false; | 48 static const bool kDebugOnly = false; |
| 48 #endif | 49 #endif |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1414 #if SK_SUPPORT_GPU | 1415 #if SK_SUPPORT_GPU |
| 1415 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " | 1416 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " |
| 1416 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " | 1417 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " |
| 1417 "use the default. 0 for either disables the cache."); | 1418 "use the default. 0 for either disables the cache."); |
| 1418 #endif | 1419 #endif |
| 1419 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " | 1420 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " |
| 1420 "when reading/writing files."); | 1421 "when reading/writing files."); |
| 1421 DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str( ), | 1422 DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str( ), |
| 1422 "Space-separated list of ErrorTypes that should be ignored. If any *other* error " | 1423 "Space-separated list of ErrorTypes that should be ignored. If any *other* error " |
| 1423 "types are encountered, the tool will exit with a nonzero return v alue."); | 1424 "types are encountered, the tool will exit with a nonzero return v alue."); |
| 1425 DEFINE_string(ignoreFailuresFile, "", "Path to file containing a list of tests f or which we " | |
| 1426 "should ignore failures.\n" | |
| 1427 "The file should list one test per line, except for comment lines starting with #"); | |
| 1424 DEFINE_string(ignoreTests, "", "Space delimited list of tests for which we shoul d ignore " | 1428 DEFINE_string(ignoreTests, "", "Space delimited list of tests for which we shoul d ignore " |
| 1425 "failures."); | 1429 "failures.\n" |
| 1430 "DEPRECATED in favor of --ignoreFailuresFile; see bug 1730"); | |
| 1426 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" | 1431 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" |
| 1427 "Multiple matches may be separated by spaces.\n" | 1432 "Multiple matches may be separated by spaces.\n" |
| 1428 "~ causes a matching test to always be skipped\n" | 1433 "~ causes a matching test to always be skipped\n" |
| 1429 "^ requires the start of the test to match\n" | 1434 "^ requires the start of the test to match\n" |
| 1430 "$ requires the end of the test to match\n" | 1435 "$ requires the end of the test to match\n" |
| 1431 "^ and $ requires an exact match\n" | 1436 "^ and $ requires an exact match\n" |
| 1432 "If a test does not match any list entry,\n" | 1437 "If a test does not match any list entry,\n" |
| 1433 "it is skipped unless some list entry starts with ~"); | 1438 "it is skipped unless some list entry starts with ~"); |
| 1434 DEFINE_string(missingExpectationsPath, "", "Write images for tests without expec tations " | 1439 DEFINE_string(missingExpectationsPath, "", "Write images for tests without expec tations " |
| 1435 "into this directory."); | 1440 "into this directory."); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1773 FLAGS_simulatePipePlayba ckFailure)); | 1778 FLAGS_simulatePipePlayba ckFailure)); |
| 1774 if (FLAGS_tiledPipe) { | 1779 if (FLAGS_tiledPipe) { |
| 1775 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, | 1780 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, |
| 1776 comparisonBitm ap)); | 1781 comparisonBitm ap)); |
| 1777 } | 1782 } |
| 1778 } | 1783 } |
| 1779 return errorsForAllModes; | 1784 return errorsForAllModes; |
| 1780 } | 1785 } |
| 1781 | 1786 |
| 1782 /** | 1787 /** |
| 1788 * Read individual lines from a file, pushing them into the given array. | |
| 1789 * | |
| 1790 * @param filename path to the file to read | |
| 1791 * @param lines array of strings to add the lines to | |
| 1792 * @returns true if able to read lines from the file | |
| 1793 */ | |
| 1794 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines ) { | |
| 1795 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); | |
| 1796 SkStream *stream = streamWrapper.get(); | |
| 1797 if (!stream) { | |
| 1798 gm_fprintf(stderr, "unable to read file '%s'\n", filename); | |
| 1799 return false; | |
| 1800 } | |
| 1801 | |
| 1802 char c; | |
| 1803 SkString line; | |
| 1804 while (1 == stream->read(&c, 1)) { | |
| 1805 // If we hit either CR or LF, we've completed a line. | |
| 1806 // | |
| 1807 // TODO: If the file uses both CR and LF, this will return an extra blan k | |
| 1808 // line for each line of the file. Which is OK for current purposes... | |
| 1809 // | |
| 1810 // TODO: Does this properly handle unicode? It doesn't matter for | |
| 1811 // current purposes... | |
| 1812 if ((c == 0x0d) || (c == 0x0a)) { | |
| 1813 lines.push_back(line); | |
| 1814 line.reset(); | |
| 1815 } else { | |
| 1816 line.append(&c, 1); | |
| 1817 } | |
| 1818 } | |
| 1819 lines.push_back(line); | |
| 1820 return true; | |
| 1821 } | |
| 1822 | |
| 1823 /** | |
| 1783 * Return a list of all entries in an array of strings as a single string | 1824 * Return a list of all entries in an array of strings as a single string |
| 1784 * of this form: | 1825 * of this form: |
| 1785 * "item1", "item2", "item3" | 1826 * "item1", "item2", "item3" |
| 1786 */ | 1827 */ |
| 1787 SkString list_all(const SkTArray<SkString> &stringArray); | 1828 SkString list_all(const SkTArray<SkString> &stringArray); |
| 1788 SkString list_all(const SkTArray<SkString> &stringArray) { | 1829 SkString list_all(const SkTArray<SkString> &stringArray) { |
| 1789 SkString total; | 1830 SkString total; |
| 1790 for (int i = 0; i < stringArray.count(); i++) { | 1831 for (int i = 0; i < stringArray.count(); i++) { |
| 1791 if (i > 0) { | 1832 if (i > 0) { |
| 1792 total.append(", "); | 1833 total.append(", "); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2013 } | 2054 } |
| 2014 return true; | 2055 return true; |
| 2015 } | 2056 } |
| 2016 | 2057 |
| 2017 /** | 2058 /** |
| 2018 * Replace contents of ignoreTestSubstrings with a list of testname/config subst rings, indicating | 2059 * Replace contents of ignoreTestSubstrings with a list of testname/config subst rings, indicating |
| 2019 * which tests' failures should be ignored. | 2060 * which tests' failures should be ignored. |
| 2020 */ | 2061 */ |
| 2021 static bool parse_flags_ignore_tests(SkTArray<SkString> &ignoreTestSubstrings) { | 2062 static bool parse_flags_ignore_tests(SkTArray<SkString> &ignoreTestSubstrings) { |
| 2022 ignoreTestSubstrings.reset(); | 2063 ignoreTestSubstrings.reset(); |
| 2023 for (int i = 0; i < FLAGS_ignoreTests.count(); i++) { | 2064 |
| 2024 ignoreTestSubstrings.push_back(SkString(FLAGS_ignoreTests[i])); | 2065 // Parse --ignoreTests |
| 2066 if (FLAGS_ignoreTests.count() > 0) { | |
| 2067 gm_fprintf(stderr, "you are using deprecated --ignoreTests flag\n"); | |
|
epoger
2013/10/18 14:52:49
Leon- I realized that, since I hadn't committed th
scroggo
2013/10/18 14:54:53
Perfect. Thanks!
| |
| 2068 for (int i = 0; i < FLAGS_ignoreTests.count(); i++) { | |
| 2069 ignoreTestSubstrings.push_back(SkString(FLAGS_ignoreTests[i])); | |
| 2070 } | |
| 2025 } | 2071 } |
| 2072 | |
| 2073 // Parse --ignoreFailuresFile | |
| 2074 for (int i = 0; i < FLAGS_ignoreFailuresFile.count(); i++) { | |
| 2075 SkTArray<SkString> linesFromFile; | |
| 2076 if (!read_lines_from_file(FLAGS_ignoreFailuresFile[i], linesFromFile)) { | |
| 2077 return false; | |
| 2078 } else { | |
| 2079 for (int j = 0; j < linesFromFile.count(); j++) { | |
| 2080 SkString thisLine = linesFromFile[j]; | |
| 2081 if (thisLine.isEmpty() || thisLine.startsWith('#')) { | |
| 2082 // skip this line | |
| 2083 } else { | |
| 2084 ignoreTestSubstrings.push_back(thisLine); | |
| 2085 } | |
| 2086 } | |
| 2087 } | |
| 2088 } | |
| 2089 | |
| 2026 return true; | 2090 return true; |
| 2027 } | 2091 } |
| 2028 | 2092 |
| 2029 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { | 2093 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { |
| 2030 if (FLAGS_modulo.count() == 2) { | 2094 if (FLAGS_modulo.count() == 2) { |
| 2031 *moduloRemainder = atoi(FLAGS_modulo[0]); | 2095 *moduloRemainder = atoi(FLAGS_modulo[0]); |
| 2032 *moduloDivisor = atoi(FLAGS_modulo[1]); | 2096 *moduloDivisor = atoi(FLAGS_modulo[1]); |
| 2033 if (*moduloRemainder < 0 || *moduloDivisor <= 0 || | 2097 if (*moduloRemainder < 0 || *moduloDivisor <= 0 || |
| 2034 *moduloRemainder >= *moduloDivisor) { | 2098 *moduloRemainder >= *moduloDivisor) { |
| 2035 gm_fprintf(stderr, "invalid modulo values."); | 2099 gm_fprintf(stderr, "invalid modulo values."); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2322 if (FLAGS_forceBWtext) { | 2386 if (FLAGS_forceBWtext) { |
| 2323 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2387 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2324 } | 2388 } |
| 2325 } | 2389 } |
| 2326 | 2390 |
| 2327 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2391 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2328 int main(int argc, char * const argv[]) { | 2392 int main(int argc, char * const argv[]) { |
| 2329 return tool_main(argc, (char**) argv); | 2393 return tool_main(argc, (char**) argv); |
| 2330 } | 2394 } |
| 2331 #endif | 2395 #endif |
| OLD | NEW |