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

Side by Side Diff: dm/DM.cpp

Issue 22839016: Skeleton of DM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: missed one Created 7 years, 2 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
« no previous file with comments | « no previous file | dm/DMComparisonTask.h » ('j') | dm/DMCpuTask.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "GrContext.h"
epoger 2013/10/11 21:13:13 High-level suggestion: Explore using the existing
mtklein 2013/10/15 18:30:53 Uh, that's a nice idea but I'm explicitly not cari
epoger 2013/10/15 18:52:37 Well, at some point I suppose the goal is to switc
bsalomon 2013/10/15 18:58:55 When we get to that step, can we please make DM em
2 #include "GrContextFactory.h"
3 #include "SkCommandLineFlags.h"
4 #include "SkForceLinking.h"
5 #include "SkGraphics.h"
6 #include "gm.h"
7
8 #include "DMReporter.h"
9 #include "DMTask.h"
10 #include "DMTaskRunner.h"
11 #include "DMCpuTask.h"
12 #include "DMGpuTask.h"
13
14 using skiagm::GM;
15 using skiagm::GMRegistry;
16 using skiagm::Expectations;
17 using skiagm::ExpectationsSource;
18 using skiagm::JsonExpectationsSource;
19
20 DEFINE_int32(cpuThreads, -1, "Threads for CPU work. Default NUM_CPUS.");
21 DEFINE_int32(gpuThreads, 1, "Threads for GPU work.");
22 DEFINE_string(expectations, "", "If set, check expectations against files found at this path.");
epoger 2013/10/11 21:13:13 "check expectations" -> "compare generated images"
mtklein 2013/10/15 18:30:53 Done.
23 DEFINE_string(resources, "resources", "Path to resources directory.");
24 DEFINE_bool(verbose, false, "Print more.");
25 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n"
26 "Multiple matches may be separated by spaces.\n"
27 "~ causes a matching GM to always be skipped\n"
28 "^ requires the start of the GM to match\n"
29 "$ requires the end of the GM to match\n"
30 "^ and $ requires an exact match\n"
31 "If a GM does not match any list entry,\n"
32 "it is skipped unless some list entry starts with ~\n" );
33
34 DEFINE_bool(565, false, "Run 565?");
bsalomon 2013/10/10 21:13:07 Hmm... most of our other tools work like --config
mtklein 2013/10/10 22:32:19 Yeah, either way works. This one was a bit of an
epoger 2013/10/11 21:13:13 Personally, I prefer "--configs gpu 8888" to "--gp
bsalomon 2013/10/11 21:18:58 I'd just add that the gpu vs GPU naming is kind of
mtklein 2013/10/15 18:30:53 Okay. I've switched to a single --config. I've p
35 DEFINE_bool(8888, true, "Run 8888?");
36 DEFINE_bool(gpu, true, "Run gpu?");
37 DEFINE_bool(msaa4, false, "Run msaa4?");
38 DEFINE_bool(msaa16, false, "Run msaa16?");
39 DEFINE_bool(gpunull, false, "Run gpunull?");
40 DEFINE_bool(gpudebug, false, "Run gpudebug?");
41 DEFINE_bool(angle, false, "Run angle?");
42 DEFINE_bool(mesa, false, "Run mesa?");
43 //DEFINE_bool(pdf, false, "Run pdf?"); // TODO(mtklein)
epoger 2013/10/11 21:13:13 Maybe use an #ifdef to disable PDF, so you don't n
mtklein 2013/10/15 18:30:53 Thanks. I think I'll be able to handle the commen
44
45 __SK_FORCE_IMAGE_DECODER_LINKING;
46
47 void KickOffTasks(const SkTDArray<GMRegistry::Factory>& gms,
48 const ExpectationsSource& expectations,
49 DM::Reporter* reporter,
50 DM::TaskRunner* tasks) {
51 const SkBitmap::Config _565 = SkBitmap::kRGB_565_Config;
52 const SkBitmap::Config _8888 = SkBitmap::kARGB_8888_Config;
53 const GrContextFactory::GLContextType native = GrContextFactory::kNative_GLC ontextType;
54 const GrContextFactory::GLContextType null = GrContextFactory::kNull_GLCon textType;
55 const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_GLCo ntextType;
56 const GrContextFactory::GLContextType angle =
57 #if SK_ANGLE
58 GrContextFactory::kANGLE_GLContextType;
59 #else
60 native;
61 #endif
62 const GrContextFactory::GLContextType mesa =
63 #if SK_MESA
64 GLContextFactory::kMESA_GLContextType;
65 #else
66 native;
67 #endif
68
69 #define START(name, type, ...) \
70 if (FLAGS_##name) { \
71 tasks->add(SkNEW_ARGS(DM::type, \
72 (#name, reporter, tasks, expectations, gms[i], __VA_ARGS__)) ); \
73 }
74
75 for (int i = 0; i < gms.count(); i++) {
76 SkAutoTDelete<GM> gmForName(gms[i](NULL));
77 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, gmForName->shortName())) continue;
78
79 START(565, CpuTask, _565);
80 START(8888, CpuTask, _8888);
81 START(gpu, GpuTask, _8888, native, 0);
82 START(msaa4, GpuTask, _8888, native, 4);
83 START(msaa16, GpuTask, _8888, native, 16);
84 START(gpunull, GpuTask, _8888, null, 0);
85 START(gpudebug, GpuTask, _8888, debug, 0);
86 START(angle, GpuTask, _8888, angle, 0);
87 START(mesa, GpuTask, _8888, mesa, 0);
88 //START(pdf, PdfTask, _8888);
89 }
90 #undef START
91 }
92
93 void ReportFailures(const DM::Reporter& reporter) {
94 SkTArray<SkString> failures;
95 reporter.getFailures(&failures);
96
97 if (failures.count() == 0) {
98 return;
99 }
100
101 SkDebugf("Failures:\n");
102 for (int i = 0; i < failures.count(); i++) {
103 SkDebugf(" %s\n", failures[i].c_str());
104 }
105 }
106
107 class NoExpectations : public ExpectationsSource {
108 public:
109 Expectations get(const char* /*testName*/) const SK_OVERRIDE {
110 return Expectations(true /*ignore failures*/);
111 }
112 };
113
114
115 int main(int argc, char** argv) {
epoger 2013/10/11 21:13:13 A few comments within here would be nice
mtklein 2013/10/15 18:30:53 Added a note to the top.
116 SkGraphics::Init();
117 SkCommandLineFlags::Parse(argc, argv);
118 GM::SetResourcePath(FLAGS_resources[0]);
119
120 SkTDArray<GMRegistry::Factory> gms;
121 for (const GMRegistry* reg = GMRegistry::Head(); reg != NULL; reg = reg->nex t()) {
122 *gms.append() = reg->factory();
123 }
124 SkDebugf("%d GMs\n", gms.count());
125
126 SkAutoTUnref<ExpectationsSource> expectations(SkNEW(NoExpectations));
127 if (FLAGS_expectations.count() > 0) {
128 SkString expectationsPath(FLAGS_expectations[0]);
129 expectationsPath += "/expected-results.json";
epoger 2013/10/11 21:13:13 Why not just allow the user to pass the full path,
mtklein 2013/10/15 18:30:53 Done.
130 expectations.reset(SkNEW_ARGS(JsonExpectationsSource, (expectationsPath. c_str())));
131 }
132
133 DM::Reporter reporter;
134 DM::TaskRunner tasks(FLAGS_cpuThreads, FLAGS_gpuThreads);
135 KickOffTasks(gms, *expectations, &reporter, &tasks);
136 tasks.wait();
137
138 reporter.UpdateStatusLine();
139 SkDebugf("\n");
140
141 if (FLAGS_verbose) {
142 ReportFailures(reporter);
143 }
144
145 SkGraphics::Term();
146
147 return reporter.failed() > 0;
148 }
OLDNEW
« no previous file with comments | « no previous file | dm/DMComparisonTask.h » ('j') | dm/DMCpuTask.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698