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 static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, |
| 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 ", gRec[(*outConfigs)[i]].fName); | |
| 1866 } | |
| 1867 gm_fprintf(stdout, "%s\n", configStr.c_str()); | |
| 1868 | |
| 1869 return true; | |
| 1870 } | |
| 1871 | |
| 1872 static bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { | |
| 1857 if (FLAGS_ignoreErrorTypes.count() > 0) { | 1873 if (FLAGS_ignoreErrorTypes.count() > 0) { |
| 1858 gmmain.fIgnorableErrorTypes = ErrorCombination(); | 1874 *outErrorTypes = ErrorCombination(); |
| 1859 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { | 1875 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { |
| 1860 ErrorType type; | 1876 ErrorType type; |
| 1861 const char *name = FLAGS_ignoreErrorTypes[i]; | 1877 const char *name = FLAGS_ignoreErrorTypes[i]; |
| 1862 if (!getErrorTypeByName(name, &type)) { | 1878 if (!getErrorTypeByName(name, &type)) { |
| 1863 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); | 1879 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); |
| 1864 return -1; | 1880 return false; |
| 1865 } else { | 1881 } else { |
| 1866 gmmain.fIgnorableErrorTypes.add(type); | 1882 outErrorTypes->add(type); |
| 1867 } | 1883 } |
| 1868 } | 1884 } |
| 1869 } | 1885 } |
| 1870 | 1886 return true; |
| 1871 #if SK_SUPPORT_GPU | 1887 } |
| 1888 | |
| 1889 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { | |
| 1890 if (FLAGS_modulo.count() == 2) { | |
| 1891 *moduloRemainder = atoi(FLAGS_modulo[0]); | |
| 1892 *moduloDivisor = atoi(FLAGS_modulo[1]); | |
| 1893 if (*moduloRemainder < 0 || *moduloDivisor <= 0 || | |
| 1894 *moduloRemainder >= *moduloDivisor) { | |
| 1895 gm_fprintf(stderr, "invalid modulo values."); | |
| 1896 return false; | |
| 1897 } | |
| 1898 } | |
| 1899 return true; | |
| 1900 } | |
| 1901 | |
| 1902 static bool parse_flags_gpu_cache(int* sizeBytes, int* sizeCount) { | |
| 1872 if (FLAGS_gpuCacheSize.count() > 0) { | 1903 if (FLAGS_gpuCacheSize.count() > 0) { |
| 1873 if (FLAGS_gpuCacheSize.count() != 2) { | 1904 if (FLAGS_gpuCacheSize.count() != 2) { |
| 1874 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | 1905 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); |
| 1875 return -1; | 1906 return false; |
| 1876 } | 1907 } |
| 1877 gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]); | 1908 *sizeBytes = atoi(FLAGS_gpuCacheSize[0]); |
| 1878 gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]); | 1909 *sizeCount = atoi(FLAGS_gpuCacheSize[1]); |
| 1879 } else { | 1910 } else { |
| 1880 gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE; | 1911 *sizeBytes = DEFAULT_CACHE_VALUE; |
| 1881 gGpuCacheSizeCount = DEFAULT_CACHE_VALUE; | 1912 *sizeCount = DEFAULT_CACHE_VALUE; |
| 1882 } | 1913 } |
| 1883 #endif | 1914 return true; |
| 1884 | 1915 } |
| 1885 SkTDArray<SkScalar> tileGridReplayScales; | 1916 |
| 1886 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | 1917 static bool parse_flags_tile_grid_replay_scales(SkTDArray<SkScalar>* outScales) { |
| 1918 *outScales->append() = SK_Scalar1; // By default only test at scale 1.0 | |
| 1887 if (FLAGS_tileGridReplayScales.count() > 0) { | 1919 if (FLAGS_tileGridReplayScales.count() > 0) { |
| 1888 tileGridReplayScales.reset(); | 1920 outScales->reset(); |
| 1889 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | 1921 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { |
| 1890 double val = atof(FLAGS_tileGridReplayScales[i]); | 1922 double val = atof(FLAGS_tileGridReplayScales[i]); |
| 1891 if (0 < val) { | 1923 if (0 < val) { |
| 1892 *tileGridReplayScales.append() = SkDoubleToScalar(val); | 1924 *outScales->append() = SkDoubleToScalar(val); |
| 1893 } | 1925 } |
| 1894 } | 1926 } |
| 1895 if (0 == tileGridReplayScales.count()) { | 1927 if (0 == outScales->count()) { |
| 1896 // Should have at least one scale | 1928 // Should have at least one scale |
| 1897 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); | 1929 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); |
| 1898 return -1; | 1930 return false; |
| 1899 } | 1931 } |
| 1900 } | 1932 } |
| 1901 | 1933 return true; |
| 1902 if (!userConfig) { | 1934 } |
| 1903 // if no config is specified by user, add the defaults | 1935 |
| 1904 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1936 static bool parse_flags_gmmain_paths(GMMain* gmmain) { |
| 1905 if (gRec[i].fRunByDefault) { | 1937 gmmain->fUseFileHierarchy = FLAGS_hierarchy; |
| 1906 *configs.append() = i; | 1938 gmmain->fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames; |
| 1907 } | 1939 |
| 1908 } | 1940 if (FLAGS_mismatchPath.count() == 1) { |
| 1909 } | 1941 gmmain->fMismatchPath = FLAGS_mismatchPath[0]; |
| 1910 // now remove any explicitly excluded configs | 1942 } |
| 1911 for (int i = 0; i < excludeConfigs.count(); ++i) { | 1943 |
| 1912 int index = configs.find(excludeConfigs[i]); | 1944 if (FLAGS_missingExpectationsPath.count() == 1) { |
| 1913 if (index >= 0) { | 1945 gmmain->fMissingExpectationsPath = FLAGS_missingExpectationsPath[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 } | 1946 } |
| 1961 | 1947 |
| 1962 if (FLAGS_readPath.count() == 1) { | 1948 if (FLAGS_readPath.count() == 1) { |
| 1963 const char* readPath = FLAGS_readPath[0]; | 1949 const char* readPath = FLAGS_readPath[0]; |
| 1964 if (!sk_exists(readPath)) { | 1950 if (!sk_exists(readPath)) { |
| 1965 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 1951 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); |
| 1966 return -1; | 1952 return false; |
| 1967 } | 1953 } |
| 1968 if (sk_isdir(readPath)) { | 1954 if (sk_isdir(readPath)) { |
| 1969 if (FLAGS_verbose) { | 1955 if (FLAGS_verbose) { |
| 1970 gm_fprintf(stdout, "reading from %s\n", readPath); | 1956 gm_fprintf(stdout, "reading from %s\n", readPath); |
| 1971 } | 1957 } |
| 1972 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1958 gmmain->fExpectationsSource.reset(SkNEW_ARGS( |
| 1973 IndividualImageExpectationsSource, (readPath))); | 1959 IndividualImageExpectationsSource, (readPath))); |
| 1974 } else { | 1960 } else { |
| 1975 if (FLAGS_verbose) { | 1961 if (FLAGS_verbose) { |
| 1976 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath); | 1962 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath); |
| 1977 } | 1963 } |
| 1978 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1964 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource, (readPath))); |
| 1979 JsonExpectationsSource, (readPath))); | 1965 } |
| 1980 } | 1966 } |
| 1981 } | 1967 return true; |
| 1968 } | |
| 1969 | |
| 1970 static bool parse_flags_match_strs(SkTDArray<const char*>* matchStrs) { | |
| 1971 for (int i = 0; i < FLAGS_match.count(); ++i) { | |
| 1972 matchStrs->push(FLAGS_match[i]); | |
| 1973 } | |
| 1974 return true; | |
| 1975 } | |
| 1976 | |
| 1977 static bool parse_flags_resource_path() { | |
| 1978 if (FLAGS_resourcePath.count() == 1) { | |
| 1979 GM::SetResourcePath(FLAGS_resourcePath[0]); | |
| 1980 } | |
| 1981 return true; | |
| 1982 } | |
| 1983 | |
| 1984 static bool parse_flags_jpeg_quality() { | |
| 1985 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { | |
| 1986 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range. "); | |
| 1987 return false; | |
| 1988 } | |
| 1989 return true; | |
| 1990 } | |
| 1991 | |
| 1992 int tool_main(int argc, char** argv); | |
| 1993 int tool_main(int argc, char** argv) { | |
| 1994 | |
| 1995 #if SK_ENABLE_INST_COUNT | |
| 1996 gPrintInstCount = true; | |
| 1997 #endif | |
| 1998 | |
| 1999 SkGraphics::Init(); | |
| 2000 // we don't need to see this during a run | |
| 2001 gSkSuppressFontCachePurgeSpew = true; | |
| 2002 | |
| 2003 setSystemPreferences(); | |
| 2004 GMMain gmmain; | |
| 2005 | |
| 2006 SkString usage; | |
| 2007 usage.printf("Run the golden master tests.\n"); | |
| 2008 SkCommandLineFlags::SetUsage(usage.c_str()); | |
| 2009 SkCommandLineFlags::Parse(argc, argv); | |
| 2010 | |
| 2011 SkTDArray<size_t> configs; | |
| 2012 int moduloRemainder = -1, moduloDivisor = -1; | |
|
vandebo (ex-Chrome)
2013/08/07 17:29:48
nit: two int lines.
| |
| 2013 SkTDArray<SkScalar> tileGridReplayScales; | |
| 2014 #if SK_SUPPORT_GPU | |
| 2015 GrContextFactory* grFactory = new GrContextFactory; | |
| 2016 #else | |
| 2017 GrContextFactory* grFactory = NULL; | |
| 2018 #endif | |
| 2019 SkTDArray<const char*> matchStrs; | |
| 2020 | |
| 2021 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || | |
| 2022 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || | |
| 2023 #if SK_SUPPORT_GPU | |
| 2024 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || | |
| 2025 #endif | |
| 2026 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || | |
| 2027 !parse_flags_gmmain_paths(&gmmain) || | |
| 2028 !parse_flags_resource_path() || | |
| 2029 !parse_flags_match_strs(&matchStrs) || | |
| 2030 !parse_flags_jpeg_quality() || | |
| 2031 !parse_flags_configs(&configs, grFactory)) { | |
| 2032 return -1; | |
| 2033 } | |
| 2034 | |
| 1982 if (FLAGS_verbose) { | 2035 if (FLAGS_verbose) { |
| 1983 if (FLAGS_writePath.count() == 1) { | 2036 if (FLAGS_writePath.count() == 1) { |
| 1984 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); | 2037 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); |
| 1985 } | 2038 } |
| 1986 if (NULL != gmmain.fMismatchPath) { | 2039 if (NULL != gmmain.fMismatchPath) { |
| 1987 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat h); | 2040 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat h); |
| 1988 } | 2041 } |
| 1989 if (NULL != gmmain.fMissingExpectationsPath) { | 2042 if (NULL != gmmain.fMissingExpectationsPath) { |
| 1990 gm_fprintf(stdout, "writing images without expectations to %s\n", | 2043 gm_fprintf(stdout, "writing images without expectations to %s\n", |
| 1991 gmmain.fMissingExpectationsPath); | 2044 gmmain.fMissingExpectationsPath); |
| 1992 } | 2045 } |
| 1993 if (FLAGS_writePicturePath.count() == 1) { | 2046 if (FLAGS_writePicturePath.count() == 1) { |
| 1994 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat h[0]); | 2047 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat h[0]); |
| 1995 } | 2048 } |
| 1996 if (FLAGS_resourcePath.count() == 1) { | 2049 if (FLAGS_resourcePath.count() == 1) { |
| 1997 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath [0]); | 2050 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath [0]); |
| 1998 } | 2051 } |
| 1999 } | 2052 } |
| 2000 | 2053 |
| 2001 if (moduloDivisor <= 0) { | |
| 2002 moduloRemainder = -1; | |
| 2003 } | |
| 2004 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { | |
| 2005 moduloRemainder = -1; | |
| 2006 } | |
| 2007 | |
| 2008 int gmsRun = 0; | 2054 int gmsRun = 0; |
| 2009 int gmIndex = -1; | 2055 int gmIndex = -1; |
| 2010 SkString moduloStr; | 2056 SkString moduloStr; |
| 2011 | 2057 |
| 2012 // If we will be writing out files, prepare subdirectories. | 2058 // If we will be writing out files, prepare subdirectories. |
| 2013 if (FLAGS_writePath.count() == 1) { | 2059 if (FLAGS_writePath.count() == 1) { |
| 2014 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy , configs)) { | 2060 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy , configs)) { |
| 2015 return -1; | 2061 return -1; |
| 2016 } | 2062 } |
| 2017 } | 2063 } |
| 2018 if (NULL != gmmain.fMismatchPath) { | 2064 if (NULL != gmmain.fMismatchPath) { |
| 2019 if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHierarc hy, configs)) { | 2065 if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHierarc hy, configs)) { |
| 2020 return -1; | 2066 return -1; |
| 2021 } | 2067 } |
| 2022 } | 2068 } |
| 2023 if (NULL != gmmain.fMissingExpectationsPath) { | 2069 if (NULL != gmmain.fMissingExpectationsPath) { |
| 2024 if (!prepare_subdirectories(gmmain.fMissingExpectationsPath, gmmain.fUse FileHierarchy, | 2070 if (!prepare_subdirectories(gmmain.fMissingExpectationsPath, gmmain.fUse FileHierarchy, |
| 2025 configs)) { | 2071 configs)) { |
| 2026 return -1; | 2072 return -1; |
| 2027 } | 2073 } |
| 2028 } | 2074 } |
| 2029 | 2075 |
| 2030 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { | |
| 2031 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range. "); | |
| 2032 } | |
| 2033 | |
| 2034 Iter iter; | 2076 Iter iter; |
| 2035 GM* gm; | 2077 GM* gm; |
| 2036 while ((gm = iter.next()) != NULL) { | 2078 while ((gm = iter.next()) != NULL) { |
| 2037 SkAutoTDelete<GM> adgm(gm); | 2079 SkAutoTDelete<GM> adgm(gm); |
| 2038 ++gmIndex; | 2080 ++gmIndex; |
| 2039 if (moduloRemainder >= 0) { | 2081 if (moduloRemainder >= 0) { |
| 2040 if ((gmIndex % moduloDivisor) != moduloRemainder) { | 2082 if ((gmIndex % moduloDivisor) != moduloRemainder) { |
| 2041 continue; | 2083 continue; |
| 2042 } | 2084 } |
| 2043 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); | 2085 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); |
| 2044 } | 2086 } |
| 2045 | 2087 |
| 2046 const char* shortName = gm->shortName(); | 2088 const char* shortName = gm->shortName(); |
| 2047 | 2089 |
| 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)) { | 2090 if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { |
| 2053 continue; | 2091 continue; |
| 2054 } | 2092 } |
| 2055 | 2093 |
| 2056 gmsRun++; | 2094 gmsRun++; |
| 2057 SkISize size = gm->getISize(); | 2095 SkISize size = gm->getISize(); |
| 2058 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, | 2096 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, |
| 2059 size.width(), size.height()); | 2097 size.width(), size.height()); |
| 2060 | 2098 |
| 2061 run_multiple_configs(gmmain, gm, configs, grFactory); | 2099 run_multiple_configs(gmmain, gm, configs, grFactory); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2135 if (FLAGS_forceBWtext) { | 2173 if (FLAGS_forceBWtext) { |
| 2136 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2174 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2137 } | 2175 } |
| 2138 } | 2176 } |
| 2139 | 2177 |
| 2140 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2178 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2141 int main(int argc, char * const argv[]) { | 2179 int main(int argc, char * const argv[]) { |
| 2142 return tool_main(argc, (char**) argv); | 2180 return tool_main(argc, (char**) argv); |
| 2143 } | 2181 } |
| 2144 #endif | 2182 #endif |
| OLD | NEW |