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 "ProcStats.h" | 12 #include "ProcStats.h" |
13 #include "Resources.h" | 13 #include "Resources.h" |
14 #include "SkBBHFactory.h" | 14 #include "SkBBHFactory.h" |
15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
16 #include "SkCodec.h" | 16 #include "SkCodec.h" |
17 #include "SkCommonFlags.h" | 17 #include "SkCommonFlags.h" |
18 #include "SkCommonFlagsConfig.h" | 18 #include "SkCommonFlagsConfig.h" |
19 #include "SkFontMgr.h" | 19 #include "SkFontMgr.h" |
20 #include "SkForceLinking.h" | |
21 #include "SkGraphics.h" | 20 #include "SkGraphics.h" |
22 #include "SkMD5.h" | 21 #include "SkMD5.h" |
23 #include "SkMutex.h" | 22 #include "SkMutex.h" |
24 #include "SkOSFile.h" | 23 #include "SkOSFile.h" |
25 #include "SkSpinlock.h" | 24 #include "SkSpinlock.h" |
26 #include "SkTHash.h" | 25 #include "SkTHash.h" |
27 #include "SkTaskGroup.h" | 26 #include "SkTaskGroup.h" |
28 #include "SkThreadUtils.h" | 27 #include "SkThreadUtils.h" |
29 #include "Test.h" | 28 #include "Test.h" |
30 #include "Timer.h" | 29 #include "Timer.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
58 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aar ects GM on 8888."); | 57 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aar ects GM on 8888."); |
59 | 58 |
60 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i n this directory."); | 59 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i n this directory."); |
61 | 60 |
62 DEFINE_string(uninterestingHashesFile, "", | 61 DEFINE_string(uninterestingHashesFile, "", |
63 "File containing a list of uninteresting hashes. If a result hashes to s omething in " | 62 "File containing a list of uninteresting hashes. If a result hashes to s omething in " |
64 "this list, no image is written for that result."); | 63 "this list, no image is written for that result."); |
65 | 64 |
66 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); | 65 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); |
67 DEFINE_int32(shard, 0, "Which shard do I run?"); | 66 DEFINE_int32(shard, 0, "Which shard do I run?"); |
67 DEFINE_bool(simpleCodec, false, "Only decode images to native scale"); | |
scroggo
2016/02/25 17:08:36
Alternatively, we can set this to true as the defa
msarett
2016/02/25 17:47:37
Acknowledged.
| |
68 | 68 |
69 __SK_FORCE_IMAGE_DECODER_LINKING; | |
70 using namespace DM; | 69 using namespace DM; |
71 | 70 |
72 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 71 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
73 | 72 |
74 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); | 73 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
75 static SkTArray<SkString> gFailures; | 74 static SkTArray<SkString> gFailures; |
76 | 75 |
77 static void fail(const SkString& err) { | 76 static void fail(const SkString& err) { |
78 SkAutoMutexAcquire lock(gFailuresMutex); | 77 SkAutoMutexAcquire lock(gFailuresMutex); |
79 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); | 78 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 231 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
233 TaggedSrc& s = gSrcs.push_back(); | 232 TaggedSrc& s = gSrcs.push_back(); |
234 s.reset(src.detach()); | 233 s.reset(src.detach()); |
235 s.tag = tag; | 234 s.tag = tag; |
236 s.options = options; | 235 s.options = options; |
237 } | 236 } |
238 } | 237 } |
239 | 238 |
240 static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp e dstColorType, | 239 static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp e dstColorType, |
241 SkAlphaType dstAlphaType, float scale) { | 240 SkAlphaType dstAlphaType, float scale) { |
241 if (FLAGS_simpleCodec) { | |
242 if (mode != CodecSrc::kCodec_Mode || dstColorType != CodecSrc::kGetFromC anvas_DstColorType | |
243 || scale != 1.0f) | |
244 // Only decode in the simple case. | |
245 return; | |
246 } | |
242 SkString folder; | 247 SkString folder; |
243 switch (mode) { | 248 switch (mode) { |
244 case CodecSrc::kCodec_Mode: | 249 case CodecSrc::kCodec_Mode: |
245 folder.append("codec"); | 250 folder.append("codec"); |
246 break; | 251 break; |
247 case CodecSrc::kCodecZeroInit_Mode: | 252 case CodecSrc::kCodecZeroInit_Mode: |
248 folder.append("codec_zero_init"); | 253 folder.append("codec_zero_init"); |
249 break; | 254 break; |
250 case CodecSrc::kScanline_Mode: | 255 case CodecSrc::kScanline_Mode: |
251 folder.append("scanline"); | 256 folder.append("scanline"); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 SkDebugf("Couldn't read %s.", path.c_str()); | 353 SkDebugf("Couldn't read %s.", path.c_str()); |
349 return; | 354 return; |
350 } | 355 } |
351 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 356 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
352 if (nullptr == codec.get()) { | 357 if (nullptr == codec.get()) { |
353 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 358 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
354 return; | 359 return; |
355 } | 360 } |
356 | 361 |
357 // Native Scales | 362 // Native Scales |
358 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these | |
359 // tests. SkImageDecoder supports downscales by integer fac tors. | |
360 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 | 363 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 |
361 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; | 364 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; |
362 | 365 |
363 SkTArray<CodecSrc::Mode> nativeModes; | 366 SkTArray<CodecSrc::Mode> nativeModes; |
364 nativeModes.push_back(CodecSrc::kCodec_Mode); | 367 nativeModes.push_back(CodecSrc::kCodec_Mode); |
365 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); | 368 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); |
366 nativeModes.push_back(CodecSrc::kGen_Mode); | 369 nativeModes.push_back(CodecSrc::kGen_Mode); |
367 switch (codec->getEncodedFormat()) { | 370 switch (codec->getEncodedFormat()) { |
368 case SkEncodedFormat::kJPEG_SkEncodedFormat: | 371 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
369 nativeModes.push_back(CodecSrc::kScanline_Mode); | 372 nativeModes.push_back(CodecSrc::kScanline_Mode); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 kOpaque_SkAlphaType != alphaType) { | 430 kOpaque_SkAlphaType != alphaType) { |
428 continue; | 431 continue; |
429 } | 432 } |
430 | 433 |
431 push_codec_src(path, mode, colorType, alphaType, scale); | 434 push_codec_src(path, mode, colorType, alphaType, scale); |
432 } | 435 } |
433 } | 436 } |
434 } | 437 } |
435 } | 438 } |
436 | 439 |
440 if (FLAGS_simpleCodec) { | |
441 return; | |
442 } | |
443 | |
437 // https://bug.skia.org/4428 | 444 // https://bug.skia.org/4428 |
438 bool subset = false; | 445 bool subset = false; |
439 // The following image types are supported by BitmapRegionDecoder, | 446 // The following image types are supported by BitmapRegionDecoder, |
440 // so we will test full image decodes and subset decodes. | 447 // so we will test full image decodes and subset decodes. |
441 static const char* const exts[] = { | 448 static const char* const exts[] = { |
442 "jpg", "jpeg", "png", "webp", | 449 "jpg", "jpeg", "png", "webp", |
443 "JPG", "JPEG", "PNG", "WEBP", | 450 "JPG", "JPEG", "PNG", "WEBP", |
444 }; | 451 }; |
445 for (const char* ext : exts) { | 452 for (const char* ext : exts) { |
446 if (path.endsWith(ext)) { | 453 if (path.endsWith(ext)) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 } | 613 } |
607 } | 614 } |
608 | 615 |
609 SkTArray<SkString> images; | 616 SkTArray<SkString> images; |
610 if (!CollectImages(&images)) { | 617 if (!CollectImages(&images)) { |
611 return false; | 618 return false; |
612 } | 619 } |
613 | 620 |
614 for (auto image : images) { | 621 for (auto image : images) { |
615 push_codec_srcs(image); | 622 push_codec_srcs(image); |
623 if (FLAGS_simpleCodec) { | |
624 continue; | |
625 } | |
626 | |
616 const char* ext = strrchr(image.c_str(), '.'); | 627 const char* ext = strrchr(image.c_str(), '.'); |
617 if (ext && brd_supported(ext+1)) { | 628 if (ext && brd_supported(ext+1)) { |
618 push_brd_srcs(image); | 629 push_brd_srcs(image); |
619 } | 630 } |
620 } | 631 } |
621 | 632 |
622 return true; | 633 return true; |
623 } | 634 } |
624 | 635 |
625 static void push_sink(const SkCommandLineConfig& config, Sink* s) { | 636 static void push_sink(const SkCommandLineConfig& config, Sink* s) { |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1274 Reporter* reporter, | 1285 Reporter* reporter, |
1275 GrContextFactory* fac tory); | 1286 GrContextFactory* fac tory); |
1276 } // namespace skiatest | 1287 } // namespace skiatest |
1277 | 1288 |
1278 #if !defined(SK_BUILD_FOR_IOS) | 1289 #if !defined(SK_BUILD_FOR_IOS) |
1279 int main(int argc, char** argv) { | 1290 int main(int argc, char** argv) { |
1280 SkCommandLineFlags::Parse(argc, argv); | 1291 SkCommandLineFlags::Parse(argc, argv); |
1281 return dm_main(); | 1292 return dm_main(); |
1282 } | 1293 } |
1283 #endif | 1294 #endif |
OLD | NEW |