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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1760 SkString subdir; | 1760 SkString subdir; |
| 1761 subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName); | 1761 subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName); |
| 1762 if (!sk_mkdir(subdir.c_str())) { | 1762 if (!sk_mkdir(subdir.c_str())) { |
| 1763 return false; | 1763 return false; |
| 1764 } | 1764 } |
| 1765 } | 1765 } |
| 1766 } | 1766 } |
| 1767 return true; | 1767 return true; |
| 1768 } | 1768 } |
| 1769 | 1769 |
| 1770 int tool_main(int argc, char** argv); | 1770 bool parse_flags_configs(SkTDArray<size_t>* outConfigs, |
|
edisonn
2013/08/02 12:32:41
static
ducky
2013/08/02 18:14:38
Fixed as of latest patchset last night, after I re
| |
| 1771 int tool_main(int argc, char** argv) { | 1771 GrContextFactory* grFactory) { |
| 1772 | |
| 1773 #if SK_ENABLE_INST_COUNT | |
| 1774 gPrintInstCount = true; | |
| 1775 #endif | |
| 1776 | |
| 1777 SkGraphics::Init(); | |
| 1778 // we don't need to see this during a run | |
| 1779 gSkSuppressFontCachePurgeSpew = true; | |
| 1780 | |
| 1781 setSystemPreferences(); | |
| 1782 GMMain gmmain; | |
| 1783 | |
| 1784 SkTDArray<size_t> configs; | |
| 1785 SkTDArray<size_t> excludeConfigs; | 1772 SkTDArray<size_t> excludeConfigs; |
| 1786 bool userConfig = false; | |
| 1787 | |
| 1788 SkString usage; | |
| 1789 usage.printf("Run the golden master tests.\n"); | |
| 1790 SkCommandLineFlags::SetUsage(usage.c_str()); | |
| 1791 SkCommandLineFlags::Parse(argc, argv); | |
| 1792 | |
| 1793 gmmain.fUseFileHierarchy = FLAGS_hierarchy; | |
| 1794 gmmain.fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames; | |
| 1795 if (FLAGS_mismatchPath.count() == 1) { | |
| 1796 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; | |
| 1797 } | |
| 1798 if (FLAGS_missingExpectationsPath.count() == 1) { | |
| 1799 gmmain.fMissingExpectationsPath = FLAGS_missingExpectationsPath[0]; | |
| 1800 } | |
| 1801 | 1773 |
| 1802 for (int i = 0; i < FLAGS_config.count(); i++) { | 1774 for (int i = 0; i < FLAGS_config.count(); i++) { |
| 1803 const char* config = FLAGS_config[i]; | 1775 const char* config = FLAGS_config[i]; |
| 1804 userConfig = true; | |
| 1805 bool exclude = false; | 1776 bool exclude = false; |
| 1806 if (*config == kExcludeConfigChar) { | 1777 if (*config == kExcludeConfigChar) { |
| 1807 exclude = true; | 1778 exclude = true; |
| 1808 config += 1; | 1779 config += 1; |
| 1809 } | 1780 } |
| 1810 int index = findConfig(config); | 1781 int index = findConfig(config); |
| 1811 if (index >= 0) { | 1782 if (index >= 0) { |
| 1812 if (exclude) { | 1783 if (exclude) { |
| 1813 *excludeConfigs.append() = index; | 1784 *excludeConfigs.append() = index; |
| 1814 } else { | 1785 } else { |
| 1815 appendUnique<size_t>(&configs, index); | 1786 appendUnique<size_t>(outConfigs, index); |
| 1816 } | 1787 } |
| 1817 } else if (0 == strcmp(kDefaultsConfigStr, config)) { | 1788 } else if (0 == strcmp(kDefaultsConfigStr, config)) { |
| 1789 if (exclude) { | |
| 1790 gm_fprintf(stderr, "%c%s is not allowed.\n", | |
| 1791 kExcludeConfigChar, kDefaultsConfigStr); | |
| 1792 return false; | |
| 1793 } | |
| 1818 for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) { | 1794 for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) { |
| 1819 if (gRec[c].fRunByDefault) { | 1795 if (gRec[c].fRunByDefault) { |
| 1820 if (exclude) { | 1796 appendUnique<size_t>(outConfigs, c); |
| 1821 gm_fprintf(stderr, "%c%s is not allowed.\n", | |
| 1822 kExcludeConfigChar, kDefaultsConfigStr); | |
| 1823 return -1; | |
| 1824 } else { | |
| 1825 appendUnique<size_t>(&configs, c); | |
| 1826 } | |
| 1827 } | 1797 } |
| 1828 } | 1798 } |
| 1829 } else { | 1799 } else { |
| 1830 gm_fprintf(stderr, "unrecognized config %s\n", config); | 1800 gm_fprintf(stderr, "unrecognized config %s\n", config); |
| 1831 return -1; | 1801 return false; |
| 1832 } | 1802 } |
| 1833 } | 1803 } |
| 1834 | 1804 |
| 1835 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { | 1805 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { |
| 1836 int index = findConfig(FLAGS_excludeConfig[i]); | 1806 int index = findConfig(FLAGS_excludeConfig[i]); |
| 1837 if (index >= 0) { | 1807 if (index >= 0) { |
| 1838 *excludeConfigs.append() = index; | 1808 *excludeConfigs.append() = index; |
| 1839 } else { | 1809 } else { |
| 1840 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]); | 1810 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]); |
| 1841 return -1; | 1811 return false; |
| 1842 } | 1812 } |
| 1843 } | 1813 } |
| 1844 | 1814 |
| 1845 int moduloRemainder = -1; | 1815 if (outConfigs->count() == 0) { |
| 1846 int moduloDivisor = -1; | 1816 // if no config is specified by user, add the defaults |
| 1847 | 1817 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1848 if (FLAGS_modulo.count() == 2) { | 1818 if (gRec[i].fRunByDefault) { |
| 1849 moduloRemainder = atoi(FLAGS_modulo[0]); | 1819 *outConfigs->append() = i; |
| 1850 moduloDivisor = atoi(FLAGS_modulo[1]); | 1820 } |
| 1851 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { | 1821 } |
| 1852 gm_fprintf(stderr, "invalid modulo values."); | 1822 } |
| 1853 return -1; | 1823 // now remove any explicitly excluded configs |
| 1854 } | 1824 for (int i = 0; i < excludeConfigs.count(); ++i) { |
| 1855 } | 1825 int index = outConfigs->find(excludeConfigs[i]); |
| 1856 | 1826 if (index >= 0) { |
| 1827 outConfigs->remove(index); | |
| 1828 // now assert that there was only one copy in configs[] | |
| 1829 SkASSERT(outConfigs->find(excludeConfigs[i]) < 0); | |
| 1830 } | |
| 1831 } | |
| 1832 | |
| 1833 if (grFactory != NULL) { | |
| 1834 for (int i = 0; i < outConfigs->count(); ++i) { | |
| 1835 size_t index = (*outConfigs)[i]; | |
| 1836 if (kGPU_Backend == gRec[index].fBackend) { | |
| 1837 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); | |
| 1838 if (NULL == ctx) { | |
| 1839 gm_fprintf(stderr, "GrContext could not be created for confi g %s." | |
| 1840 " Config will be skipped.\n", gRec[index].fName); | |
| 1841 outConfigs->remove(i); | |
| 1842 --i; | |
| 1843 continue; | |
| 1844 } | |
| 1845 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { | |
| 1846 gm_fprintf(stderr, "Sample count (%d) of config %s is not su pported." | |
| 1847 " Config will be skipped.\n", | |
| 1848 gRec[index].fSampleCnt, gRec[index].fName); | |
| 1849 outConfigs->remove(i); | |
| 1850 --i; | |
| 1851 } | |
| 1852 } | |
| 1853 } | |
| 1854 } | |
| 1855 | |
| 1856 if (outConfigs->isEmpty()) { | |
| 1857 gm_fprintf(stderr, "No configs to run."); | |
| 1858 return false; | |
| 1859 } | |
| 1860 | |
| 1861 // now show the user the set of configs that will be run. | |
| 1862 SkString configStr("These configs will be run: "); | |
| 1863 // show the user the config that will run. | |
| 1864 for (int i = 0; i < outConfigs->count(); ++i) { | |
| 1865 configStr.appendf("%s%s", gRec[(*outConfigs)[i]].fName, | |
| 1866 (i == outConfigs->count() - 1) ? "\n" : " "); | |
|
edisonn
2013/08/02 12:32:41
make it (i < outConfigs->count()) ? " " : "");
an
ducky
2013/08/02 18:14:38
Done. It now just adds a space all the time, since
| |
| 1867 } | |
| 1868 gm_fprintf(stdout, "%s", configStr.c_str()); | |
| 1869 | |
| 1870 return true; | |
| 1871 } | |
| 1872 | |
| 1873 bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { | |
|
edisonn
2013/08/02 12:32:41
static
ducky
2013/08/02 18:14:38
Done.
| |
| 1857 if (FLAGS_ignoreErrorTypes.count() > 0) { | 1874 if (FLAGS_ignoreErrorTypes.count() > 0) { |
| 1858 gmmain.fIgnorableErrorTypes = ErrorCombination(); | 1875 *outErrorTypes = ErrorCombination(); |
| 1859 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { | 1876 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { |
| 1860 ErrorType type; | 1877 ErrorType type; |
| 1861 const char *name = FLAGS_ignoreErrorTypes[i]; | 1878 const char *name = FLAGS_ignoreErrorTypes[i]; |
| 1862 if (!getErrorTypeByName(name, &type)) { | 1879 if (!getErrorTypeByName(name, &type)) { |
| 1863 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); | 1880 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); |
| 1864 return -1; | 1881 return false; |
| 1865 } else { | 1882 } else { |
| 1866 gmmain.fIgnorableErrorTypes.add(type); | 1883 outErrorTypes->add(type); |
| 1867 } | 1884 } |
| 1868 } | 1885 } |
| 1869 } | 1886 } |
| 1870 | 1887 return true; |
| 1871 #if SK_SUPPORT_GPU | 1888 } |
| 1889 | |
| 1890 bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { | |
|
edisonn
2013/08/02 12:32:41
make it static, otherwise you might get a warning
ducky
2013/08/02 18:14:38
Done.
| |
| 1891 if (FLAGS_modulo.count() == 2) { | |
| 1892 *moduloRemainder = atoi(FLAGS_modulo[0]); | |
| 1893 *moduloDivisor = atoi(FLAGS_modulo[1]); | |
| 1894 if (*moduloRemainder < 0 || *moduloDivisor <= 0 || | |
| 1895 *moduloRemainder >= *moduloDivisor) { | |
| 1896 gm_fprintf(stderr, "invalid modulo values."); | |
| 1897 return false; | |
| 1898 } | |
| 1899 } | |
| 1900 return true; | |
| 1901 } | |
| 1902 | |
| 1903 bool parse_flags_gpu_cache(int* sizeBytes, int* sizeCount) { | |
|
edisonn
2013/08/02 12:32:41
static
ducky
2013/08/02 18:14:38
Done.
| |
| 1872 if (FLAGS_gpuCacheSize.count() > 0) { | 1904 if (FLAGS_gpuCacheSize.count() > 0) { |
| 1873 if (FLAGS_gpuCacheSize.count() != 2) { | 1905 if (FLAGS_gpuCacheSize.count() != 2) { |
| 1874 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | 1906 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); |
| 1875 return -1; | 1907 return false; |
| 1876 } | 1908 } |
| 1877 gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]); | 1909 *sizeBytes = atoi(FLAGS_gpuCacheSize[0]); |
| 1878 gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]); | 1910 *sizeCount = atoi(FLAGS_gpuCacheSize[1]); |
| 1879 } else { | 1911 } else { |
| 1880 gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE; | 1912 *sizeBytes = DEFAULT_CACHE_VALUE; |
| 1881 gGpuCacheSizeCount = DEFAULT_CACHE_VALUE; | 1913 *sizeCount = DEFAULT_CACHE_VALUE; |
| 1882 } | 1914 } |
| 1883 #endif | 1915 return true; |
| 1884 | 1916 } |
| 1885 SkTDArray<SkScalar> tileGridReplayScales; | 1917 |
| 1886 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | 1918 bool parse_tile_grid_replay_scales(SkTDArray<SkScalar>* outScales) { |
|
edisonn
2013/08/02 12:32:41
static
ducky
2013/08/02 18:14:38
Done.
| |
| 1919 *outScales->append() = SK_Scalar1; // By default only test at scale 1.0 | |
| 1887 if (FLAGS_tileGridReplayScales.count() > 0) { | 1920 if (FLAGS_tileGridReplayScales.count() > 0) { |
| 1888 tileGridReplayScales.reset(); | 1921 outScales->reset(); |
| 1889 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | 1922 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { |
| 1890 double val = atof(FLAGS_tileGridReplayScales[i]); | 1923 double val = atof(FLAGS_tileGridReplayScales[i]); |
| 1891 if (0 < val) { | 1924 if (0 < val) { |
| 1892 *tileGridReplayScales.append() = SkDoubleToScalar(val); | 1925 *outScales->append() = SkDoubleToScalar(val); |
| 1893 } | 1926 } |
| 1894 } | 1927 } |
| 1895 if (0 == tileGridReplayScales.count()) { | 1928 if (0 == outScales->count()) { |
| 1896 // Should have at least one scale | 1929 // Should have at least one scale |
| 1897 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); | 1930 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); |
| 1898 return -1; | 1931 return false; |
| 1899 } | 1932 } |
| 1900 } | 1933 } |
| 1901 | 1934 return true; |
| 1902 if (!userConfig) { | 1935 } |
| 1903 // if no config is specified by user, add the defaults | 1936 |
| 1904 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1937 bool parse_read_path(SkAutoTUnref<ExpectationsSource>* source) { |
|
edisonn
2013/08/02 12:32:41
static
ducky
2013/08/02 18:14:38
Done.
| |
| 1905 if (gRec[i].fRunByDefault) { | |
| 1906 *configs.append() = i; | |
| 1907 } | |
| 1908 } | |
| 1909 } | |
| 1910 // now remove any explicitly excluded configs | |
| 1911 for (int i = 0; i < excludeConfigs.count(); ++i) { | |
| 1912 int index = configs.find(excludeConfigs[i]); | |
| 1913 if (index >= 0) { | |
| 1914 configs.remove(index); | |
| 1915 // now assert that there was only one copy in configs[] | |
| 1916 SkASSERT(configs.find(excludeConfigs[i]) < 0); | |
| 1917 } | |
| 1918 } | |
| 1919 | |
| 1920 #if SK_SUPPORT_GPU | |
| 1921 GrContextFactory* grFactory = new GrContextFactory; | |
| 1922 for (int i = 0; i < configs.count(); ++i) { | |
| 1923 size_t index = configs[i]; | |
| 1924 if (kGPU_Backend == gRec[index].fBackend) { | |
| 1925 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); | |
| 1926 if (NULL == ctx) { | |
| 1927 gm_fprintf(stderr, "GrContext could not be created for config %s ." | |
| 1928 " Config will be skipped.\n", gRec[index].fName); | |
| 1929 configs.remove(i); | |
| 1930 --i; | |
| 1931 continue; | |
| 1932 } | |
| 1933 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { | |
| 1934 gm_fprintf(stderr, "Sample count (%d) of config %s is not suppor ted." | |
| 1935 " Config will be skipped.\n", gRec[index].fSampleCnt, gRec[index].fName); | |
| 1936 configs.remove(i); | |
| 1937 --i; | |
| 1938 } | |
| 1939 } | |
| 1940 } | |
| 1941 #else | |
| 1942 GrContextFactory* grFactory = NULL; | |
| 1943 #endif | |
| 1944 | |
| 1945 if (configs.isEmpty()) { | |
| 1946 gm_fprintf(stderr, "No configs to run."); | |
| 1947 return -1; | |
| 1948 } | |
| 1949 | |
| 1950 // now show the user the set of configs that will be run. | |
| 1951 SkString configStr("These configs will be run: "); | |
| 1952 // show the user the config that will run. | |
| 1953 for (int i = 0; i < configs.count(); ++i) { | |
| 1954 configStr.appendf("%s%s", gRec[configs[i]].fName, (i == configs.count() - 1) ? "\n" : " "); | |
| 1955 } | |
| 1956 gm_fprintf(stdout, "%s", configStr.c_str()); | |
| 1957 | |
| 1958 if (FLAGS_resourcePath.count() == 1) { | |
| 1959 GM::SetResourcePath(FLAGS_resourcePath[0]); | |
| 1960 } | |
| 1961 | |
| 1962 if (FLAGS_readPath.count() == 1) { | 1938 if (FLAGS_readPath.count() == 1) { |
| 1963 const char* readPath = FLAGS_readPath[0]; | 1939 const char* readPath = FLAGS_readPath[0]; |
| 1964 if (!sk_exists(readPath)) { | 1940 if (!sk_exists(readPath)) { |
| 1965 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 1941 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); |
| 1966 return -1; | 1942 return false; |
| 1967 } | 1943 } |
| 1968 if (sk_isdir(readPath)) { | 1944 if (sk_isdir(readPath)) { |
| 1969 if (FLAGS_verbose) { | 1945 if (FLAGS_verbose) { |
| 1970 gm_fprintf(stdout, "reading from %s\n", readPath); | 1946 gm_fprintf(stdout, "reading from %s\n", readPath); |
| 1971 } | 1947 } |
| 1972 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1948 source->reset(SkNEW_ARGS( |
| 1973 IndividualImageExpectationsSource, (readPath))); | 1949 IndividualImageExpectationsSource, (readPath))); |
| 1974 } else { | 1950 } else { |
| 1975 if (FLAGS_verbose) { | 1951 if (FLAGS_verbose) { |
| 1976 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath); | 1952 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath); |
| 1977 } | 1953 } |
| 1978 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1954 source->reset(SkNEW_ARGS(JsonExpectationsSource, (readPath))); |
| 1979 JsonExpectationsSource, (readPath))); | 1955 } |
| 1980 } | 1956 } |
| 1981 } | 1957 return true; |
| 1958 } | |
| 1959 | |
| 1960 bool parse_match_strs(SkTDArray<const char*>* matchStrs) { | |
|
edisonn
2013/08/02 12:32:41
static
ducky
2013/08/02 18:14:38
Done.
| |
| 1961 for (int i = 0; i < FLAGS_match.count(); ++i) { | |
| 1962 matchStrs->push(FLAGS_match[i]); | |
| 1963 } | |
| 1964 return true; | |
| 1965 } | |
| 1966 | |
| 1967 int tool_main(int argc, char** argv); | |
| 1968 int tool_main(int argc, char** argv) { | |
| 1969 | |
| 1970 #if SK_ENABLE_INST_COUNT | |
| 1971 gPrintInstCount = true; | |
| 1972 #endif | |
| 1973 | |
| 1974 SkGraphics::Init(); | |
| 1975 // we don't need to see this during a run | |
| 1976 gSkSuppressFontCachePurgeSpew = true; | |
| 1977 | |
| 1978 setSystemPreferences(); | |
| 1979 GMMain gmmain; | |
| 1980 | |
| 1981 SkString usage; | |
| 1982 usage.printf("Run the golden master tests.\n"); | |
| 1983 SkCommandLineFlags::SetUsage(usage.c_str()); | |
| 1984 SkCommandLineFlags::Parse(argc, argv); | |
| 1985 | |
| 1986 gmmain.fUseFileHierarchy = FLAGS_hierarchy; | |
| 1987 gmmain.fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames; | |
| 1988 if (FLAGS_mismatchPath.count() == 1) { | |
| 1989 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; | |
| 1990 } | |
| 1991 if (FLAGS_missingExpectationsPath.count() == 1) { | |
| 1992 gmmain.fMissingExpectationsPath = FLAGS_missingExpectationsPath[0]; | |
| 1993 } | |
| 1994 | |
| 1995 SkTDArray<size_t> configs; | |
| 1996 int moduloRemainder = -1, moduloDivisor = -1; | |
| 1997 SkTDArray<SkScalar> tileGridReplayScales; | |
| 1998 #if SK_SUPPORT_GPU | |
| 1999 GrContextFactory* grFactory = new GrContextFactory; | |
| 2000 #else | |
| 2001 GrContextFactory* grFactory = NULL; | |
| 2002 #endif | |
| 2003 SkTDArray<const char*> matchStrs; | |
| 2004 | |
| 2005 if (!parse_flags_configs(&configs, grFactory) || | |
| 2006 !parse_flags_ignore_error_types(&(gmmain.fIgnorableErrorTypes)) || | |
| 2007 !parse_flags_modulo(&moduloRemainder, &moduloDivisor) || | |
| 2008 #if SK_SUPPORT_GPU | |
| 2009 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || | |
| 2010 #endif | |
| 2011 !parse_tile_grid_replay_scales(&tileGridReplayScales) || | |
| 2012 !parse_read_path(&gmmain.fExpectationsSource) || | |
| 2013 !parse_match_strs(&matchStrs)) { | |
| 2014 return -1; | |
| 2015 } | |
| 2016 | |
| 2017 if (FLAGS_resourcePath.count() == 1) { | |
| 2018 GM::SetResourcePath(FLAGS_resourcePath[0]); | |
| 2019 } | |
| 2020 | |
| 1982 if (FLAGS_verbose) { | 2021 if (FLAGS_verbose) { |
| 1983 if (FLAGS_writePath.count() == 1) { | 2022 if (FLAGS_writePath.count() == 1) { |
| 1984 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); | 2023 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); |
| 1985 } | 2024 } |
| 1986 if (NULL != gmmain.fMismatchPath) { | 2025 if (NULL != gmmain.fMismatchPath) { |
| 1987 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat h); | 2026 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat h); |
| 1988 } | 2027 } |
| 1989 if (NULL != gmmain.fMissingExpectationsPath) { | 2028 if (NULL != gmmain.fMissingExpectationsPath) { |
| 1990 gm_fprintf(stdout, "writing images without expectations to %s\n", | 2029 gm_fprintf(stdout, "writing images without expectations to %s\n", |
| 1991 gmmain.fMissingExpectationsPath); | 2030 gmmain.fMissingExpectationsPath); |
| 1992 } | 2031 } |
| 1993 if (FLAGS_writePicturePath.count() == 1) { | 2032 if (FLAGS_writePicturePath.count() == 1) { |
| 1994 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat h[0]); | 2033 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat h[0]); |
| 1995 } | 2034 } |
| 1996 if (FLAGS_resourcePath.count() == 1) { | 2035 if (FLAGS_resourcePath.count() == 1) { |
| 1997 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath [0]); | 2036 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath [0]); |
| 1998 } | 2037 } |
| 1999 } | 2038 } |
| 2000 | 2039 |
| 2001 if (moduloDivisor <= 0) { | |
| 2002 moduloRemainder = -1; | |
| 2003 } | |
| 2004 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { | |
| 2005 moduloRemainder = -1; | |
| 2006 } | |
| 2007 | |
| 2008 int gmsRun = 0; | 2040 int gmsRun = 0; |
| 2009 int gmIndex = -1; | 2041 int gmIndex = -1; |
| 2010 SkString moduloStr; | 2042 SkString moduloStr; |
| 2011 | 2043 |
| 2012 // If we will be writing out files, prepare subdirectories. | 2044 // If we will be writing out files, prepare subdirectories. |
| 2013 if (FLAGS_writePath.count() == 1) { | 2045 if (FLAGS_writePath.count() == 1) { |
| 2014 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy , configs)) { | 2046 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy , configs)) { |
| 2015 return -1; | 2047 return -1; |
| 2016 } | 2048 } |
| 2017 } | 2049 } |
| 2018 if (NULL != gmmain.fMismatchPath) { | 2050 if (NULL != gmmain.fMismatchPath) { |
| 2019 if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHierarc hy, configs)) { | 2051 if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHierarc hy, configs)) { |
| 2020 return -1; | 2052 return -1; |
| 2021 } | 2053 } |
| 2022 } | 2054 } |
| 2023 if (NULL != gmmain.fMissingExpectationsPath) { | 2055 if (NULL != gmmain.fMissingExpectationsPath) { |
| 2024 if (!prepare_subdirectories(gmmain.fMissingExpectationsPath, gmmain.fUse FileHierarchy, | 2056 if (!prepare_subdirectories(gmmain.fMissingExpectationsPath, gmmain.fUse FileHierarchy, |
| 2025 configs)) { | 2057 configs)) { |
| 2026 return -1; | 2058 return -1; |
| 2027 } | 2059 } |
| 2028 } | 2060 } |
| 2029 | 2061 |
| 2030 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { | 2062 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { |
|
ducky
2013/08/02 03:59:04
Is this supposed to do anything, like exit the pro
edisonn
2013/08/02 12:32:41
please add return -1 here. good find.
ducky
2013/08/02 18:14:38
Done.
| |
| 2031 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range. "); | 2063 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range. "); |
| 2032 } | 2064 } |
| 2033 | 2065 |
| 2034 Iter iter; | 2066 Iter iter; |
| 2035 GM* gm; | 2067 GM* gm; |
| 2036 while ((gm = iter.next()) != NULL) { | 2068 while ((gm = iter.next()) != NULL) { |
| 2037 SkAutoTDelete<GM> adgm(gm); | 2069 SkAutoTDelete<GM> adgm(gm); |
| 2038 ++gmIndex; | 2070 ++gmIndex; |
| 2039 if (moduloRemainder >= 0) { | 2071 if (moduloRemainder >= 0) { |
| 2040 if ((gmIndex % moduloDivisor) != moduloRemainder) { | 2072 if ((gmIndex % moduloDivisor) != moduloRemainder) { |
| 2041 continue; | 2073 continue; |
| 2042 } | 2074 } |
| 2043 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); | 2075 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); |
| 2044 } | 2076 } |
| 2045 | 2077 |
| 2046 const char* shortName = gm->shortName(); | 2078 const char* shortName = gm->shortName(); |
| 2047 | 2079 |
| 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 if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { |
| 2053 continue; | 2081 continue; |
| 2054 } | 2082 } |
| 2055 | 2083 |
| 2056 gmsRun++; | 2084 gmsRun++; |
| 2057 SkISize size = gm->getISize(); | 2085 SkISize size = gm->getISize(); |
| 2058 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, | 2086 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, |
| 2059 size.width(), size.height()); | 2087 size.width(), size.height()); |
| 2060 | 2088 |
| 2061 run_multiple_configs(gmmain, gm, configs, grFactory); | 2089 run_multiple_configs(gmmain, gm, configs, grFactory); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2135 if (FLAGS_forceBWtext) { | 2163 if (FLAGS_forceBWtext) { |
| 2136 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2164 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2137 } | 2165 } |
| 2138 } | 2166 } |
| 2139 | 2167 |
| 2140 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2168 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2141 int main(int argc, char * const argv[]) { | 2169 int main(int argc, char * const argv[]) { |
| 2142 return tool_main(argc, (char**) argv); | 2170 return tool_main(argc, (char**) argv); |
| 2143 } | 2171 } |
| 2144 #endif | 2172 #endif |
| OLD | NEW |