Chromium Code Reviews| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 } | 189 } |
| 189 | 190 |
| 190 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 191 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
| 191 | 192 |
| 192 struct TaggedSrc : public SkAutoTDelete<Src> { | 193 struct TaggedSrc : public SkAutoTDelete<Src> { |
| 193 ImplicitString tag; | 194 ImplicitString tag; |
| 194 ImplicitString options; | 195 ImplicitString options; |
| 195 }; | 196 }; |
| 196 | 197 |
| 197 struct TaggedSink : public SkAutoTDelete<Sink> { | 198 struct TaggedSink : public SkAutoTDelete<Sink> { |
| 198 const char* tag; | 199 SkString tag; |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 static const bool kMemcpyOK = true; | 202 static const bool kMemcpyOK = true; |
| 202 | 203 |
| 203 static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; | 204 static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; |
| 204 static SkTArray<TaggedSink, kMemcpyOK> gSinks; | 205 static SkTArray<TaggedSink, kMemcpyOK> gSinks; |
| 205 | 206 |
| 206 static bool in_shard() { | 207 static bool in_shard() { |
| 207 static int N = 0; | 208 static int N = 0; |
| 208 return N++ % FLAGS_shards == FLAGS_shard; | 209 return N++ % FLAGS_shards == FLAGS_shard; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 } | 549 } |
| 549 } else if (sk_exists(flag)) { | 550 } else if (sk_exists(flag)) { |
| 550 // assume that FLAGS_images[i] is a valid image if it is a file. | 551 // assume that FLAGS_images[i] is a valid image if it is a file. |
| 551 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. | 552 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. |
| 552 push_codec_srcs(flag); | 553 push_codec_srcs(flag); |
| 553 push_brd_srcs(flag); | 554 push_brd_srcs(flag); |
| 554 } | 555 } |
| 555 } | 556 } |
| 556 } | 557 } |
| 557 | 558 |
| 558 static GrGLStandard get_gpu_api() { | 559 static void push_sink(const SkCommandLineConfig& config, Sink* s) { |
| 559 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 560 SkAutoTDelete<Sink> sink(s); |
| 560 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | |
| 561 return kNone_GrGLStandard; | |
| 562 } | |
| 563 | 561 |
| 564 static void push_sink(const char* tag, Sink* s) { | |
| 565 SkAutoTDelete<Sink> sink(s); | |
| 566 if (!FLAGS_config.contains(tag)) { | |
| 567 return; | |
| 568 } | |
| 569 // Try a simple Src as a canary. If it fails, skip this sink. | 562 // Try a simple Src as a canary. If it fails, skip this sink. |
| 570 struct : public Src { | 563 struct : public Src { |
| 571 Error draw(SkCanvas* c) const override { | 564 Error draw(SkCanvas* c) const override { |
| 572 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); | 565 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); |
| 573 return ""; | 566 return ""; |
| 574 } | 567 } |
| 575 SkISize size() const override { return SkISize::Make(16, 16); } | 568 SkISize size() const override { return SkISize::Make(16, 16); } |
| 576 Name name() const override { return "justOneRect"; } | 569 Name name() const override { return "justOneRect"; } |
| 577 } justOneRect; | 570 } justOneRect; |
| 578 | 571 |
| 579 SkBitmap bitmap; | 572 SkBitmap bitmap; |
| 580 SkDynamicMemoryWStream stream; | 573 SkDynamicMemoryWStream stream; |
| 581 SkString log; | 574 SkString log; |
| 582 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); | 575 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); |
| 583 if (err.isFatal()) { | 576 if (err.isFatal()) { |
| 584 SkDebugf("Could not run %s: %s\n", tag, err.c_str()); | 577 SkDebugf("Could not run %s: %s\n", config.getTag().c_str(), err.c_str()) ; |
| 585 exit(1); | 578 exit(1); |
| 586 } | 579 } |
| 587 | 580 |
| 588 TaggedSink& ts = gSinks.push_back(); | 581 TaggedSink& ts = gSinks.push_back(); |
| 589 ts.reset(sink.detach()); | 582 ts.reset(sink.detach()); |
| 590 ts.tag = tag; | 583 ts.tag = config.getTag(); |
| 591 } | 584 } |
| 592 | 585 |
| 593 static bool gpu_supported() { | 586 static bool gpu_supported() { |
| 594 #if SK_SUPPORT_GPU | 587 #if SK_SUPPORT_GPU |
| 595 return FLAGS_gpu; | 588 return FLAGS_gpu; |
| 596 #else | 589 #else |
| 597 return false; | 590 return false; |
| 598 #endif | 591 #endif |
| 599 } | 592 } |
| 600 | 593 |
| 601 static Sink* create_sink(const char* tag) { | 594 static Sink* create_sink(const SkCommandLineConfig* config) { |
| 602 #define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS_ _); } | 595 #if SK_SUPPORT_GPU |
| 603 if (gpu_supported()) { | 596 if (gpu_supported()) { |
| 604 typedef GrContextFactory Gr; | 597 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) { |
| 605 const GrGLStandard api = get_gpu_api(); | 598 GrContextFactory::GLContextType contextType = GrContextFactory::kNat ive_GLContextType; |
| 606 SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 599 GrContextFactory::GLContextOptions contextOptions = GrContextFactory ::kNone_GLContextOptions; |
| 607 SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 600 switch (gpuConfig->getAPI()) { |
| 608 SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 601 case SkCommandLineConfigGpu::kNative_API: |
| 609 SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0 , true, FLAGS_gpu_threading); | 602 contextType = GrContextFactory::kNative_GLContextType; |
| 610 SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4 , false, FLAGS_gpu_threading); | 603 break; |
| 611 SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16 , false, FLAGS_gpu_threading); | 604 case SkCommandLineConfigGpu::kGL_API: |
| 612 SINK("nvprmsaa4", GPUSink, Gr::kNative_GLContextType, Gr::kEnableNVP R_GLContextOptions, api, 4, true, FLAGS_gpu_threading); | 605 contextType = GrContextFactory::kGL_GLContextType; |
| 613 SINK("nvprmsaa16", GPUSink, Gr::kNative_GLContextType, Gr::kEnableNVP R_GLContextOptions, api, 16, true, FLAGS_gpu_threading); | 606 break; |
| 614 #if SK_ANGLE | 607 case SkCommandLineConfigGpu::kGLES_API: |
| 615 SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 608 contextType = GrContextFactory::kGLES_GLContextType; |
| 616 SINK("angle-gl", GPUSink, Gr::kANGLE_GL_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 609 break; |
| 617 #endif | 610 #if SK_ANGLE |
| 618 #if SK_COMMAND_BUFFER | 611 case SkCommandLineConfigGpu::kANGLE_API: |
| 619 SINK("commandbuffer", GPUSink, Gr::kCommandBuffer_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 612 contextType = GrContextFactory::kANGLE_GLContextType; |
| 620 #endif | 613 break; |
| 621 #if SK_MESA | 614 case SkCommandLineConfigGpu::kANGLE_GL_API: |
| 622 SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0 , false, FLAGS_gpu_threading); | 615 contextType = GrContextFactory::kANGLE_GL_GLContextType; |
|
bsalomon
2015/12/02 23:22:42
do we need this conversion? Could GrContextFactory
Kimmo Kinnunen
2015/12/04 14:26:18
The idea is that these are different things. GrCon
bsalomon
2015/12/07 14:33:19
GrContextFactory really only exists for our test t
| |
| 623 #endif | 616 break; |
| 617 #endif | |
| 618 #if SK_COMMAND_BUFFER | |
| 619 case SkCommandLineConfigGpu::kCommandBuffer_API: | |
| 620 contextType = GrContextFactory::kCommandBuffer_GLContextType ; | |
| 621 break; | |
| 622 #endif | |
| 623 #if SK_MESA | |
| 624 case SkCommandLineConfigGpu::kMESA_API: | |
| 625 contextType = GrContextFactory::kMESA_GLContextType; | |
| 626 break; | |
| 627 #endif | |
| 628 case SkCommandLineConfigGpu::kNull_API: | |
| 629 contextType = GrContextFactory::kNull_GLContextType; | |
| 630 break; | |
| 631 case SkCommandLineConfigGpu::kDebug_API: | |
| 632 contextType = GrContextFactory::kDebug_GLContextType; | |
| 633 break; | |
| 634 } | |
| 635 if (gpuConfig->getUseNVPR()) { | |
| 636 contextOptions = static_cast<GrContextFactory::GLContextOptions> ( | |
| 637 contextOptions | GrContextFactory::kEnableNVPR_GLContextOpti ons); | |
| 638 } | |
| 639 return new GPUSink(contextType, contextOptions, gpuConfig->getSample s(), gpuConfig->getUseDIText(), FLAGS_gpu_threading); | |
| 640 } | |
| 624 } | 641 } |
| 642 #endif | |
| 643 | |
| 644 #define SINK(t, sink, ...) if (config->getTag().equals(t)) { return new sink(__V A_ARGS__); } | |
| 625 | 645 |
| 626 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 646 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 627 SINK("hwui", HWUISink); | 647 SINK("hwui", HWUISink); |
| 628 #endif | 648 #endif |
| 629 | 649 |
| 630 if (FLAGS_cpu) { | 650 if (FLAGS_cpu) { |
| 631 SINK("565", RasterSink, kRGB_565_SkColorType); | 651 SINK("565", RasterSink, kRGB_565_SkColorType); |
| 632 SINK("8888", RasterSink, kN32_SkColorType); | 652 SINK("8888", RasterSink, kN32_SkColorType); |
| 633 SINK("pdf", PDFSink, "Pdfium"); | 653 SINK("pdf", PDFSink, "Pdfium"); |
| 634 SINK("pdf_poppler", PDFSink, "Poppler"); | 654 SINK("pdf_poppler", PDFSink, "Poppler"); |
| 635 SINK("skp", SKPSink); | 655 SINK("skp", SKPSink); |
| 636 SINK("svg", SVGSink); | 656 SINK("svg", SVGSink); |
| 637 SINK("null", NullSink); | 657 SINK("null", NullSink); |
| 638 SINK("xps", XPSSink); | 658 SINK("xps", XPSSink); |
| 639 } | 659 } |
| 640 #undef SINK | 660 #undef SINK |
| 641 return nullptr; | 661 return nullptr; |
| 642 } | 662 } |
| 643 | 663 |
| 644 static Sink* create_via(const char* tag, Sink* wrapped) { | 664 static Sink* create_via(const SkString& tag, Sink* wrapped) { |
| 645 #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); } | 665 #define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); } |
| 646 VIA("twice", ViaTwice, wrapped); | 666 VIA("twice", ViaTwice, wrapped); |
| 647 VIA("pipe", ViaPipe, wrapped); | 667 VIA("pipe", ViaPipe, wrapped); |
| 648 VIA("serialize", ViaSerialization, wrapped); | 668 VIA("serialize", ViaSerialization, wrapped); |
| 649 VIA("2ndpic", ViaSecondPicture, wrapped); | 669 VIA("2ndpic", ViaSecondPicture, wrapped); |
| 650 VIA("sp", ViaSingletonPictures, wrapped); | 670 VIA("sp", ViaSingletonPictures, wrapped); |
| 651 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped); | 671 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped); |
| 652 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); | 672 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); |
| 653 VIA("remote", ViaRemote, false, wrapped); | 673 VIA("remote", ViaRemote, false, wrapped); |
| 654 VIA("remote_cache", ViaRemote, true, wrapped); | 674 VIA("remote_cache", ViaRemote, true, wrapped); |
| 655 | 675 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 666 | 686 |
| 667 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 687 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 668 VIA("androidsdk", ViaAndroidSDK, wrapped); | 688 VIA("androidsdk", ViaAndroidSDK, wrapped); |
| 669 #endif | 689 #endif |
| 670 | 690 |
| 671 #undef VIA | 691 #undef VIA |
| 672 return nullptr; | 692 return nullptr; |
| 673 } | 693 } |
| 674 | 694 |
| 675 static void gather_sinks() { | 695 static void gather_sinks() { |
| 676 for (int i = 0; i < FLAGS_config.count(); i++) { | 696 SkCommandLineConfigArray configs; |
| 677 const char* config = FLAGS_config[i]; | 697 ParseConfigs(FLAGS_config, &configs); |
| 678 SkTArray<SkString> parts; | 698 for (int i = 0; i < configs.count(); i++) { |
| 679 SkStrSplit(config, "-", &parts); | 699 const SkCommandLineConfig& config = *configs[i]; |
| 700 Sink* sink = create_sink(&config); | |
| 701 if (sink == nullptr) { | |
| 702 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.getT ag().c_str(), config.getTag().c_str()); | |
| 703 break; | |
| 704 } | |
| 680 | 705 |
| 681 Sink* sink = nullptr; | 706 const SkTArray<SkString>& parts = config.getViaParts(); |
| 682 for (int i = parts.count(); i-- > 0;) { | 707 for (int j = parts.count(); j-- > 0;) { |
| 683 const char* part = parts[i].c_str(); | 708 const SkString& part = parts[j]; |
| 684 Sink* next = (sink == nullptr) ? create_sink(part) : create_via(part , sink); | 709 Sink* next = create_via(part, sink); |
| 685 if (next == nullptr) { | 710 if (next == nullptr) { |
| 686 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); | 711 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config. getTag().c_str(), part.c_str()); |
| 687 delete sink; | 712 delete sink; |
| 688 sink = nullptr; | 713 sink = nullptr; |
| 689 break; | 714 break; |
| 690 } | 715 } |
| 691 sink = next; | 716 sink = next; |
| 692 } | 717 } |
| 693 if (sink) { | 718 if (sink) { |
| 694 push_sink(config, sink); | 719 push_sink(config, sink); |
| 695 } | 720 } |
| 696 } | 721 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 const TaggedSink& sink; | 823 const TaggedSink& sink; |
| 799 | 824 |
| 800 static void Run(Task* task) { | 825 static void Run(Task* task) { |
| 801 SkString name = task->src->name(); | 826 SkString name = task->src->name(); |
| 802 | 827 |
| 803 // We'll skip drawing this Src/Sink pair if: | 828 // We'll skip drawing this Src/Sink pair if: |
| 804 // - the Src vetoes the Sink; | 829 // - the Src vetoes the Sink; |
| 805 // - this Src / Sink combination is on the blacklist; | 830 // - this Src / Sink combination is on the blacklist; |
| 806 // - it's a dry run. | 831 // - it's a dry run. |
| 807 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); | 832 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); |
| 808 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c _str(), | 833 SkString whyBlacklisted = is_blacklisted(task->sink.tag.c_str(), task->s rc.tag.c_str(), |
| 809 task->src.options.c_str(), name .c_str()); | 834 task->src.options.c_str(), name .c_str()); |
| 810 if (!whyBlacklisted.isEmpty()) { | 835 if (!whyBlacklisted.isEmpty()) { |
| 811 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); | 836 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
| 812 } | 837 } |
| 813 | 838 |
| 814 SkString log; | 839 SkString log; |
| 815 auto timerStart = now_ms(); | 840 auto timerStart = now_ms(); |
| 816 if (!FLAGS_dryRun && note.isEmpty()) { | 841 if (!FLAGS_dryRun && note.isEmpty()) { |
| 817 SkBitmap bitmap; | 842 SkBitmap bitmap; |
| 818 SkDynamicMemoryWStream stream; | 843 SkDynamicMemoryWStream stream; |
| 819 if (FLAGS_pre_log) { | 844 if (FLAGS_pre_log) { |
| 820 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); | 845 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag.c_str( )); |
| 821 } | 846 } |
| 822 start(task->sink.tag, task->src.tag, task->src.options, name.c_str() ); | 847 start(task->sink.tag.c_str(), task->src.tag, task->src.options, name .c_str()); |
| 823 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); | 848 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
| 824 if (!err.isEmpty()) { | 849 if (!err.isEmpty()) { |
| 825 auto elapsed = now_ms() - timerStart; | 850 auto elapsed = now_ms() - timerStart; |
| 826 if (err.isFatal()) { | 851 if (err.isFatal()) { |
| 827 fail(SkStringPrintf("%s %s %s %s: %s", | 852 fail(SkStringPrintf("%s %s %s %s: %s", |
| 828 task->sink.tag, | 853 task->sink.tag.c_str(), |
| 829 task->src.tag.c_str(), | 854 task->src.tag.c_str(), |
| 830 task->src.options.c_str(), | 855 task->src.options.c_str(), |
| 831 name.c_str(), | 856 name.c_str(), |
| 832 err.c_str())); | 857 err.c_str())); |
| 833 } else { | 858 } else { |
| 834 note.appendf(" (skipped: %s)", err.c_str()); | 859 note.appendf(" (skipped: %s)", err.c_str()); |
| 835 } | 860 } |
| 836 done(elapsed, task->sink.tag, task->src.tag, task->src.options, | 861 done(elapsed, task->sink.tag.c_str(), task->src.tag, task->src.o ptions, |
| 837 name, note, log); | 862 name, note, log); |
| 838 return; | 863 return; |
| 839 } | 864 } |
| 840 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); | 865 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
| 841 | 866 |
| 842 SkString md5; | 867 SkString md5; |
| 843 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { | 868 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { |
| 844 SkMD5 hash; | 869 SkMD5 hash; |
| 845 if (data->getLength()) { | 870 if (data->getLength()) { |
| 846 hash.writeStream(data, data->getLength()); | 871 hash.writeStream(data, data->getLength()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 859 } | 884 } |
| 860 } | 885 } |
| 861 SkMD5::Digest digest; | 886 SkMD5::Digest digest; |
| 862 hash.finish(digest); | 887 hash.finish(digest); |
| 863 for (int i = 0; i < 16; i++) { | 888 for (int i = 0; i < 16; i++) { |
| 864 md5.appendf("%02x", digest.data[i]); | 889 md5.appendf("%02x", digest.data[i]); |
| 865 } | 890 } |
| 866 } | 891 } |
| 867 | 892 |
| 868 if (!FLAGS_readPath.isEmpty() && | 893 if (!FLAGS_readPath.isEmpty() && |
| 869 !gGold.contains(Gold(task->sink.tag, task->src.tag.c_str(), | 894 !gGold.contains(Gold(task->sink.tag.c_str(), task->src.tag.c_str (), |
| 870 task->src.options.c_str(), name, md5))) { | 895 task->src.options.c_str(), name, md5))) { |
| 871 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", | 896 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", |
| 872 md5.c_str(), | 897 md5.c_str(), |
| 873 task->sink.tag, | 898 task->sink.tag.c_str(), |
| 874 task->src.tag.c_str(), | 899 task->src.tag.c_str(), |
| 875 task->src.options.c_str(), | 900 task->src.options.c_str(), |
| 876 name.c_str(), | 901 name.c_str(), |
| 877 FLAGS_readPath[0])); | 902 FLAGS_readPath[0])); |
| 878 } | 903 } |
| 879 | 904 |
| 880 if (!FLAGS_writePath.isEmpty()) { | 905 if (!FLAGS_writePath.isEmpty()) { |
| 881 const char* ext = task->sink->fileExtension(); | 906 const char* ext = task->sink->fileExtension(); |
| 882 if (data->getLength()) { | 907 if (data->getLength()) { |
| 883 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt r); | 908 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt r); |
| 884 SkASSERT(bitmap.drawsNothing()); | 909 SkASSERT(bitmap.drawsNothing()); |
| 885 } else if (!bitmap.drawsNothing()) { | 910 } else if (!bitmap.drawsNothing()) { |
| 886 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); | 911 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); |
| 887 } | 912 } |
| 888 } | 913 } |
| 889 } | 914 } |
| 890 done(now_ms()-timerStart, task->sink.tag, task->src.tag.c_str(), task->s rc.options.c_str(), | 915 done(now_ms()-timerStart, task->sink.tag.c_str(), task->src.tag.c_str(), task->src.options.c_str(), |
| 891 name, note, log); | 916 name, note, log); |
| 892 } | 917 } |
| 893 | 918 |
| 894 static void WriteToDisk(const Task& task, | 919 static void WriteToDisk(const Task& task, |
| 895 SkString md5, | 920 SkString md5, |
| 896 const char* ext, | 921 const char* ext, |
| 897 SkStream* data, size_t len, | 922 SkStream* data, size_t len, |
| 898 const SkBitmap* bitmap) { | 923 const SkBitmap* bitmap) { |
| 899 JsonWriter::BitmapResult result; | 924 JsonWriter::BitmapResult result; |
| 900 result.name = task.src->name(); | 925 result.name = task.src->name(); |
| 901 result.config = task.sink.tag; | 926 result.config = task.sink.tag.c_str(); |
| 902 result.sourceType = task.src.tag; | 927 result.sourceType = task.src.tag; |
| 903 result.sourceOptions = task.src.options; | 928 result.sourceOptions = task.src.options; |
| 904 result.ext = ext; | 929 result.ext = ext; |
| 905 result.md5 = md5; | 930 result.md5 = md5; |
| 906 JsonWriter::AddBitmapResult(result); | 931 JsonWriter::AddBitmapResult(result); |
| 907 | 932 |
| 908 // If an MD5 is uninteresting, we want it noted in the JSON file, | 933 // If an MD5 is uninteresting, we want it noted in the JSON file, |
| 909 // but don't want to dump it out as a .png (or whatever ext is). | 934 // but don't want to dump it out as a .png (or whatever ext is). |
| 910 if (gUninterestingHashes.contains(md5)) { | 935 if (gUninterestingHashes.contains(md5)) { |
| 911 return; | 936 return; |
| 912 } | 937 } |
| 913 | 938 |
| 914 const char* dir = FLAGS_writePath[0]; | 939 const char* dir = FLAGS_writePath[0]; |
| 915 if (0 == strcmp(dir, "@")) { // Needed for iOS. | 940 if (0 == strcmp(dir, "@")) { // Needed for iOS. |
| 916 dir = FLAGS_resourcePath[0]; | 941 dir = FLAGS_resourcePath[0]; |
| 917 } | 942 } |
| 918 sk_mkdir(dir); | 943 sk_mkdir(dir); |
| 919 | 944 |
| 920 SkString path; | 945 SkString path; |
| 921 if (FLAGS_nameByHash) { | 946 if (FLAGS_nameByHash) { |
| 922 path = SkOSPath::Join(dir, result.md5.c_str()); | 947 path = SkOSPath::Join(dir, result.md5.c_str()); |
| 923 path.append("."); | 948 path.append("."); |
| 924 path.append(ext); | 949 path.append(ext); |
| 925 if (sk_exists(path.c_str())) { | 950 if (sk_exists(path.c_str())) { |
| 926 return; // Content-addressed. If it exists already, we're done . | 951 return; // Content-addressed. If it exists already, we're done . |
| 927 } | 952 } |
| 928 } else { | 953 } else { |
| 929 path = SkOSPath::Join(dir, task.sink.tag); | 954 path = SkOSPath::Join(dir, task.sink.tag.c_str()); |
| 930 sk_mkdir(path.c_str()); | 955 sk_mkdir(path.c_str()); |
| 931 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str()); | 956 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str()); |
| 932 sk_mkdir(path.c_str()); | 957 sk_mkdir(path.c_str()); |
| 933 if (strcmp(task.src.options.c_str(), "") != 0) { | 958 if (strcmp(task.src.options.c_str(), "") != 0) { |
| 934 path = SkOSPath::Join(path.c_str(), task.src.options.c_str()); | 959 path = SkOSPath::Join(path.c_str(), task.src.options.c_str()); |
| 935 sk_mkdir(path.c_str()); | 960 sk_mkdir(path.c_str()); |
| 936 } | 961 } |
| 937 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); | 962 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); |
| 938 path.append("."); | 963 path.append("."); |
| 939 path.append(ext); | 964 path.append(ext); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1164 test(reporter, context->fGrContext, context->fGLContext); | 1189 test(reporter, context->fGrContext, context->fGLContext); |
| 1165 } | 1190 } |
| 1166 #endif | 1191 #endif |
| 1167 } // namespace | 1192 } // namespace |
| 1168 | 1193 |
| 1169 | 1194 |
| 1170 template<typename T> | 1195 template<typename T> |
| 1171 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo rter, | 1196 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo rter, |
| 1172 GrContextFactory* factory) { | 1197 GrContextFactory* factory) { |
| 1173 #if SK_SUPPORT_GPU | 1198 #if SK_SUPPORT_GPU |
| 1174 const GrGLStandard api = get_gpu_api(); | 1199 // Iterate over context types, except use "native" instead of explicitly try ing OpenGL and |
| 1175 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 1200 // OpenGL ES. Do not use GLES on desktop, since tests do not account for not fixing |
| 1176 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i; | 1201 // http://skbug.com/2809 |
| 1202 GrContextFactory::GLContextType contextTypes[] = { | |
| 1203 GrContextFactory::kNative_GLContextType, | |
| 1204 #if SK_ANGLE | |
| 1205 GrContextFactory::kANGLE_GLContextType, | |
| 1206 GrContextFactory::kANGLE_GL_GLContextType, | |
| 1207 #endif | |
| 1208 #if SK_COMMAND_BUFFER | |
| 1209 GrContextFactory::kCommandBuffer_GLContextType, | |
| 1210 #endif | |
| 1211 #if SK_MESA | |
| 1212 GrContextFactory::kMESA_GLContextType, | |
| 1213 #endif | |
| 1214 GrContextFactory::kNull_GLContextType, | |
| 1215 GrContextFactory::kDebug_GLContextType, | |
| 1216 }; | |
| 1217 static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kGLContextTy peCnt - 2, | |
| 1218 "Skipping unexpected GLContextType for GPU tests"); | |
| 1219 | |
| 1220 for (auto& contextType : contextTypes) { | |
| 1177 int contextSelector = kNone_GPUTestContexts; | 1221 int contextSelector = kNone_GPUTestContexts; |
| 1178 if (GrContextFactory::IsRenderingGLContext(glCtxType)) { | 1222 if (GrContextFactory::IsRenderingGLContext(contextType)) { |
| 1179 contextSelector |= kAllRendering_GPUTestContexts; | 1223 contextSelector |= kAllRendering_GPUTestContexts; |
| 1180 } | 1224 } |
| 1181 if (glCtxType == GrContextFactory::kNative_GLContextType) { | 1225 if (contextType == GrContextFactory::kNative_GLContextType) { |
| 1182 contextSelector |= kNative_GPUTestContexts; | 1226 contextSelector |= kNative_GPUTestContexts; |
| 1183 } | 1227 } |
| 1184 if (glCtxType == GrContextFactory::kNull_GLContextType) { | 1228 if (contextType == GrContextFactory::kNull_GLContextType) { |
| 1185 contextSelector |= kNull_GPUTestContexts; | 1229 contextSelector |= kNull_GPUTestContexts; |
| 1186 } | 1230 } |
| 1187 if ((testContexts & contextSelector) == 0) { | 1231 if ((testContexts & contextSelector) == 0) { |
| 1188 continue; | 1232 continue; |
| 1189 } | 1233 } |
| 1190 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glC txType, api)) { | 1234 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(con textType)) { |
| 1191 call_test(test, reporter, context); | 1235 call_test(test, reporter, context); |
| 1192 } | 1236 } |
| 1193 if (GrContextFactory::ContextInfo* context = | 1237 if (GrContextFactory::ContextInfo* context = |
| 1194 factory->getContextInfo(glCtxType, api, | 1238 factory->getContextInfo(contextType, GrContextFactory::kEnableNVPR_G LContextOptions)) { |
| 1195 GrContextFactory::kEnableNVPR_GLContextOptio ns)) { | |
| 1196 call_test(test, reporter, context); | 1239 call_test(test, reporter, context); |
| 1197 } | 1240 } |
| 1198 } | 1241 } |
| 1199 #endif | 1242 #endif |
| 1200 } | 1243 } |
| 1201 | 1244 |
| 1202 template | 1245 template |
| 1203 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, | 1246 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, |
| 1204 GPUTestContexts testContexts, | 1247 GPUTestContexts testContexts, |
| 1205 Reporter* reporter, | 1248 Reporter* reporter, |
| 1206 GrContextFactory* factory); | 1249 GrContextFactory* factory); |
| 1207 template | 1250 template |
| 1208 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG LContext test, | 1251 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG LContext test, |
| 1209 GPUTestContexts testC ontexts, | 1252 GPUTestContexts testC ontexts, |
| 1210 Reporter* reporter, | 1253 Reporter* reporter, |
| 1211 GrContextFactory* fac tory); | 1254 GrContextFactory* fac tory); |
| 1212 } // namespace skiatest | 1255 } // namespace skiatest |
| 1213 | 1256 |
| 1214 #if !defined(SK_BUILD_FOR_IOS) | 1257 #if !defined(SK_BUILD_FOR_IOS) |
| 1215 int main(int argc, char** argv) { | 1258 int main(int argc, char** argv) { |
| 1216 SkCommandLineFlags::Parse(argc, argv); | 1259 SkCommandLineFlags::Parse(argc, argv); |
| 1217 return dm_main(); | 1260 return dm_main(); |
| 1218 } | 1261 } |
| 1219 #endif | 1262 #endif |
| OLD | NEW |