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

Side by Side Diff: dm/DM.cpp

Issue 108963002: DM: Add support for reading a directory of images with --expectations (-r). (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments etc Created 7 years 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/DMChecksumTask.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 "GrContext.h" 4 #include "GrContext.h"
5 #include "GrContextFactory.h" 5 #include "GrContextFactory.h"
6 #include "SkCommandLineFlags.h" 6 #include "SkCommandLineFlags.h"
7 #include "SkForceLinking.h" 7 #include "SkForceLinking.h"
8 #include "SkGraphics.h" 8 #include "SkGraphics.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include "gm.h" 10 #include "gm.h"
11 11
12 #include "DMReporter.h" 12 #include "DMReporter.h"
13 #include "DMTask.h" 13 #include "DMTask.h"
14 #include "DMTaskRunner.h" 14 #include "DMTaskRunner.h"
15 #include "DMCpuTask.h" 15 #include "DMCpuTask.h"
16 #include "DMGpuTask.h" 16 #include "DMGpuTask.h"
17 #include "DMWriteTask.h"
17 18
18 #include <string.h> 19 #include <string.h>
19 20
20 using skiagm::GM; 21 using skiagm::GM;
21 using skiagm::GMRegistry; 22 using skiagm::GMRegistry;
22 using skiagm::Expectations;
23 using skiagm::ExpectationsSource;
24 using skiagm::JsonExpectationsSource;
25 23
26 DEFINE_int32(cpuThreads, -1, "Threads for CPU work. Default NUM_CPUS."); 24 DEFINE_int32(cpuThreads, -1, "Threads for CPU work. Default NUM_CPUS.");
27 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); 25 DEFINE_int32(gpuThreads, 1, "Threads for GPU work.");
28 DEFINE_string(expectations, "", "Compare generated images against JSON expectati ons at this path."); 26 DEFINE_string2(expectations, r, "",
27 "If a directory, compare generated images against images under th is path. "
28 "If a file, compare generated images against JSON expectations at this path.");
29 DEFINE_string(resources, "resources", "Path to resources directory."); 29 DEFINE_string(resources, "resources", "Path to resources directory.");
30 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" 30 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n"
31 "Multiple matches may be separated by spaces.\n" 31 "Multiple matches may be separated by spaces.\n"
32 "~ causes a matching GM to always be skipped\n" 32 "~ causes a matching GM to always be skipped\n"
33 "^ requires the start of the GM to match\n" 33 "^ requires the start of the GM to match\n"
34 "$ requires the end of the GM to match\n" 34 "$ requires the end of the GM to match\n"
35 "^ and $ requires an exact match\n" 35 "^ and $ requires an exact match\n"
36 "If a GM does not match any list entry,\n" 36 "If a GM does not match any list entry,\n"
37 "it is skipped unless some list entry starts with ~"); 37 "it is skipped unless some list entry starts with ~");
38 DEFINE_string(config, "8888 gpu", 38 DEFINE_string(config, "8888 gpu",
39 "Options: 565 8888 gpu msaa4 msaa16 gpunull gpudebug angle mesa"); // TO DO(mtklein): pdf 39 "Options: 565 8888 gpu msaa4 msaa16 gpunull gpudebug angle mesa"); // TO DO(mtklein): pdf
40 40
41 __SK_FORCE_IMAGE_DECODER_LINKING; 41 __SK_FORCE_IMAGE_DECODER_LINKING;
42 42
43 // "FooBar" -> "foobar". Obviously, ASCII only. 43 // "FooBar" -> "foobar". Obviously, ASCII only.
44 static SkString lowercase(SkString s) { 44 static SkString lowercase(SkString s) {
45 for (size_t i = 0; i < s.size(); i++) { 45 for (size_t i = 0; i < s.size(); i++) {
46 s[i] = tolower(s[i]); 46 s[i] = tolower(s[i]);
47 } 47 }
48 return s; 48 return s;
49 } 49 }
50 50
51 static void kick_off_tasks(const SkTDArray<GMRegistry::Factory>& gms, 51 static void kick_off_tasks(const SkTDArray<GMRegistry::Factory>& gms,
52 const SkTArray<SkString>& configs, 52 const SkTArray<SkString>& configs,
53 const ExpectationsSource& expectations, 53 const DM::Expectations& expectations,
54 DM::Reporter* reporter, 54 DM::Reporter* reporter,
55 DM::TaskRunner* tasks) { 55 DM::TaskRunner* tasks) {
56 const SkBitmap::Config _565 = SkBitmap::kRGB_565_Config; 56 const SkBitmap::Config _565 = SkBitmap::kRGB_565_Config;
57 const SkBitmap::Config _8888 = SkBitmap::kARGB_8888_Config; 57 const SkBitmap::Config _8888 = SkBitmap::kARGB_8888_Config;
58 const GrContextFactory::GLContextType native = GrContextFactory::kNative_GLC ontextType; 58 const GrContextFactory::GLContextType native = GrContextFactory::kNative_GLC ontextType;
59 const GrContextFactory::GLContextType null = GrContextFactory::kNull_GLCon textType; 59 const GrContextFactory::GLContextType null = GrContextFactory::kNull_GLCon textType;
60 const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_GLCo ntextType; 60 const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_GLCo ntextType;
61 const GrContextFactory::GLContextType angle = 61 const GrContextFactory::GLContextType angle =
62 #if SK_ANGLE 62 #if SK_ANGLE
63 GrContextFactory::kANGLE_GLContextType; 63 GrContextFactory::kANGLE_GLContextType;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (failures.count() == 0) { 100 if (failures.count() == 0) {
101 return; 101 return;
102 } 102 }
103 103
104 SkDebugf("Failures:\n"); 104 SkDebugf("Failures:\n");
105 for (int i = 0; i < failures.count(); i++) { 105 for (int i = 0; i < failures.count(); i++) {
106 SkDebugf(" %s\n", failures[i].c_str()); 106 SkDebugf(" %s\n", failures[i].c_str());
107 } 107 }
108 } 108 }
109 109
110 class NoExpectations : public ExpectationsSource {
111 public:
112 Expectations get(const char* /*testName*/) const SK_OVERRIDE {
113 return Expectations();
114 }
115 };
116
117 int tool_main(int argc, char** argv); 110 int tool_main(int argc, char** argv);
118 int tool_main(int argc, char** argv) { 111 int tool_main(int argc, char** argv) {
119 SkGraphics::Init(); 112 SkGraphics::Init();
120 113
121 SkCommandLineFlags::Parse(argc, argv); 114 SkCommandLineFlags::Parse(argc, argv);
122 GM::SetResourcePath(FLAGS_resources[0]); 115 GM::SetResourcePath(FLAGS_resources[0]);
123 SkTArray<SkString> configs; 116 SkTArray<SkString> configs;
124 for (int i = 0; i < FLAGS_config.count(); i++) { 117 for (int i = 0; i < FLAGS_config.count(); i++) {
125 SkStrSplit(FLAGS_config[i], ", ", &configs); 118 SkStrSplit(FLAGS_config[i], ", ", &configs);
126 } 119 }
127 120
128 SkTDArray<GMRegistry::Factory> gms; 121 SkTDArray<GMRegistry::Factory> gms;
129 for (const GMRegistry* reg = GMRegistry::Head(); reg != NULL; reg = reg->nex t()) { 122 for (const GMRegistry* reg = GMRegistry::Head(); reg != NULL; reg = reg->nex t()) {
130 SkAutoTDelete<GM> gmForName(reg->factory()(NULL)); 123 SkAutoTDelete<GM> gmForName(reg->factory()(NULL));
131 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, gmForName->shortName()) ) { 124 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, gmForName->shortName()) ) {
132 *gms.append() = reg->factory(); 125 *gms.append() = reg->factory();
133 } 126 }
134 } 127 }
135 SkDebugf("%d GMs x %d configs\n", gms.count(), configs.count()); 128 SkDebugf("%d GMs x %d configs\n", gms.count(), configs.count());
136 129
137 SkAutoTUnref<ExpectationsSource> expectations(SkNEW(NoExpectations)); 130 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations));
138 if (FLAGS_expectations.count() > 0) { 131 if (FLAGS_expectations.count() > 0) {
139 expectations.reset(SkNEW_ARGS(JsonExpectationsSource, (FLAGS_expectation s[0]))); 132 const char* path = FLAGS_expectations[0];
133 if (sk_isdir(path)) {
134 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path)));
135 } else {
136 expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path)));
137 }
140 } 138 }
141 139
142 DM::Reporter reporter; 140 DM::Reporter reporter;
143 DM::TaskRunner tasks(FLAGS_cpuThreads, FLAGS_gpuThreads); 141 DM::TaskRunner tasks(FLAGS_cpuThreads, FLAGS_gpuThreads);
144 kick_off_tasks(gms, configs, *expectations, &reporter, &tasks); 142 kick_off_tasks(gms, configs, *expectations, &reporter, &tasks);
145 tasks.wait(); 143 tasks.wait();
146 144
147 reporter.updateStatusLine(); 145 reporter.updateStatusLine();
148 SkDebugf("\n"); 146 SkDebugf("\n");
149 report_failures(reporter); 147 report_failures(reporter);
150 148
151 SkGraphics::Term(); 149 SkGraphics::Term();
152 150
153 return reporter.failed() > 0; 151 return reporter.failed() > 0;
154 } 152 }
155 153
156 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 154 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
157 int main(int argc, char** argv) { 155 int main(int argc, char** argv) {
158 return tool_main(argc, argv); 156 return tool_main(argc, argv);
159 } 157 }
160 #endif 158 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMChecksumTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698