| 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 "SkCodec.h" | 16 #include "SkCodec.h" |
| 17 #include "SkCommonFlags.h" | 17 #include "SkCommonFlags.h" |
| 18 #include "SkCommonFlagsConfig.h" |
| 18 #include "SkFontMgr.h" | 19 #include "SkFontMgr.h" |
| 19 #include "SkForceLinking.h" | 20 #include "SkForceLinking.h" |
| 20 #include "SkGraphics.h" | 21 #include "SkGraphics.h" |
| 21 #include "SkMD5.h" | 22 #include "SkMD5.h" |
| 22 #include "SkMutex.h" | 23 #include "SkMutex.h" |
| 23 #include "SkOSFile.h" | 24 #include "SkOSFile.h" |
| 24 #include "SkTHash.h" | 25 #include "SkTHash.h" |
| 25 #include "SkTaskGroup.h" | 26 #include "SkTaskGroup.h" |
| 26 #include "SkThreadUtils.h" | 27 #include "SkThreadUtils.h" |
| 27 #include "Test.h" | 28 #include "Test.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 193 } |
| 193 | 194 |
| 194 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 195 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 195 | 196 |
| 196 struct TaggedSrc : public SkAutoTDelete<Src> { | 197 struct TaggedSrc : public SkAutoTDelete<Src> { |
| 197 ImplicitString tag; | 198 ImplicitString tag; |
| 198 ImplicitString options; | 199 ImplicitString options; |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 struct TaggedSink : public SkAutoTDelete<Sink> { | 202 struct TaggedSink : public SkAutoTDelete<Sink> { |
| 202 const char* tag; | 203 SkString tag; |
| 203 }; | 204 }; |
| 204 | 205 |
| 205 static const bool kMemcpyOK = true; | 206 static const bool kMemcpyOK = true; |
| 206 | 207 |
| 207 static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; | 208 static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; |
| 208 static SkTArray<TaggedSink, kMemcpyOK> gSinks; | 209 static SkTArray<TaggedSink, kMemcpyOK> gSinks; |
| 209 | 210 |
| 210 static bool in_shard() { | 211 static bool in_shard() { |
| 211 static int N = 0; | 212 static int N = 0; |
| 212 return N++ % FLAGS_shards == FLAGS_shard; | 213 return N++ % FLAGS_shards == FLAGS_shard; |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 } | 535 } |
| 535 } else if (sk_exists(flag)) { | 536 } else if (sk_exists(flag)) { |
| 536 // assume that FLAGS_images[i] is a valid image if it is a file. | 537 // assume that FLAGS_images[i] is a valid image if it is a file. |
| 537 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. | 538 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. |
| 538 push_codec_srcs(flag); | 539 push_codec_srcs(flag); |
| 539 push_brd_srcs(flag); | 540 push_brd_srcs(flag); |
| 540 } | 541 } |
| 541 } | 542 } |
| 542 } | 543 } |
| 543 | 544 |
| 544 #if SK_SUPPORT_GPU | 545 static void push_sink(const SkCommandLineConfig& config, Sink* s) { |
| 545 static GrGLStandard get_gpu_api() { | 546 SkAutoTDelete<Sink> sink(s); |
| 546 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | |
| 547 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | |
| 548 return kNone_GrGLStandard; | |
| 549 } | |
| 550 #endif | |
| 551 | 547 |
| 552 static void push_sink(const char* tag, Sink* s) { | |
| 553 SkAutoTDelete<Sink> sink(s); | |
| 554 if (!FLAGS_config.contains(tag)) { | |
| 555 return; | |
| 556 } | |
| 557 // Try a simple Src as a canary. If it fails, skip this sink. | 548 // Try a simple Src as a canary. If it fails, skip this sink. |
| 558 struct : public Src { | 549 struct : public Src { |
| 559 Error draw(SkCanvas* c) const override { | 550 Error draw(SkCanvas* c) const override { |
| 560 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); | 551 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); |
| 561 return ""; | 552 return ""; |
| 562 } | 553 } |
| 563 SkISize size() const override { return SkISize::Make(16, 16); } | 554 SkISize size() const override { return SkISize::Make(16, 16); } |
| 564 Name name() const override { return "justOneRect"; } | 555 Name name() const override { return "justOneRect"; } |
| 565 } justOneRect; | 556 } justOneRect; |
| 566 | 557 |
| 567 SkBitmap bitmap; | 558 SkBitmap bitmap; |
| 568 SkDynamicMemoryWStream stream; | 559 SkDynamicMemoryWStream stream; |
| 569 SkString log; | 560 SkString log; |
| 570 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); | 561 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); |
| 571 if (err.isFatal()) { | 562 if (err.isFatal()) { |
| 572 SkDebugf("Could not run %s: %s\n", tag, err.c_str()); | 563 SkDebugf("Could not run %s: %s\n", config.getTag().c_str(), err.c_str())
; |
| 573 exit(1); | 564 exit(1); |
| 574 } | 565 } |
| 575 | 566 |
| 576 TaggedSink& ts = gSinks.push_back(); | 567 TaggedSink& ts = gSinks.push_back(); |
| 577 ts.reset(sink.detach()); | 568 ts.reset(sink.detach()); |
| 578 ts.tag = tag; | 569 ts.tag = config.getTag(); |
| 579 } | 570 } |
| 580 | 571 |
| 581 static bool gpu_supported() { | 572 static bool gpu_supported() { |
| 582 #if SK_SUPPORT_GPU | 573 #if SK_SUPPORT_GPU |
| 583 return FLAGS_gpu; | 574 return FLAGS_gpu; |
| 584 #else | 575 #else |
| 585 return false; | 576 return false; |
| 586 #endif | 577 #endif |
| 587 } | 578 } |
| 588 static Sink* create_gpu_sink(const char* tag, GrContextFactory::GLContextType co
ntextType, | 579 |
| 589 GrContextFactory::GLContextOptions contextOptions,
int samples, | 580 static Sink* create_sink(const SkCommandLineConfig* config) { |
| 590 bool diText, bool threaded) { | |
| 591 #if SK_SUPPORT_GPU | 581 #if SK_SUPPORT_GPU |
| 592 GrContextFactory testFactory; | 582 if (gpu_supported()) { |
| 593 const GrGLStandard api = get_gpu_api(); | 583 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) { |
| 594 if (testFactory.get(contextType, api, contextOptions)) { | 584 GrContextFactory::GLContextType contextType = gpuConfig->getContextT
ype(); |
| 595 return new GPUSink(contextType, contextOptions, api, samples, diText, th
readed); | 585 GrContextFactory::GLContextOptions contextOptions = |
| 586 GrContextFactory::kNone_GLContextOptions; |
| 587 if (gpuConfig->getUseNVPR()) { |
| 588 contextOptions = static_cast<GrContextFactory::GLContextOptions>
( |
| 589 contextOptions | GrContextFactory::kEnableNVPR_GLContextOpti
ons); |
| 590 } |
| 591 GrContextFactory testFactory; |
| 592 if (!testFactory.get(contextType, contextOptions)) { |
| 593 SkDebugf("WARNING: can not create GPU context for config '%s'. " |
| 594 "GM tests will be skipped.\n", gpuConfig->getTag().c_st
r()); |
| 595 return nullptr; |
| 596 } |
| 597 return new GPUSink(contextType, contextOptions, gpuConfig->getSample
s(), |
| 598 gpuConfig->getUseDIText(), FLAGS_gpu_threading); |
| 599 } |
| 596 } | 600 } |
| 597 SkDebugf("WARNING: can not create GPU context for config '%s'. GM tests will
be skipped.\n", tag); | |
| 598 #endif | 601 #endif |
| 599 return nullptr; | |
| 600 } | |
| 601 static Sink* create_sink(const char* tag) { | |
| 602 #define GPU_SINK(t, ...) if (0 == strcmp(t, tag)) { return create_gpu_sink(tag,
__VA_ARGS__); } | |
| 603 if (gpu_supported()) { | |
| 604 typedef GrContextFactory Gr; | |
| 605 GPU_SINK("gpunull", Gr::kNull_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 606 GPU_SINK("gpudebug", Gr::kDebug_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 607 GPU_SINK("gpu", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 608 GPU_SINK("gpudft", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 0, true, FLAGS_gpu_threading); | |
| 609 GPU_SINK("msaa4", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 4, false, FLAGS_gpu_threading); | |
| 610 GPU_SINK("msaa16", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 16, false, FLAGS_gpu_threading); | |
| 611 GPU_SINK("nvprmsaa4", Gr::kNative_GLContextType, Gr::kEnableN
VPR_GLContextOptions, 4, true, FLAGS_gpu_threading); | |
| 612 GPU_SINK("nvprmsaa16", Gr::kNative_GLContextType, Gr::kEnableN
VPR_GLContextOptions, 16, true, FLAGS_gpu_threading); | |
| 613 #if SK_ANGLE | |
| 614 GPU_SINK("angle", Gr::kANGLE_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 615 GPU_SINK("angle-gl", Gr::kANGLE_GL_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 616 #endif | |
| 617 #if SK_COMMAND_BUFFER | |
| 618 GPU_SINK("commandbuffer", Gr::kCommandBuffer_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 619 #endif | |
| 620 #if SK_MESA | |
| 621 GPU_SINK("mesa", Gr::kMESA_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); | |
| 622 #endif | |
| 623 } | |
| 624 #undef GPU_SINK | |
| 625 | 602 |
| 626 #define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS_
_); } | 603 #define SINK(t, sink, ...) if (config->getTag().equals(t)) { return new sink(__V
A_ARGS__); } |
| 604 |
| 627 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 605 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 628 SINK("hwui", HWUISink); | 606 SINK("hwui", HWUISink); |
| 629 #endif | 607 #endif |
| 630 | 608 |
| 631 if (FLAGS_cpu) { | 609 if (FLAGS_cpu) { |
| 632 SINK("565", RasterSink, kRGB_565_SkColorType); | 610 SINK("565", RasterSink, kRGB_565_SkColorType); |
| 633 SINK("8888", RasterSink, kN32_SkColorType); | 611 SINK("8888", RasterSink, kN32_SkColorType); |
| 634 SINK("pdf", PDFSink, "Pdfium"); | 612 SINK("pdf", PDFSink, "Pdfium"); |
| 635 SINK("pdf_poppler", PDFSink, "Poppler"); | 613 SINK("pdf_poppler", PDFSink, "Poppler"); |
| 636 SINK("skp", SKPSink); | 614 SINK("skp", SKPSink); |
| 637 SINK("svg", SVGSink); | 615 SINK("svg", SVGSink); |
| 638 SINK("null", NullSink); | 616 SINK("null", NullSink); |
| 639 SINK("xps", XPSSink); | 617 SINK("xps", XPSSink); |
| 640 } | 618 } |
| 641 #undef SINK | 619 #undef SINK |
| 642 return nullptr; | 620 return nullptr; |
| 643 } | 621 } |
| 644 | 622 |
| 645 static Sink* create_via(const char* tag, Sink* wrapped) { | 623 static Sink* create_via(const SkString& tag, Sink* wrapped) { |
| 646 #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__);
} | 624 #define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); } |
| 647 VIA("twice", ViaTwice, wrapped); | 625 VIA("twice", ViaTwice, wrapped); |
| 648 VIA("pipe", ViaPipe, wrapped); | 626 VIA("pipe", ViaPipe, wrapped); |
| 649 VIA("serialize", ViaSerialization, wrapped); | 627 VIA("serialize", ViaSerialization, wrapped); |
| 650 VIA("2ndpic", ViaSecondPicture, wrapped); | 628 VIA("2ndpic", ViaSecondPicture, wrapped); |
| 651 VIA("sp", ViaSingletonPictures, wrapped); | 629 VIA("sp", ViaSingletonPictures, wrapped); |
| 652 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped); | 630 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped); |
| 653 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); | 631 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); |
| 654 VIA("remote", ViaRemote, false, wrapped); | 632 VIA("remote", ViaRemote, false, wrapped); |
| 655 VIA("remote_cache", ViaRemote, true, wrapped); | 633 VIA("remote_cache", ViaRemote, true, wrapped); |
| 656 | 634 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 667 | 645 |
| 668 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 646 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 669 VIA("androidsdk", ViaAndroidSDK, wrapped); | 647 VIA("androidsdk", ViaAndroidSDK, wrapped); |
| 670 #endif | 648 #endif |
| 671 | 649 |
| 672 #undef VIA | 650 #undef VIA |
| 673 return nullptr; | 651 return nullptr; |
| 674 } | 652 } |
| 675 | 653 |
| 676 static void gather_sinks() { | 654 static void gather_sinks() { |
| 677 for (int i = 0; i < FLAGS_config.count(); i++) { | 655 SkCommandLineConfigArray configs; |
| 678 const char* config = FLAGS_config[i]; | 656 ParseConfigs(FLAGS_config, &configs); |
| 679 SkTArray<SkString> parts; | 657 for (int i = 0; i < configs.count(); i++) { |
| 680 SkStrSplit(config, "-", &parts); | 658 const SkCommandLineConfig& config = *configs[i]; |
| 659 Sink* sink = create_sink(&config); |
| 660 if (sink == nullptr) { |
| 661 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.getT
ag().c_str(), |
| 662 config.getTag().c_str()); |
| 663 continue; |
| 664 } |
| 681 | 665 |
| 682 Sink* sink = nullptr; | 666 const SkTArray<SkString>& parts = config.getViaParts(); |
| 683 for (int i = parts.count(); i-- > 0;) { | 667 for (int j = parts.count(); j-- > 0;) { |
| 684 const char* part = parts[i].c_str(); | 668 const SkString& part = parts[j]; |
| 685 Sink* next = (sink == nullptr) ? create_sink(part) : create_via(part
, sink); | 669 Sink* next = create_via(part, sink); |
| 686 if (next == nullptr) { | 670 if (next == nullptr) { |
| 687 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); | 671 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.
getTag().c_str(), |
| 672 part.c_str()); |
| 688 delete sink; | 673 delete sink; |
| 689 sink = nullptr; | 674 sink = nullptr; |
| 690 break; | 675 break; |
| 691 } | 676 } |
| 692 sink = next; | 677 sink = next; |
| 693 } | 678 } |
| 694 if (sink) { | 679 if (sink) { |
| 695 push_sink(config, sink); | 680 push_sink(config, sink); |
| 696 } | 681 } |
| 697 } | 682 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 const TaggedSink& sink; | 784 const TaggedSink& sink; |
| 800 | 785 |
| 801 static void Run(Task* task) { | 786 static void Run(Task* task) { |
| 802 SkString name = task->src->name(); | 787 SkString name = task->src->name(); |
| 803 | 788 |
| 804 // We'll skip drawing this Src/Sink pair if: | 789 // We'll skip drawing this Src/Sink pair if: |
| 805 // - the Src vetoes the Sink; | 790 // - the Src vetoes the Sink; |
| 806 // - this Src / Sink combination is on the blacklist; | 791 // - this Src / Sink combination is on the blacklist; |
| 807 // - it's a dry run. | 792 // - it's a dry run. |
| 808 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); | 793 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); |
| 809 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c
_str(), | 794 SkString whyBlacklisted = is_blacklisted(task->sink.tag.c_str(), task->s
rc.tag.c_str(), |
| 810 task->src.options.c_str(), name
.c_str()); | 795 task->src.options.c_str(), name
.c_str()); |
| 811 if (!whyBlacklisted.isEmpty()) { | 796 if (!whyBlacklisted.isEmpty()) { |
| 812 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); | 797 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
| 813 } | 798 } |
| 814 | 799 |
| 815 SkString log; | 800 SkString log; |
| 816 auto timerStart = now_ms(); | 801 auto timerStart = now_ms(); |
| 817 if (!FLAGS_dryRun && note.isEmpty()) { | 802 if (!FLAGS_dryRun && note.isEmpty()) { |
| 818 SkBitmap bitmap; | 803 SkBitmap bitmap; |
| 819 SkDynamicMemoryWStream stream; | 804 SkDynamicMemoryWStream stream; |
| 820 if (FLAGS_pre_log) { | 805 if (FLAGS_pre_log) { |
| 821 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); | 806 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag.c_str(
)); |
| 822 } | 807 } |
| 823 start(task->sink.tag, task->src.tag, task->src.options, name.c_str()
); | 808 start(task->sink.tag.c_str(), task->src.tag, task->src.options, name
.c_str()); |
| 824 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); | 809 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
| 825 if (!err.isEmpty()) { | 810 if (!err.isEmpty()) { |
| 826 auto elapsed = now_ms() - timerStart; | 811 auto elapsed = now_ms() - timerStart; |
| 827 if (err.isFatal()) { | 812 if (err.isFatal()) { |
| 828 fail(SkStringPrintf("%s %s %s %s: %s", | 813 fail(SkStringPrintf("%s %s %s %s: %s", |
| 829 task->sink.tag, | 814 task->sink.tag.c_str(), |
| 830 task->src.tag.c_str(), | 815 task->src.tag.c_str(), |
| 831 task->src.options.c_str(), | 816 task->src.options.c_str(), |
| 832 name.c_str(), | 817 name.c_str(), |
| 833 err.c_str())); | 818 err.c_str())); |
| 834 } else { | 819 } else { |
| 835 note.appendf(" (skipped: %s)", err.c_str()); | 820 note.appendf(" (skipped: %s)", err.c_str()); |
| 836 } | 821 } |
| 837 done(elapsed, task->sink.tag, task->src.tag, task->src.options, | 822 done(elapsed, task->sink.tag.c_str(), task->src.tag, task->src.o
ptions, |
| 838 name, note, log); | 823 name, note, log); |
| 839 return; | 824 return; |
| 840 } | 825 } |
| 841 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); | 826 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
| 842 | 827 |
| 843 SkString md5; | 828 SkString md5; |
| 844 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { | 829 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { |
| 845 SkMD5 hash; | 830 SkMD5 hash; |
| 846 if (data->getLength()) { | 831 if (data->getLength()) { |
| 847 hash.writeStream(data, data->getLength()); | 832 hash.writeStream(data, data->getLength()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 860 } | 845 } |
| 861 } | 846 } |
| 862 SkMD5::Digest digest; | 847 SkMD5::Digest digest; |
| 863 hash.finish(digest); | 848 hash.finish(digest); |
| 864 for (int i = 0; i < 16; i++) { | 849 for (int i = 0; i < 16; i++) { |
| 865 md5.appendf("%02x", digest.data[i]); | 850 md5.appendf("%02x", digest.data[i]); |
| 866 } | 851 } |
| 867 } | 852 } |
| 868 | 853 |
| 869 if (!FLAGS_readPath.isEmpty() && | 854 if (!FLAGS_readPath.isEmpty() && |
| 870 !gGold.contains(Gold(task->sink.tag, task->src.tag.c_str(), | 855 !gGold.contains(Gold(task->sink.tag.c_str(), task->src.tag.c_str
(), |
| 871 task->src.options.c_str(), name, md5))) { | 856 task->src.options.c_str(), name, md5))) { |
| 872 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", | 857 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", |
| 873 md5.c_str(), | 858 md5.c_str(), |
| 874 task->sink.tag, | 859 task->sink.tag.c_str(), |
| 875 task->src.tag.c_str(), | 860 task->src.tag.c_str(), |
| 876 task->src.options.c_str(), | 861 task->src.options.c_str(), |
| 877 name.c_str(), | 862 name.c_str(), |
| 878 FLAGS_readPath[0])); | 863 FLAGS_readPath[0])); |
| 879 } | 864 } |
| 880 | 865 |
| 881 if (!FLAGS_writePath.isEmpty()) { | 866 if (!FLAGS_writePath.isEmpty()) { |
| 882 const char* ext = task->sink->fileExtension(); | 867 const char* ext = task->sink->fileExtension(); |
| 883 if (data->getLength()) { | 868 if (data->getLength()) { |
| 884 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt
r); | 869 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt
r); |
| 885 SkASSERT(bitmap.drawsNothing()); | 870 SkASSERT(bitmap.drawsNothing()); |
| 886 } else if (!bitmap.drawsNothing()) { | 871 } else if (!bitmap.drawsNothing()) { |
| 887 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); | 872 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); |
| 888 } | 873 } |
| 889 } | 874 } |
| 890 } | 875 } |
| 891 done(now_ms()-timerStart, task->sink.tag, task->src.tag.c_str(), task->s
rc.options.c_str(), | 876 done(now_ms()-timerStart, task->sink.tag.c_str(), task->src.tag.c_str(),
task->src.options.c_str(), |
| 892 name, note, log); | 877 name, note, log); |
| 893 } | 878 } |
| 894 | 879 |
| 895 static void WriteToDisk(const Task& task, | 880 static void WriteToDisk(const Task& task, |
| 896 SkString md5, | 881 SkString md5, |
| 897 const char* ext, | 882 const char* ext, |
| 898 SkStream* data, size_t len, | 883 SkStream* data, size_t len, |
| 899 const SkBitmap* bitmap) { | 884 const SkBitmap* bitmap) { |
| 900 JsonWriter::BitmapResult result; | 885 JsonWriter::BitmapResult result; |
| 901 result.name = task.src->name(); | 886 result.name = task.src->name(); |
| 902 result.config = task.sink.tag; | 887 result.config = task.sink.tag.c_str(); |
| 903 result.sourceType = task.src.tag; | 888 result.sourceType = task.src.tag; |
| 904 result.sourceOptions = task.src.options; | 889 result.sourceOptions = task.src.options; |
| 905 result.ext = ext; | 890 result.ext = ext; |
| 906 result.md5 = md5; | 891 result.md5 = md5; |
| 907 JsonWriter::AddBitmapResult(result); | 892 JsonWriter::AddBitmapResult(result); |
| 908 | 893 |
| 909 // If an MD5 is uninteresting, we want it noted in the JSON file, | 894 // If an MD5 is uninteresting, we want it noted in the JSON file, |
| 910 // but don't want to dump it out as a .png (or whatever ext is). | 895 // but don't want to dump it out as a .png (or whatever ext is). |
| 911 if (gUninterestingHashes.contains(md5)) { | 896 if (gUninterestingHashes.contains(md5)) { |
| 912 return; | 897 return; |
| 913 } | 898 } |
| 914 | 899 |
| 915 const char* dir = FLAGS_writePath[0]; | 900 const char* dir = FLAGS_writePath[0]; |
| 916 if (0 == strcmp(dir, "@")) { // Needed for iOS. | 901 if (0 == strcmp(dir, "@")) { // Needed for iOS. |
| 917 dir = FLAGS_resourcePath[0]; | 902 dir = FLAGS_resourcePath[0]; |
| 918 } | 903 } |
| 919 sk_mkdir(dir); | 904 sk_mkdir(dir); |
| 920 | 905 |
| 921 SkString path; | 906 SkString path; |
| 922 if (FLAGS_nameByHash) { | 907 if (FLAGS_nameByHash) { |
| 923 path = SkOSPath::Join(dir, result.md5.c_str()); | 908 path = SkOSPath::Join(dir, result.md5.c_str()); |
| 924 path.append("."); | 909 path.append("."); |
| 925 path.append(ext); | 910 path.append(ext); |
| 926 if (sk_exists(path.c_str())) { | 911 if (sk_exists(path.c_str())) { |
| 927 return; // Content-addressed. If it exists already, we're done
. | 912 return; // Content-addressed. If it exists already, we're done
. |
| 928 } | 913 } |
| 929 } else { | 914 } else { |
| 930 path = SkOSPath::Join(dir, task.sink.tag); | 915 path = SkOSPath::Join(dir, task.sink.tag.c_str()); |
| 931 sk_mkdir(path.c_str()); | 916 sk_mkdir(path.c_str()); |
| 932 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str()); | 917 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str()); |
| 933 sk_mkdir(path.c_str()); | 918 sk_mkdir(path.c_str()); |
| 934 if (strcmp(task.src.options.c_str(), "") != 0) { | 919 if (strcmp(task.src.options.c_str(), "") != 0) { |
| 935 path = SkOSPath::Join(path.c_str(), task.src.options.c_str()); | 920 path = SkOSPath::Join(path.c_str(), task.src.options.c_str()); |
| 936 sk_mkdir(path.c_str()); | 921 sk_mkdir(path.c_str()); |
| 937 } | 922 } |
| 938 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); | 923 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); |
| 939 path.append("."); | 924 path.append("."); |
| 940 path.append(ext); | 925 path.append(ext); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 GrContextFactory::ContextInfo* context) { | 1157 GrContextFactory::ContextInfo* context) { |
| 1173 test(reporter, context->fGrContext, context->fGLContext); | 1158 test(reporter, context->fGrContext, context->fGLContext); |
| 1174 } | 1159 } |
| 1175 #endif | 1160 #endif |
| 1176 } // namespace | 1161 } // namespace |
| 1177 | 1162 |
| 1178 template<typename T> | 1163 template<typename T> |
| 1179 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
rter, | 1164 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
rter, |
| 1180 GrContextFactory* factory) { | 1165 GrContextFactory* factory) { |
| 1181 #if SK_SUPPORT_GPU | 1166 #if SK_SUPPORT_GPU |
| 1182 const GrGLStandard api = get_gpu_api(); | 1167 // Iterate over context types, except use "native" instead of explicitly try
ing OpenGL and |
| 1183 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 1168 // OpenGL ES. Do not use GLES on desktop, since tests do not account for not
fixing |
| 1184 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; | 1169 // http://skbug.com/2809 |
| 1170 GrContextFactory::GLContextType contextTypes[] = { |
| 1171 GrContextFactory::kNative_GLContextType, |
| 1172 #if SK_ANGLE |
| 1173 #ifdef SK_BUILD_FOR_WIN |
| 1174 GrContextFactory::kANGLE_GLContextType, |
| 1175 #endif |
| 1176 GrContextFactory::kANGLE_GL_GLContextType, |
| 1177 #endif |
| 1178 #if SK_COMMAND_BUFFER |
| 1179 GrContextFactory::kCommandBuffer_GLContextType, |
| 1180 #endif |
| 1181 #if SK_MESA |
| 1182 GrContextFactory::kMESA_GLContextType, |
| 1183 #endif |
| 1184 GrContextFactory::kNull_GLContextType, |
| 1185 GrContextFactory::kDebug_GLContextType, |
| 1186 }; |
| 1187 static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kGLContextTy
peCnt - 2, |
| 1188 "Skipping unexpected GLContextType for GPU tests"); |
| 1189 |
| 1190 for (auto& contextType : contextTypes) { |
| 1185 int contextSelector = kNone_GPUTestContexts; | 1191 int contextSelector = kNone_GPUTestContexts; |
| 1186 if (GrContextFactory::IsRenderingGLContext(glCtxType)) { | 1192 if (GrContextFactory::IsRenderingGLContext(contextType)) { |
| 1187 contextSelector |= kAllRendering_GPUTestContexts; | 1193 contextSelector |= kAllRendering_GPUTestContexts; |
| 1188 } else if (glCtxType == GrContextFactory::kNative_GLContextType) { | 1194 } else if (contextType == GrContextFactory::kNative_GLContextType) { |
| 1189 contextSelector |= kNative_GPUTestContexts; | 1195 contextSelector |= kNative_GPUTestContexts; |
| 1190 } else if (glCtxType == GrContextFactory::kNull_GLContextType) { | 1196 } else if (contextType == GrContextFactory::kNull_GLContextType) { |
| 1191 contextSelector |= kNull_GPUTestContexts; | 1197 contextSelector |= kNull_GPUTestContexts; |
| 1192 } else if (glCtxType == GrContextFactory::kDebug_GLContextType) { | 1198 } else if (contextType == GrContextFactory::kDebug_GLContextType) { |
| 1193 contextSelector |= kDebug_GPUTestContexts; | 1199 contextSelector |= kDebug_GPUTestContexts; |
| 1194 } | 1200 } |
| 1195 if ((testContexts & contextSelector) == 0) { | 1201 if ((testContexts & contextSelector) == 0) { |
| 1196 continue; | 1202 continue; |
| 1197 } | 1203 } |
| 1198 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glC
txType, api)) { | 1204 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(con
textType)) { |
| 1199 call_test(test, reporter, context); | 1205 call_test(test, reporter, context); |
| 1200 } | 1206 } |
| 1201 if (GrContextFactory::ContextInfo* context = | 1207 if (GrContextFactory::ContextInfo* context = |
| 1202 factory->getContextInfo(glCtxType, api, | 1208 factory->getContextInfo(contextType, GrContextFactory::kEnableNVPR_G
LContextOptions)) { |
| 1203 GrContextFactory::kEnableNVPR_GLContextOptio
ns)) { | |
| 1204 call_test(test, reporter, context); | 1209 call_test(test, reporter, context); |
| 1205 } | 1210 } |
| 1206 } | 1211 } |
| 1207 #endif | 1212 #endif |
| 1208 } | 1213 } |
| 1209 | 1214 |
| 1210 template | 1215 template |
| 1211 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, | 1216 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, |
| 1212 GPUTestContexts testContexts, | 1217 GPUTestContexts testContexts, |
| 1213 Reporter* reporter, | 1218 Reporter* reporter, |
| 1214 GrContextFactory* factory); | 1219 GrContextFactory* factory); |
| 1215 template | 1220 template |
| 1216 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG
LContext test, | 1221 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG
LContext test, |
| 1217 GPUTestContexts testC
ontexts, | 1222 GPUTestContexts testC
ontexts, |
| 1218 Reporter* reporter, | 1223 Reporter* reporter, |
| 1219 GrContextFactory* fac
tory); | 1224 GrContextFactory* fac
tory); |
| 1220 } // namespace skiatest | 1225 } // namespace skiatest |
| 1221 | 1226 |
| 1222 #if !defined(SK_BUILD_FOR_IOS) | 1227 #if !defined(SK_BUILD_FOR_IOS) |
| 1223 int main(int argc, char** argv) { | 1228 int main(int argc, char** argv) { |
| 1224 SkCommandLineFlags::Parse(argc, argv); | 1229 SkCommandLineFlags::Parse(argc, argv); |
| 1225 return dm_main(); | 1230 return dm_main(); |
| 1226 } | 1231 } |
| 1227 #endif | 1232 #endif |
| OLD | NEW |