Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: gm/gmmain.cpp

Issue 13842014: Add option to specify defaults configs to --config flag in gm. This makes it easier to run gm defau… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add option to specify defaults configs to --config flag in gm. This makes it easier to run gm defau… Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 uint32_t flags; 167 uint32_t flags;
168 }; 168 };
169 169
170 static PipeFlagComboData gPipeWritingFlagCombos[] = { 170 static PipeFlagComboData gPipeWritingFlagCombos[] = {
171 { "", 0 }, 171 { "", 0 },
172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, 172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag },
173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag 173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag
174 | SkGPipeWriter::kSharedAddressSpace_Flag } 174 | SkGPipeWriter::kSharedAddressSpace_Flag }
175 }; 175 };
176 176
177 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect); 177 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect);
epoger 2013/04/24 16:18:26 Looks like this got picked up from https://code.go
bsalomon 2013/04/24 18:07:33 Sorry 'bout that... I moved the CL from my home ma
178 178
179 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() 179 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination()
180 .plus(kMissingExpectations_ErrorType) 180 .plus(kMissingExpectations_ErrorType)
181 .plus(kIntentionallySkipped_ErrorType); 181 .plus(kIntentionallySkipped_ErrorType);
182 182
183 class GMMain { 183 class GMMain {
184 public: 184 public:
185 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes), 185 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes),
186 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} 186 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {}
187 187
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 #endif // SK_SUPPORT_GPU 1164 #endif // SK_SUPPORT_GPU
1165 #ifdef SK_SUPPORT_XPS 1165 #ifdef SK_SUPPORT_XPS
1166 /* At present we have no way of comparing XPS files (either natively or by c onverting to PNG). */ 1166 /* At present we have no way of comparing XPS files (either natively or by c onverting to PNG). */
1167 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true }, 1167 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true },
1168 #endif // SK_SUPPORT_XPS 1168 #endif // SK_SUPPORT_XPS
1169 #ifdef SK_SUPPORT_PDF 1169 #ifdef SK_SUPPORT_PDF
1170 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true }, 1170 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true },
1171 #endif // SK_SUPPORT_PDF 1171 #endif // SK_SUPPORT_PDF
1172 }; 1172 };
1173 1173
1174 static const char kDefaultsConfigStr[] = "defaults";
1175 static const char kExcludeConfigChar = '~';
1176
1174 static SkString configUsage() { 1177 static SkString configUsage() {
1175 SkString result; 1178 SkString result;
1176 result.appendf("Space delimited list of which configs to run. Possible optio ns: ["); 1179 result.appendf("Space delimited list of which configs to run. Possible optio ns: [");
1177 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 1180 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
1181 SkASSERT(gRec[i].fName != kDefaultsConfigStr);
1178 if (i > 0) { 1182 if (i > 0) {
1179 result.append("|"); 1183 result.append("|");
1180 } 1184 }
1181 result.appendf("%s", gRec[i].fName); 1185 result.appendf("%s", gRec[i].fName);
1182 } 1186 }
1183 result.append("]\n"); 1187 result.append("]\n");
1184 result.appendf("The default value is: \""); 1188 result.appendf("The default value is: \"");
1189 SkString firstDefault;
1190 SkString allButFirstDefaults;
1191 SkString nonDefault;
1185 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 1192 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
1186 if (gRec[i].fRunByDefault) { 1193 if (gRec[i].fRunByDefault) {
1187 if (i > 0) { 1194 if (i > 0) {
1188 result.append(" "); 1195 result.append(" ");
1189 } 1196 }
1190 result.appendf("%s", gRec[i].fName); 1197 result.append(gRec[i].fName);
1198 if (firstDefault.isEmpty()) {
1199 firstDefault = gRec[i].fName;
1200 } else {
1201 if (!allButFirstDefaults.isEmpty()) {
1202 allButFirstDefaults.append(" ");
1203 }
1204 allButFirstDefaults.append(gRec[i].fName);
1205 }
1206 } else {
1207 nonDefault = gRec[i].fName;
1191 } 1208 }
1192 } 1209 }
1193 result.appendf("\""); 1210 result.append("\"\n");
1194 1211 result.appendf("\"%s\" evaluates to the default set of configs.\n", kDefault sConfigStr);
1212 result.appendf("Prepending \"%c\" on a config name excludes it from the set of configs to run.\n"
1213 "Exclusions always override inclusions regardless of order.\n ",
1214 kExcludeConfigChar);
1215 result.appendf("E.g. \"--config %s %c%s %s\" will run these configs:\n\t%s % s",
1216 kDefaultsConfigStr,
1217 kExcludeConfigChar,
1218 firstDefault.c_str(),
1219 nonDefault.c_str(),
1220 allButFirstDefaults.c_str(),
1221 nonDefault.c_str());
1195 return result; 1222 return result;
1196 } 1223 }
1197 1224
1198 // Macro magic to convert a numeric preprocessor token into a string. 1225 // Macro magic to convert a numeric preprocessor token into a string.
1199 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor -token-to-a-string 1226 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor -token-to-a-string
1200 // This should probably be moved into one of our common headers... 1227 // This should probably be moved into one of our common headers...
1201 #define TOSTRING_INTERNAL(x) #x 1228 #define TOSTRING_INTERNAL(x) #x
1202 #define TOSTRING(x) TOSTRING_INTERNAL(x) 1229 #define TOSTRING(x) TOSTRING_INTERNAL(x)
1203 1230
1204 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). 1231 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath").
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 usage.printf("Run the golden master tests.\n"); 1674 usage.printf("Run the golden master tests.\n");
1648 SkCommandLineFlags::SetUsage(usage.c_str()); 1675 SkCommandLineFlags::SetUsage(usage.c_str());
1649 SkCommandLineFlags::Parse(argc, argv); 1676 SkCommandLineFlags::Parse(argc, argv);
1650 1677
1651 gmmain.fUseFileHierarchy = FLAGS_hierarchy; 1678 gmmain.fUseFileHierarchy = FLAGS_hierarchy;
1652 if (FLAGS_mismatchPath.count() == 1) { 1679 if (FLAGS_mismatchPath.count() == 1) {
1653 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; 1680 gmmain.fMismatchPath = FLAGS_mismatchPath[0];
1654 } 1681 }
1655 1682
1656 for (int i = 0; i < FLAGS_config.count(); i++) { 1683 for (int i = 0; i < FLAGS_config.count(); i++) {
1657 int index = findConfig(FLAGS_config[i]); 1684 const char* config = FLAGS_config[i];
1685 userConfig = true;
1686 bool exclude = false;
1687 if (*config == kExcludeConfigChar) {
1688 exclude = true;
1689 config += 1;
1690 }
1691 int index = findConfig(config);
1658 if (index >= 0) { 1692 if (index >= 0) {
1659 appendUnique<size_t>(&configs, index); 1693 if (exclude) {
1660 userConfig = true; 1694 *excludeConfigs.append() = index;
1695 } else {
1696 appendUnique<size_t>(&configs, index);
1697 }
1698 } else if (0 == strcmp(kDefaultsConfigStr, config)) {
1699 for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) {
1700 if (gRec[c].fRunByDefault) {
1701 if (exclude) {
1702 gm_fprintf(stderr, "%c%s is not allowed.\n",
1703 kExcludeConfigChar, kDefaultsConfigStr);
1704 return -1;
1705 } else {
1706 appendUnique<size_t>(&configs, c);
1707 }
1708 }
1709 }
1661 } else { 1710 } else {
1662 gm_fprintf(stderr, "unrecognized config %s\n", FLAGS_config[i]); 1711 gm_fprintf(stderr, "unrecognized config %s\n", config);
1663 return -1; 1712 return -1;
1664 } 1713 }
1665 } 1714 }
1666 1715
1667 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { 1716 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) {
1668 int index = findConfig(FLAGS_excludeConfig[i]); 1717 int index = findConfig(FLAGS_excludeConfig[i]);
1669 if (index >= 0) { 1718 if (index >= 0) {
1670 *excludeConfigs.append() = index; 1719 *excludeConfigs.append() = index;
1671 } else { 1720 } else {
1672 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]); 1721 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 " Config will be skipped.\n", gRec[index].fSampleCnt, gRec[index].fName); 1815 " Config will be skipped.\n", gRec[index].fSampleCnt, gRec[index].fName);
1767 configs.remove(i); 1816 configs.remove(i);
1768 --i; 1817 --i;
1769 } 1818 }
1770 } 1819 }
1771 } 1820 }
1772 #else 1821 #else
1773 GrContextFactory* grFactory = NULL; 1822 GrContextFactory* grFactory = NULL;
1774 #endif 1823 #endif
1775 1824
1825 if (configs.isEmpty()) {
1826 gm_fprintf(stderr, "No configs to run.");
1827 return -1;
1828 }
1829
1830 // now show the user the set of configs that will be run.
1831 SkString configStr("These configs will be run: ");
1832 // show the user the config that will run.
1833 for (int i = 0; i < configs.count(); ++i) {
1834 configStr.appendf("%s%s", gRec[configs[i]].fName, (i == configs.count() - 1) ? "\n" : " ");
1835 }
1836 gm_fprintf(stdout, "%s", configStr.c_str());
1837
1776 if (FLAGS_resourcePath.count() == 1) { 1838 if (FLAGS_resourcePath.count() == 1) {
1777 GM::SetResourcePath(FLAGS_resourcePath[0]); 1839 GM::SetResourcePath(FLAGS_resourcePath[0]);
1778 } 1840 }
1779 1841
1780 if (FLAGS_readPath.count() == 1) { 1842 if (FLAGS_readPath.count() == 1) {
1781 const char* readPath = FLAGS_readPath[0]; 1843 const char* readPath = FLAGS_readPath[0];
1782 if (!sk_exists(readPath)) { 1844 if (!sk_exists(readPath)) {
1783 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); 1845 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath);
1784 return -1; 1846 return -1;
1785 } 1847 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 if (FLAGS_forceBWtext) { 2011 if (FLAGS_forceBWtext) {
1950 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2012 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1951 } 2013 }
1952 } 2014 }
1953 2015
1954 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2016 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1955 int main(int argc, char * const argv[]) { 2017 int main(int argc, char * const argv[]) {
1956 return tool_main(argc, (char**) argv); 2018 return tool_main(argc, (char**) argv);
1957 } 2019 }
1958 #endif 2020 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698