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