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

Side by Side Diff: dm/DM.cpp

Issue 553583004: Remove expectations / -r from DM entirely. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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
« no previous file with comments | « no previous file | dm/DMCpuGMTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Main binary for DM. 1 // Main binary for DM.
2 // For a high-level overview, please see dm/README. 2 // For a high-level overview, please see dm/README.
3 3
4 #include "CrashHandler.h" 4 #include "CrashHandler.h"
5 #include "LazyDecodeBitmap.h" 5 #include "LazyDecodeBitmap.h"
6 #include "SkCommonFlags.h" 6 #include "SkCommonFlags.h"
7 #include "SkForceLinking.h" 7 #include "SkForceLinking.h"
8 #include "SkGraphics.h" 8 #include "SkGraphics.h"
9 #include "SkOSFile.h" 9 #include "SkOSFile.h"
10 #include "SkPicture.h" 10 #include "SkPicture.h"
(...skipping 25 matching lines...) Expand all
36 #include <ctype.h> 36 #include <ctype.h>
37 37
38 using skiagm::GM; 38 using skiagm::GM;
39 using skiagm::GMRegistry; 39 using skiagm::GMRegistry;
40 using skiatest::Test; 40 using skiatest::Test;
41 using skiatest::TestRegistry; 41 using skiatest::TestRegistry;
42 42
43 static const char kGpuAPINameGL[] = "gl"; 43 static const char kGpuAPINameGL[] = "gl";
44 static const char kGpuAPINameGLES[] = "gles"; 44 static const char kGpuAPINameGLES[] = "gles";
45 45
46 DEFINE_string2(expectations, r, "",
47 "If a directory, compare generated images against images under th is path. "
48 "If a file, compare generated images against JSON expectations at this path."
49 );
50
51 DEFINE_bool(gms, true, "Run GMs?"); 46 DEFINE_bool(gms, true, "Run GMs?");
52 DEFINE_bool(tests, true, "Run tests?"); 47 DEFINE_bool(tests, true, "Run tests?");
53 DEFINE_bool(reportUsedChars, false, "Output test font construction data to be pa sted into" 48 DEFINE_bool(reportUsedChars, false, "Output test font construction data to be pa sted into"
54 " create_test_font.cpp."); 49 " create_test_font.cpp.");
55 50
56 __SK_FORCE_IMAGE_DECODER_LINKING; 51 __SK_FORCE_IMAGE_DECODER_LINKING;
57 52
58 // "FooBar" -> "foobar". Obviously, ASCII only. 53 // "FooBar" -> "foobar". Obviously, ASCII only.
59 static SkString lowercase(SkString s) { 54 static SkString lowercase(SkString s) {
60 for (size_t i = 0; i < s.size(); i++) { 55 for (size_t i = 0; i < s.size(); i++) {
61 s[i] = tolower(s[i]); 56 s[i] = tolower(s[i]);
62 } 57 }
63 return s; 58 return s;
64 } 59 }
65 60
66 static const GrContextFactory::GLContextType native = GrContextFactory::kNative_ GLContextType; 61 static const GrContextFactory::GLContextType native = GrContextFactory::kNative_ GLContextType;
67 static const GrContextFactory::GLContextType nvpr = GrContextFactory::kNVPR_GL ContextType; 62 static const GrContextFactory::GLContextType nvpr = GrContextFactory::kNVPR_GL ContextType;
68 static const GrContextFactory::GLContextType null = GrContextFactory::kNull_GL ContextType; 63 static const GrContextFactory::GLContextType null = GrContextFactory::kNull_GL ContextType;
69 static const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_G LContextType; 64 static const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_G LContextType;
70 #if SK_ANGLE 65 #if SK_ANGLE
71 static const GrContextFactory::GLContextType angle = GrContextFactory::kANGLE_G LContextType; 66 static const GrContextFactory::GLContextType angle = GrContextFactory::kANGLE_G LContextType;
72 #endif 67 #endif
73 #if SK_MESA 68 #if SK_MESA
74 static const GrContextFactory::GLContextType mesa = GrContextFactory::kMESA_GL ContextType; 69 static const GrContextFactory::GLContextType mesa = GrContextFactory::kMESA_GL ContextType;
75 #endif 70 #endif
76 71
77 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, 72 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms,
78 const SkTArray<SkString>& configs, 73 const SkTArray<SkString>& configs,
79 GrGLStandard gpuAPI, 74 GrGLStandard gpuAPI,
80 const DM::Expectations& expectations,
81 DM::Reporter* reporter, 75 DM::Reporter* reporter,
82 DM::TaskRunner* tasks) { 76 DM::TaskRunner* tasks) {
83 #define START(name, type, ...) \ 77 #define START(name, type, ...) \
84 if (lowercase(configs[j]).equals(name)) { \ 78 if (lowercase(configs[j]).equals(name)) { \
85 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, gms[i], ## __VA_ ARGS__))); \ 79 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, gms[i], ## __VA_ ARGS__))); \
86 } 80 }
87 for (int i = 0; i < gms.count(); i++) { 81 for (int i = 0; i < gms.count(); i++) {
88 for (int j = 0; j < configs.count(); j++) { 82 for (int j = 0; j < configs.count(); j++) {
89 83
90 START("565", CpuGMTask, expectations, kRGB_565_SkColorType); 84 START("565", CpuGMTask, kRGB_565_SkColorType);
91 START("8888", CpuGMTask, expectations, kN32_SkColorType); 85 START("8888", CpuGMTask, kN32_SkColorType);
92 START("gpu", GpuGMTask, expectations, native, gpuAPI, 0); 86 START("gpu", GpuGMTask, native, gpuAPI, 0);
93 START("msaa4", GpuGMTask, expectations, native, gpuAPI, 4); 87 START("msaa4", GpuGMTask, native, gpuAPI, 4);
94 START("msaa16", GpuGMTask, expectations, native, gpuAPI, 16); 88 START("msaa16", GpuGMTask, native, gpuAPI, 16);
95 START("nvprmsaa4", GpuGMTask, expectations, nvpr, gpuAPI, 4); 89 START("nvprmsaa4", GpuGMTask, nvpr, gpuAPI, 4);
96 START("nvprmsaa16", GpuGMTask, expectations, nvpr, gpuAPI, 16); 90 START("nvprmsaa16", GpuGMTask, nvpr, gpuAPI, 16);
97 START("gpunull", GpuGMTask, expectations, null, gpuAPI, 0); 91 START("gpunull", GpuGMTask, null, gpuAPI, 0);
98 START("gpudebug", GpuGMTask, expectations, debug, gpuAPI, 0); 92 START("gpudebug", GpuGMTask, debug, gpuAPI, 0);
99 #if SK_ANGLE 93 #if SK_ANGLE
100 START("angle", GpuGMTask, expectations, angle, gpuAPI, 0); 94 START("angle", GpuGMTask, angle, gpuAPI, 0);
101 #endif 95 #endif
102 #if SK_MESA 96 #if SK_MESA
103 START("mesa", GpuGMTask, expectations, mesa, gpuAPI, 0); 97 START("mesa", GpuGMTask, mesa, gpuAPI, 0);
104 #endif 98 #endif
105 START("pdf", PDFTask, RASTERIZE_PDF_PROC); 99 START("pdf", PDFTask, RASTERIZE_PDF_PROC);
106 } 100 }
107 } 101 }
108 #undef START 102 #undef START
109 } 103 }
110 104
111 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests, 105 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests,
112 DM::Reporter* reporter, 106 DM::Reporter* reporter,
113 DM::TaskRunner* tasks) { 107 DM::TaskRunner* tasks) {
(...skipping 15 matching lines...) Expand all
129 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); 123 SkOSFile::Iter it(FLAGS_skps[0], ".skp");
130 SkString filename; 124 SkString filename;
131 while (it.next(&filename)) { 125 while (it.next(&filename)) {
132 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) { 126 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) {
133 skps->push_back(SkOSPath::Join(FLAGS_skps[0], filename.c_str())); 127 skps->push_back(SkOSPath::Join(FLAGS_skps[0], filename.c_str()));
134 } 128 }
135 } 129 }
136 } 130 }
137 131
138 static void kick_off_skps(const SkTArray<SkString>& skps, 132 static void kick_off_skps(const SkTArray<SkString>& skps,
139 const DM::Expectations& expectations,
140 DM::Reporter* reporter, 133 DM::Reporter* reporter,
141 DM::TaskRunner* tasks) { 134 DM::TaskRunner* tasks) {
142 for (int i = 0; i < skps.count(); ++i) { 135 for (int i = 0; i < skps.count(); ++i) {
143 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(skps[i].c_str())); 136 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(skps[i].c_str()));
144 if (stream.get() == NULL) { 137 if (stream.get() == NULL) {
145 SkDebugf("Could not read %s.\n", skps[i].c_str()); 138 SkDebugf("Could not read %s.\n", skps[i].c_str());
146 exit(1); 139 exit(1);
147 } 140 }
148 SkAutoTUnref<SkPicture> pic( 141 SkAutoTUnref<SkPicture> pic(
149 SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeB itmap)); 142 SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeB itmap));
150 if (pic.get() == NULL) { 143 if (pic.get() == NULL) {
151 SkDebugf("Could not read %s as an SkPicture.\n", skps[i].c_str()); 144 SkDebugf("Could not read %s as an SkPicture.\n", skps[i].c_str());
152 exit(1); 145 exit(1);
153 } 146 }
154 147
155 SkString filename = SkOSPath::Basename(skps[i].c_str()); 148 SkString filename = SkOSPath::Basename(skps[i].c_str());
156 tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, expectations, pic, filename))); 149 tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic, filename)));
157 tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, 150 tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, RAST ERIZE_PDF_PROC)));
158 RASTERIZE_PDF_PROC)));
159 } 151 }
160 } 152 }
161 153
162 static void report_failures(const SkTArray<SkString>& failures) { 154 static void report_failures(const SkTArray<SkString>& failures) {
163 if (failures.count() == 0) { 155 if (failures.count() == 0) {
164 return; 156 return;
165 } 157 }
166 158
167 SkDebugf("Failures:\n"); 159 SkDebugf("Failures:\n");
168 for (int i = 0; i < failures.count(); i++) { 160 for (int i = 0; i < failures.count(); i++) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 gPrintInstCount = FLAGS_leaks; 196 gPrintInstCount = FLAGS_leaks;
205 #endif 197 #endif
206 198
207 SkTArray<SkString> configs; 199 SkTArray<SkString> configs;
208 for (int i = 0; i < FLAGS_config.count(); i++) { 200 for (int i = 0; i < FLAGS_config.count(); i++) {
209 SkStrSplit(FLAGS_config[i], ", ", &configs); 201 SkStrSplit(FLAGS_config[i], ", ", &configs);
210 } 202 }
211 203
212 GrGLStandard gpuAPI = get_gl_standard(); 204 GrGLStandard gpuAPI = get_gl_standard();
213 205
214 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::Expectations));
215 if (FLAGS_expectations.count() > 0) {
216 expectations.reset(DM::WriteTask::Expectations::Create(FLAGS_expectation s[0]));
217 if (!expectations.get()) {
218 return 1;
219 }
220 }
221
222 SkTDArray<GMRegistry::Factory> gms; 206 SkTDArray<GMRegistry::Factory> gms;
223 if (FLAGS_gms) { 207 if (FLAGS_gms) {
224 append_matching_factories<GM>(GMRegistry::Head(), &gms); 208 append_matching_factories<GM>(GMRegistry::Head(), &gms);
225 } 209 }
226 210
227 SkTDArray<TestRegistry::Factory> tests; 211 SkTDArray<TestRegistry::Factory> tests;
228 if (FLAGS_tests) { 212 if (FLAGS_tests) {
229 append_matching_factories<Test>(TestRegistry::Head(), &tests); 213 append_matching_factories<Test>(TestRegistry::Head(), &tests);
230 } 214 }
231 215
232 SkTArray<SkString> skps; 216 SkTArray<SkString> skps;
233 find_skps(&skps); 217 find_skps(&skps);
234 218
235 SkDebugf("%d GMs x %d configs, %d tests, %d pictures\n", 219 SkDebugf("%d GMs x %d configs, %d tests, %d pictures\n",
236 gms.count(), configs.count(), tests.count(), skps.count()); 220 gms.count(), configs.count(), tests.count(), skps.count());
237 DM::Reporter reporter; 221 DM::Reporter reporter;
238 222
239 DM::TaskRunner tasks; 223 DM::TaskRunner tasks;
240 kick_off_tests(tests, &reporter, &tasks); 224 kick_off_tests(tests, &reporter, &tasks);
241 kick_off_gms(gms, configs, gpuAPI, *expectations, &reporter, &tasks); 225 kick_off_gms(gms, configs, gpuAPI, &reporter, &tasks);
242 kick_off_skps(skps, *expectations, &reporter, &tasks); 226 kick_off_skps(skps, &reporter, &tasks);
243 tasks.wait(); 227 tasks.wait();
244 228
245 DM::WriteTask::DumpJson(); 229 DM::WriteTask::DumpJson();
246 230
247 SkDebugf("\n"); 231 SkDebugf("\n");
248 #ifdef SK_DEBUG 232 #ifdef SK_DEBUG
249 if (FLAGS_portableFonts && FLAGS_reportUsedChars) { 233 if (FLAGS_portableFonts && FLAGS_reportUsedChars) {
250 sk_tool_utils::report_used_chars(); 234 sk_tool_utils::report_used_chars();
251 } 235 }
252 #endif 236 #endif
253 237
254 SkTArray<SkString> failures; 238 SkTArray<SkString> failures;
255 reporter.getFailures(&failures); 239 reporter.getFailures(&failures);
256 report_failures(failures); 240 report_failures(failures);
257 return failures.count() > 0; 241 return failures.count() > 0;
258 } 242 }
259 243
260 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 244 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
261 int main(int argc, char** argv) { 245 int main(int argc, char** argv) {
262 SkCommandLineFlags::Parse(argc, argv); 246 SkCommandLineFlags::Parse(argc, argv);
263 return dm_main(); 247 return dm_main();
264 } 248 }
265 #endif 249 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMCpuGMTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698