OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
11 #include "DMSrcSinkAndroid.h" | 11 #include "DMSrcSinkAndroid.h" |
12 #include "OverwriteLine.h" | 12 #include "OverwriteLine.h" |
13 #include "ProcStats.h" | 13 #include "ProcStats.h" |
14 #include "SkBBHFactory.h" | 14 #include "SkBBHFactory.h" |
15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
16 #include "SkCommonFlags.h" | 16 #include "SkCommonFlags.h" |
17 #include "SkForceLinking.h" | 17 #include "SkForceLinking.h" |
18 #include "SkGraphics.h" | 18 #include "SkGraphics.h" |
19 #include "SkInstCnt.h" | 19 #include "SkInstCnt.h" |
20 #include "SkMD5.h" | 20 #include "SkMD5.h" |
21 #include "SkOSFile.h" | 21 #include "SkOSFile.h" |
22 #include "SkTHash.h" | 22 #include "SkTHash.h" |
23 #include "SkTaskGroup.h" | 23 #include "SkTaskGroup.h" |
24 #include "SkThreadUtils.h" | 24 #include "SkThreadUtils.h" |
25 #include "Test.h" | 25 #include "Test.h" |
26 #include "Timer.h" | 26 #include "Timer.h" |
27 | 27 |
28 DEFINE_string(src, "tests gm skp image subset codec scanline", "Source types to
test."); | 28 DEFINE_string(src, "tests gm skp image", "Source types to test."); |
29 DEFINE_bool(nameByHash, false, | 29 DEFINE_bool(nameByHash, false, |
30 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " | 30 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " |
31 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); | 31 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.
png"); |
32 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); | 32 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
33 DEFINE_string(matrix, "1 0 0 1", | 33 DEFINE_string(matrix, "1 0 0 1", |
34 "2x2 scale+skew matrix to apply or upright when using " | 34 "2x2 scale+skew matrix to apply or upright when using " |
35 "'matrix' or 'upright' in config."); | 35 "'matrix' or 'upright' in config."); |
36 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); | 36 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); |
37 | 37 |
38 DEFINE_string(blacklist, "", | 38 DEFINE_string(blacklist, "", |
39 "Space-separated config/src/name triples to blacklist. '_' matches anyt
hing. E.g. \n" | 39 "Space-separated config/src/srcOptions/name quadruples to blacklist. '_
' matches anything. E.g. \n" |
40 "'--blacklist gpu skp _' will blacklist all SKPs drawn into the gpu conf
ig.\n" | 40 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu co
nfig.\n" |
41 "'--blacklist gpu skp _ 8888 gm aarects' will also blacklist the aarects
GM on 8888."); | 41 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aar
ects GM on 8888."); |
42 | 42 |
43 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i
n this directory."); | 43 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i
n this directory."); |
44 | 44 |
45 __SK_FORCE_IMAGE_DECODER_LINKING; | 45 __SK_FORCE_IMAGE_DECODER_LINKING; |
46 using namespace DM; | 46 using namespace DM; |
47 | 47 |
48 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 48 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
49 | 49 |
50 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); | 50 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
51 static SkTArray<SkString> gFailures; | 51 static SkTArray<SkString> gFailures; |
52 | 52 |
53 static void fail(ImplicitString err) { | 53 static void fail(ImplicitString err) { |
54 SkAutoMutexAcquire lock(gFailuresMutex); | 54 SkAutoMutexAcquire lock(gFailuresMutex); |
55 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); | 55 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
56 gFailures.push_back(err); | 56 gFailures.push_back(err); |
57 } | 57 } |
58 | 58 |
59 static int32_t gPending = 0; // Atomic. Total number of running and queued tas
ks. | 59 static int32_t gPending = 0; // Atomic. Total number of running and queued tas
ks. |
60 | 60 |
61 SK_DECLARE_STATIC_MUTEX(gRunningMutex); | 61 SK_DECLARE_STATIC_MUTEX(gRunningMutex); |
62 static SkTArray<SkString> gRunning; | 62 static SkTArray<SkString> gRunning; |
63 | 63 |
64 static void done(double ms, | 64 static void done(double ms, |
65 ImplicitString config, ImplicitString src, ImplicitString name, | 65 ImplicitString config, ImplicitString src, ImplicitString srcOp
tions, |
66 ImplicitString note, ImplicitString log) { | 66 ImplicitString name, ImplicitString note, ImplicitString log) { |
67 SkString id = SkStringPrintf("%s %s %s", config.c_str(), src.c_str(), name.c
_str()); | 67 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), |
| 68 srcOptions.c_str(), name.c_str()
); |
68 { | 69 { |
69 SkAutoMutexAcquire lock(gRunningMutex); | 70 SkAutoMutexAcquire lock(gRunningMutex); |
70 for (int i = 0; i < gRunning.count(); i++) { | 71 for (int i = 0; i < gRunning.count(); i++) { |
71 if (gRunning[i] == id) { | 72 if (gRunning[i] == id) { |
72 gRunning.removeShuffle(i); | 73 gRunning.removeShuffle(i); |
73 break; | 74 break; |
74 } | 75 } |
75 } | 76 } |
76 } | 77 } |
77 if (!FLAGS_verbose) { | 78 if (!FLAGS_verbose) { |
(...skipping 10 matching lines...) Expand all Loading... |
88 , id.c_str() | 89 , id.c_str() |
89 , note.c_str() | 90 , note.c_str() |
90 , log.c_str()); | 91 , log.c_str()); |
91 // We write our dm.json file every once in a while in case we crash. | 92 // We write our dm.json file every once in a while in case we crash. |
92 // Notice this also handles the final dm.json when pending == 0. | 93 // Notice this also handles the final dm.json when pending == 0. |
93 if (pending % 500 == 0) { | 94 if (pending % 500 == 0) { |
94 JsonWriter::DumpJson(); | 95 JsonWriter::DumpJson(); |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 static void start(ImplicitString config, ImplicitString src, ImplicitString name
) { | 99 static void start(ImplicitString config, ImplicitString src, |
99 SkString id = SkStringPrintf("%s %s %s", config.c_str(), src.c_str(), name.c
_str()); | 100 ImplicitString srcOptions, ImplicitString name) { |
| 101 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), |
| 102 srcOptions.c_str(), name.c_str()
); |
100 SkAutoMutexAcquire lock(gRunningMutex); | 103 SkAutoMutexAcquire lock(gRunningMutex); |
101 gRunning.push_back(id); | 104 gRunning.push_back(id); |
102 } | 105 } |
103 | 106 |
104 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 107 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
105 | 108 |
106 struct Gold : public SkString { | 109 struct Gold : public SkString { |
107 Gold() : SkString("") {} | 110 Gold() : SkString("") {} |
108 Gold(ImplicitString sink, ImplicitString src, ImplicitString name, ImplicitS
tring md5) | 111 Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions, |
| 112 ImplicitString name, ImplicitString md5) |
109 : SkString("") { | 113 : SkString("") { |
110 this->append(sink); | 114 this->append(sink); |
111 this->append(src); | 115 this->append(src); |
| 116 this->append(srcOptions); |
112 this->append(name); | 117 this->append(name); |
113 this->append(md5); | 118 this->append(md5); |
114 } | 119 } |
115 static uint32_t Hash(const Gold& g) { return SkGoodHash((const SkString&)g);
} | 120 static uint32_t Hash(const Gold& g) { return SkGoodHash((const SkString&)g);
} |
116 }; | 121 }; |
117 static SkTHashSet<Gold, Gold::Hash> gGold; | 122 static SkTHashSet<Gold, Gold::Hash> gGold; |
118 | 123 |
119 static void add_gold(JsonWriter::BitmapResult r) { | 124 static void add_gold(JsonWriter::BitmapResult r) { |
120 gGold.add(Gold(r.config, r.sourceType, r.name, r.md5)); | 125 gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5)); |
121 } | 126 } |
122 | 127 |
123 static void gather_gold() { | 128 static void gather_gold() { |
124 if (!FLAGS_readPath.isEmpty()) { | 129 if (!FLAGS_readPath.isEmpty()) { |
125 SkString path(FLAGS_readPath[0]); | 130 SkString path(FLAGS_readPath[0]); |
126 path.append("/dm.json"); | 131 path.append("/dm.json"); |
127 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { | 132 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { |
128 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s
tr())); | 133 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s
tr())); |
129 } | 134 } |
130 } | 135 } |
131 } | 136 } |
132 | 137 |
133 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 138 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
134 | 139 |
135 template <typename T> | 140 template <typename T> |
136 struct Tagged : public SkAutoTDelete<T> { const char* tag; }; | 141 struct Tagged : public SkAutoTDelete<T> { |
| 142 const char* tag; |
| 143 const char* options; |
| 144 }; |
137 | 145 |
138 static const bool kMemcpyOK = true; | 146 static const bool kMemcpyOK = true; |
139 | 147 |
140 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; | 148 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; |
141 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; | 149 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; |
142 | 150 |
143 static void push_src(const char* tag, Src* s) { | 151 static void push_src(const char* tag, const char* options, Src* s) { |
144 SkAutoTDelete<Src> src(s); | 152 SkAutoTDelete<Src> src(s); |
145 if (FLAGS_src.contains(tag) && | 153 if (FLAGS_src.contains(tag) && |
146 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 154 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
147 Tagged<Src>& s = gSrcs.push_back(); | 155 Tagged<Src>& s = gSrcs.push_back(); |
148 s.reset(src.detach()); | 156 s.reset(src.detach()); |
149 s.tag = tag; | 157 s.tag = tag; |
| 158 s.options = options; |
150 } | 159 } |
151 } | 160 } |
152 | 161 |
153 static bool codec_supported(const char* ext) { | 162 static bool codec_supported(const char* ext) { |
154 // FIXME: Once other versions of SkCodec are available, we can add them to t
his | 163 // FIXME: Once other versions of SkCodec are available, we can add them to t
his |
155 // list (and eventually we can remove this check once they are all supported
). | 164 // list (and eventually we can remove this check once they are all supported
). |
156 static const char* const exts[] = { | 165 static const char* const exts[] = { |
157 "bmp", "gif", "png", "ico", "wbmp", | 166 "bmp", "gif", "png", "ico", "wbmp", |
158 "BMP", "GIF", "PNG", "ICO", "WBMP" | 167 "BMP", "GIF", "PNG", "ICO", "WBMP" |
159 }; | 168 }; |
160 | 169 |
161 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 170 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
162 if (0 == strcmp(exts[i], ext)) { | 171 if (0 == strcmp(exts[i], ext)) { |
163 return true; | 172 return true; |
164 } | 173 } |
165 } | 174 } |
166 return false; | 175 return false; |
167 } | 176 } |
168 | 177 |
169 static void gather_srcs() { | 178 static void gather_srcs() { |
170 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->nex
t()) { | 179 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->nex
t()) { |
171 push_src("gm", new GMSrc(r->factory())); | 180 push_src("gm", "", new GMSrc(r->factory())); |
172 } | 181 } |
173 for (int i = 0; i < FLAGS_skps.count(); i++) { | 182 for (int i = 0; i < FLAGS_skps.count(); i++) { |
174 const char* path = FLAGS_skps[i]; | 183 const char* path = FLAGS_skps[i]; |
175 if (sk_isdir(path)) { | 184 if (sk_isdir(path)) { |
176 SkOSFile::Iter it(path, "skp"); | 185 SkOSFile::Iter it(path, "skp"); |
177 for (SkString file; it.next(&file); ) { | 186 for (SkString file; it.next(&file); ) { |
178 push_src("skp", new SKPSrc(SkOSPath::Join(path, file.c_str()))); | 187 push_src("skp", "", new SKPSrc(SkOSPath::Join(path, file.c_str()
))); |
179 } | 188 } |
180 } else { | 189 } else { |
181 push_src("skp", new SKPSrc(path)); | 190 push_src("skp", "", new SKPSrc(path)); |
182 } | 191 } |
183 } | 192 } |
184 static const char* const exts[] = { | 193 static const char* const exts[] = { |
185 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico"
, | 194 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico"
, |
186 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO"
, | 195 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO"
, |
187 }; | 196 }; |
188 for (int i = 0; i < FLAGS_images.count(); i++) { | 197 for (int i = 0; i < FLAGS_images.count(); i++) { |
189 const char* flag = FLAGS_images[i]; | 198 const char* flag = FLAGS_images[i]; |
190 if (sk_isdir(flag)) { | 199 if (sk_isdir(flag)) { |
191 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 200 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
192 SkOSFile::Iter it(flag, exts[j]); | 201 SkOSFile::Iter it(flag, exts[j]); |
193 for (SkString file; it.next(&file); ) { | 202 for (SkString file; it.next(&file); ) { |
194 SkString path = SkOSPath::Join(flag, file.c_str()); | 203 SkString path = SkOSPath::Join(flag, file.c_str()); |
195 push_src("image", new ImageSrc(path)); // Decode entire
image. | 204 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image |
196 push_src("subset", new ImageSrc(path, 2)); // Decode into 2
x 2 subsets | 205 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets |
197 if (codec_supported(exts[j])) { | 206 if (codec_supported(exts[j])) { |
198 push_src("codec", new CodecSrc(path, CodecSrc::kNormal_M
ode)); | 207 push_src("image", "codec", new CodecSrc(path, CodecSrc::
kNormal_Mode)); |
199 push_src("scanline", new CodecSrc(path, CodecSrc::kScanl
ine_Mode)); | 208 push_src("image", "scanline", new CodecSrc(path, CodecSr
c::kScanline_Mode)); |
200 } | 209 } |
201 } | 210 } |
202 } | 211 } |
203 } else if (sk_exists(flag)) { | 212 } else if (sk_exists(flag)) { |
204 // assume that FLAGS_images[i] is a valid image if it is a file. | 213 // assume that FLAGS_images[i] is a valid image if it is a file. |
205 push_src("image", new ImageSrc(flag)); // Decode entire image. | 214 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. |
206 push_src("subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subs
ets | 215 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets |
207 push_src("codec", new CodecSrc(flag, CodecSrc::kNormal_Mode)); | 216 push_src("image", "codec", new CodecSrc(flag, CodecSrc::kNormal_Mode
)); |
208 push_src("scanline", new CodecSrc(flag, CodecSrc::kScanline_Mode)); | 217 push_src("image", "scanline", new CodecSrc(flag, CodecSrc::kScanline
_Mode)); |
209 } | 218 } |
210 } | 219 } |
211 } | 220 } |
212 | 221 |
213 static GrGLStandard get_gpu_api() { | 222 static GrGLStandard get_gpu_api() { |
214 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 223 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
215 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 224 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
216 return kNone_GrGLStandard; | 225 return kNone_GrGLStandard; |
217 } | 226 } |
218 | 227 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 if (sink) { | 344 if (sink) { |
336 push_sink(config, sink); | 345 push_sink(config, sink); |
337 } | 346 } |
338 } | 347 } |
339 } | 348 } |
340 | 349 |
341 static bool match(const char* needle, const char* haystack) { | 350 static bool match(const char* needle, const char* haystack) { |
342 return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle); | 351 return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle); |
343 } | 352 } |
344 | 353 |
345 static ImplicitString is_blacklisted(const char* sink, const char* src, const ch
ar* name) { | 354 static ImplicitString is_blacklisted(const char* sink, const char* src, |
346 for (int i = 0; i < FLAGS_blacklist.count() - 2; i += 3) { | 355 const char* srcOptions, const char* name) { |
| 356 for (int i = 0; i < FLAGS_blacklist.count() - 2; i += 4) { |
347 if (match(FLAGS_blacklist[i+0], sink) && | 357 if (match(FLAGS_blacklist[i+0], sink) && |
348 match(FLAGS_blacklist[i+1], src) && | 358 match(FLAGS_blacklist[i+1], src) && |
349 match(FLAGS_blacklist[i+2], name)) { | 359 match(FLAGS_blacklist[i+2], srcOptions) && |
350 return SkStringPrintf("%s %s %s", | 360 match(FLAGS_blacklist[i+3], name)) { |
351 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], FL
AGS_blacklist[i+2]); | 361 return SkStringPrintf("%s %s %s %s", |
| 362 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], |
| 363 FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]); |
352 } | 364 } |
353 } | 365 } |
354 return ""; | 366 return ""; |
355 } | 367 } |
356 | 368 |
357 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, | 369 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, |
358 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. | 370 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. |
359 struct Task { | 371 struct Task { |
360 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} | 372 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} |
361 const Tagged<Src>& src; | 373 const Tagged<Src>& src; |
362 const Tagged<Sink>& sink; | 374 const Tagged<Sink>& sink; |
363 | 375 |
364 static void Run(Task* task) { | 376 static void Run(Task* task) { |
365 SkString name = task->src->name(); | 377 SkString name = task->src->name(); |
366 SkString note; | 378 SkString note; |
367 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag,
name.c_str()); | 379 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, |
| 380 task->src.options, name.c_str()
); |
368 if (!whyBlacklisted.isEmpty()) { | 381 if (!whyBlacklisted.isEmpty()) { |
369 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); | 382 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
370 } | 383 } |
371 SkString log; | 384 SkString log; |
372 WallTimer timer; | 385 WallTimer timer; |
373 timer.start(); | 386 timer.start(); |
374 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { | 387 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { |
375 SkBitmap bitmap; | 388 SkBitmap bitmap; |
376 SkDynamicMemoryWStream stream; | 389 SkDynamicMemoryWStream stream; |
377 start(task->sink.tag, task->src.tag, name.c_str()); | 390 start(task->sink.tag, task->src.tag, task->src.options, name.c_str()
); |
378 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); | 391 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
379 if (!err.isEmpty()) { | 392 if (!err.isEmpty()) { |
380 timer.end(); | 393 timer.end(); |
381 if (err.isFatal()) { | 394 if (err.isFatal()) { |
382 fail(SkStringPrintf("%s %s %s: %s", | 395 fail(SkStringPrintf("%s %s %s %s: %s", |
383 task->sink.tag, | 396 task->sink.tag, |
384 task->src.tag, | 397 task->src.tag, |
| 398 task->src.options, |
385 name.c_str(), | 399 name.c_str(), |
386 err.c_str())); | 400 err.c_str())); |
387 } else { | 401 } else { |
388 note.appendf(" (skipped: %s)", err.c_str()); | 402 note.appendf(" (skipped: %s)", err.c_str()); |
389 } | 403 } |
390 done(timer.fWall, task->sink.tag, task->src.tag, name, note, log
); | 404 done(timer.fWall, task->sink.tag, task->src.tag, task->src.optio
ns, |
| 405 name, note, log); |
391 return; | 406 return; |
392 } | 407 } |
393 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); | 408 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
394 | 409 |
395 SkString md5; | 410 SkString md5; |
396 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { | 411 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { |
397 SkMD5 hash; | 412 SkMD5 hash; |
398 if (data->getLength()) { | 413 if (data->getLength()) { |
399 hash.writeStream(data, data->getLength()); | 414 hash.writeStream(data, data->getLength()); |
400 data->rewind(); | 415 data->rewind(); |
401 } else { | 416 } else { |
402 hash.write(bitmap.getPixels(), bitmap.getSize()); | 417 hash.write(bitmap.getPixels(), bitmap.getSize()); |
403 } | 418 } |
404 SkMD5::Digest digest; | 419 SkMD5::Digest digest; |
405 hash.finish(digest); | 420 hash.finish(digest); |
406 for (int i = 0; i < 16; i++) { | 421 for (int i = 0; i < 16; i++) { |
407 md5.appendf("%02x", digest.data[i]); | 422 md5.appendf("%02x", digest.data[i]); |
408 } | 423 } |
409 } | 424 } |
410 | 425 |
411 if (!FLAGS_readPath.isEmpty() && | 426 if (!FLAGS_readPath.isEmpty() && |
412 !gGold.contains(Gold(task->sink.tag, task->src.tag, name, md5)))
{ | 427 !gGold.contains(Gold(task->sink.tag, task->src.tag, |
413 fail(SkStringPrintf("%s not found for %s %s %s in %s", | 428 task->src.options, name, md5))) { |
| 429 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", |
414 md5.c_str(), | 430 md5.c_str(), |
415 task->sink.tag, | 431 task->sink.tag, |
416 task->src.tag, | 432 task->src.tag, |
| 433 task->src.options, |
417 name.c_str(), | 434 name.c_str(), |
418 FLAGS_readPath[0])); | 435 FLAGS_readPath[0])); |
419 } | 436 } |
420 | 437 |
421 if (!FLAGS_writePath.isEmpty()) { | 438 if (!FLAGS_writePath.isEmpty()) { |
422 const char* ext = task->sink->fileExtension(); | 439 const char* ext = task->sink->fileExtension(); |
423 if (data->getLength()) { | 440 if (data->getLength()) { |
424 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); | 441 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); |
425 SkASSERT(bitmap.drawsNothing()); | 442 SkASSERT(bitmap.drawsNothing()); |
426 } else if (!bitmap.drawsNothing()) { | 443 } else if (!bitmap.drawsNothing()) { |
427 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); | 444 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); |
428 } | 445 } |
429 } | 446 } |
430 } | 447 } |
431 timer.end(); | 448 timer.end(); |
432 done(timer.fWall, task->sink.tag, task->src.tag, name, note, log); | 449 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name
, note, log); |
433 } | 450 } |
434 | 451 |
435 static void WriteToDisk(const Task& task, | 452 static void WriteToDisk(const Task& task, |
436 SkString md5, | 453 SkString md5, |
437 const char* ext, | 454 const char* ext, |
438 SkStream* data, size_t len, | 455 SkStream* data, size_t len, |
439 const SkBitmap* bitmap) { | 456 const SkBitmap* bitmap) { |
440 JsonWriter::BitmapResult result; | 457 JsonWriter::BitmapResult result; |
441 result.name = task.src->name(); | 458 result.name = task.src->name(); |
442 result.config = task.sink.tag; | 459 result.config = task.sink.tag; |
443 result.sourceType = task.src.tag; | 460 result.sourceType = task.src.tag; |
444 result.ext = ext; | 461 result.sourceOptions = task.src.options; |
445 result.md5 = md5; | 462 result.ext = ext; |
| 463 result.md5 = md5; |
446 JsonWriter::AddBitmapResult(result); | 464 JsonWriter::AddBitmapResult(result); |
447 | 465 |
448 const char* dir = FLAGS_writePath[0]; | 466 const char* dir = FLAGS_writePath[0]; |
449 if (0 == strcmp(dir, "@")) { // Needed for iOS. | 467 if (0 == strcmp(dir, "@")) { // Needed for iOS. |
450 dir = FLAGS_resourcePath[0]; | 468 dir = FLAGS_resourcePath[0]; |
451 } | 469 } |
452 sk_mkdir(dir); | 470 sk_mkdir(dir); |
453 | 471 |
454 SkString path; | 472 SkString path; |
455 if (FLAGS_nameByHash) { | 473 if (FLAGS_nameByHash) { |
456 path = SkOSPath::Join(dir, result.md5.c_str()); | 474 path = SkOSPath::Join(dir, result.md5.c_str()); |
457 path.append("."); | 475 path.append("."); |
458 path.append(ext); | 476 path.append(ext); |
459 if (sk_exists(path.c_str())) { | 477 if (sk_exists(path.c_str())) { |
460 return; // Content-addressed. If it exists already, we're done
. | 478 return; // Content-addressed. If it exists already, we're done
. |
461 } | 479 } |
462 } else { | 480 } else { |
463 path = SkOSPath::Join(dir, task.sink.tag); | 481 path = SkOSPath::Join(dir, task.sink.tag); |
464 sk_mkdir(path.c_str()); | 482 sk_mkdir(path.c_str()); |
465 path = SkOSPath::Join(path.c_str(), task.src.tag); | 483 path = SkOSPath::Join(path.c_str(), task.src.tag); |
466 sk_mkdir(path.c_str()); | 484 sk_mkdir(path.c_str()); |
| 485 if (strcmp(task.src.options, "") != 0) { |
| 486 path = SkOSPath::Join(path.c_str(), task.src.options); |
| 487 sk_mkdir(path.c_str()); |
| 488 } |
467 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); | 489 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); |
468 path.append("."); | 490 path.append("."); |
469 path.append(ext); | 491 path.append(ext); |
470 } | 492 } |
471 | 493 |
472 SkFILEWStream file(path.c_str()); | 494 SkFILEWStream file(path.c_str()); |
473 if (!file.isValid()) { | 495 if (!file.isValid()) { |
474 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str())); | 496 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str())); |
475 return; | 497 return; |
476 } | 498 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 JsonWriter::AddTestFailure(failure); | 561 JsonWriter::AddTestFailure(failure); |
540 } | 562 } |
541 bool allowExtendedTest() const override { | 563 bool allowExtendedTest() const override { |
542 return FLAGS_pathOpsExtended; | 564 return FLAGS_pathOpsExtended; |
543 } | 565 } |
544 bool verbose() const override { return FLAGS_veryVerbose; } | 566 bool verbose() const override { return FLAGS_veryVerbose; } |
545 } reporter; | 567 } reporter; |
546 WallTimer timer; | 568 WallTimer timer; |
547 timer.start(); | 569 timer.start(); |
548 if (!FLAGS_dryRun) { | 570 if (!FLAGS_dryRun) { |
549 start("unit", "test", test->name); | 571 start("unit", "test", "", test->name); |
550 GrContextFactory factory; | 572 GrContextFactory factory; |
551 test->proc(&reporter, &factory); | 573 test->proc(&reporter, &factory); |
552 } | 574 } |
553 timer.end(); | 575 timer.end(); |
554 done(timer.fWall, "unit", "test", test->name, "", ""); | 576 done(timer.fWall, "unit", "test", "", test->name, "", ""); |
555 } | 577 } |
556 | 578 |
557 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 579 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
558 | 580 |
559 // If we're isolating all GPU-bound work to one thread (the default), this funct
ion runs all that. | 581 // If we're isolating all GPU-bound work to one thread (the default), this funct
ion runs all that. |
560 static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { | 582 static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { |
561 run_enclave(tasks); | 583 run_enclave(tasks); |
562 for (int i = 0; i < gGPUTests.count(); i++) { | 584 for (int i = 0; i < gGPUTests.count(); i++) { |
563 run_test(&gGPUTests[i]); | 585 run_test(&gGPUTests[i]); |
564 } | 586 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 } | 678 } |
657 return 0; | 679 return 0; |
658 } | 680 } |
659 | 681 |
660 #if !defined(SK_BUILD_FOR_IOS) | 682 #if !defined(SK_BUILD_FOR_IOS) |
661 int main(int argc, char** argv) { | 683 int main(int argc, char** argv) { |
662 SkCommandLineFlags::Parse(argc, argv); | 684 SkCommandLineFlags::Parse(argc, argv); |
663 return dm_main(); | 685 return dm_main(); |
664 } | 686 } |
665 #endif | 687 #endif |
OLD | NEW |