Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: dm/DM.cpp

Issue 1490113005: Add config options to run different GPU APIs to dm and nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-03-context-factory-glcontext-type
Patch Set: win angle Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 #if SK_BUILD_FOR_WIN
619 SINK("commandbuffer", GPUSink, Gr::kCommandBuffer_GLContextType, api, 0 , false, FLAGS_gpu_threading); 612 case SkCommandLineConfigGpu::kANGLE_API:
620 #endif 613 contextType = GrContextFactory::kANGLE_GLContextType;
621 #if SK_MESA 614 break;
622 SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0 , false, FLAGS_gpu_threading); 615 #endif
623 #endif 616 case SkCommandLineConfigGpu::kANGLE_GL_API:
617 contextType = GrContextFactory::kANGLE_GL_GLContextType;
618 break;
619 #endif
620 #if SK_COMMAND_BUFFER
621 case SkCommandLineConfigGpu::kCommandBuffer_API:
622 contextType = GrContextFactory::kCommandBuffer_GLContextType ;
623 break;
624 #endif
625 #if SK_MESA
626 case SkCommandLineConfigGpu::kMESA_API:
627 contextType = GrContextFactory::kMESA_GLContextType;
628 break;
629 #endif
630 case SkCommandLineConfigGpu::kNull_API:
631 contextType = GrContextFactory::kNull_GLContextType;
632 break;
633 case SkCommandLineConfigGpu::kDebug_API:
634 contextType = GrContextFactory::kDebug_GLContextType;
635 break;
636 }
637 if (gpuConfig->getUseNVPR()) {
638 contextOptions = static_cast<GrContextFactory::GLContextOptions> (
639 contextOptions | GrContextFactory::kEnableNVPR_GLContextOpti ons);
640 }
641 return new GPUSink(contextType, contextOptions, gpuConfig->getSample s(), gpuConfig->getUseDIText(), FLAGS_gpu_threading);
642 }
624 } 643 }
644 #endif
645
646 #define SINK(t, sink, ...) if (config->getTag().equals(t)) { return new sink(__V A_ARGS__); }
625 647
626 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 648 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
627 SINK("hwui", HWUISink); 649 SINK("hwui", HWUISink);
628 #endif 650 #endif
629 651
630 if (FLAGS_cpu) { 652 if (FLAGS_cpu) {
631 SINK("565", RasterSink, kRGB_565_SkColorType); 653 SINK("565", RasterSink, kRGB_565_SkColorType);
632 SINK("8888", RasterSink, kN32_SkColorType); 654 SINK("8888", RasterSink, kN32_SkColorType);
633 SINK("pdf", PDFSink, "Pdfium"); 655 SINK("pdf", PDFSink, "Pdfium");
634 SINK("pdf_poppler", PDFSink, "Poppler"); 656 SINK("pdf_poppler", PDFSink, "Poppler");
635 SINK("skp", SKPSink); 657 SINK("skp", SKPSink);
636 SINK("svg", SVGSink); 658 SINK("svg", SVGSink);
637 SINK("null", NullSink); 659 SINK("null", NullSink);
638 SINK("xps", XPSSink); 660 SINK("xps", XPSSink);
639 } 661 }
640 #undef SINK 662 #undef SINK
641 return nullptr; 663 return nullptr;
642 } 664 }
643 665
644 static Sink* create_via(const char* tag, Sink* wrapped) { 666 static Sink* create_via(const SkString& tag, Sink* wrapped) {
645 #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); } 667 #define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); }
646 VIA("twice", ViaTwice, wrapped); 668 VIA("twice", ViaTwice, wrapped);
647 VIA("pipe", ViaPipe, wrapped); 669 VIA("pipe", ViaPipe, wrapped);
648 VIA("serialize", ViaSerialization, wrapped); 670 VIA("serialize", ViaSerialization, wrapped);
649 VIA("2ndpic", ViaSecondPicture, wrapped); 671 VIA("2ndpic", ViaSecondPicture, wrapped);
650 VIA("sp", ViaSingletonPictures, wrapped); 672 VIA("sp", ViaSingletonPictures, wrapped);
651 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped); 673 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
652 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); 674 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
653 VIA("remote", ViaRemote, false, wrapped); 675 VIA("remote", ViaRemote, false, wrapped);
654 VIA("remote_cache", ViaRemote, true, wrapped); 676 VIA("remote_cache", ViaRemote, true, wrapped);
655 677
(...skipping 10 matching lines...) Expand all
666 688
667 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 689 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
668 VIA("androidsdk", ViaAndroidSDK, wrapped); 690 VIA("androidsdk", ViaAndroidSDK, wrapped);
669 #endif 691 #endif
670 692
671 #undef VIA 693 #undef VIA
672 return nullptr; 694 return nullptr;
673 } 695 }
674 696
675 static void gather_sinks() { 697 static void gather_sinks() {
676 for (int i = 0; i < FLAGS_config.count(); i++) { 698 SkCommandLineConfigArray configs;
677 const char* config = FLAGS_config[i]; 699 ParseConfigs(FLAGS_config, &configs);
678 SkTArray<SkString> parts; 700 for (int i = 0; i < configs.count(); i++) {
679 SkStrSplit(config, "-", &parts); 701 const SkCommandLineConfig& config = *configs[i];
702 Sink* sink = create_sink(&config);
703 if (sink == nullptr) {
704 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.getT ag().c_str(), config.getTag().c_str());
705 break;
706 }
680 707
681 Sink* sink = nullptr; 708 const SkTArray<SkString>& parts = config.getViaParts();
682 for (int i = parts.count(); i-- > 0;) { 709 for (int j = parts.count(); j-- > 0;) {
683 const char* part = parts[i].c_str(); 710 const SkString& part = parts[j];
684 Sink* next = (sink == nullptr) ? create_sink(part) : create_via(part , sink); 711 Sink* next = create_via(part, sink);
685 if (next == nullptr) { 712 if (next == nullptr) {
686 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); 713 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config. getTag().c_str(), part.c_str());
687 delete sink; 714 delete sink;
688 sink = nullptr; 715 sink = nullptr;
689 break; 716 break;
690 } 717 }
691 sink = next; 718 sink = next;
692 } 719 }
693 if (sink) { 720 if (sink) {
694 push_sink(config, sink); 721 push_sink(config, sink);
695 } 722 }
696 } 723 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 const TaggedSink& sink; 825 const TaggedSink& sink;
799 826
800 static void Run(Task* task) { 827 static void Run(Task* task) {
801 SkString name = task->src->name(); 828 SkString name = task->src->name();
802 829
803 // We'll skip drawing this Src/Sink pair if: 830 // We'll skip drawing this Src/Sink pair if:
804 // - the Src vetoes the Sink; 831 // - the Src vetoes the Sink;
805 // - this Src / Sink combination is on the blacklist; 832 // - this Src / Sink combination is on the blacklist;
806 // - it's a dry run. 833 // - it's a dry run.
807 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); 834 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : "");
808 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c _str(), 835 SkString whyBlacklisted = is_blacklisted(task->sink.tag.c_str(), task->s rc.tag.c_str(),
809 task->src.options.c_str(), name .c_str()); 836 task->src.options.c_str(), name .c_str());
810 if (!whyBlacklisted.isEmpty()) { 837 if (!whyBlacklisted.isEmpty()) {
811 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); 838 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
812 } 839 }
813 840
814 SkString log; 841 SkString log;
815 auto timerStart = now_ms(); 842 auto timerStart = now_ms();
816 if (!FLAGS_dryRun && note.isEmpty()) { 843 if (!FLAGS_dryRun && note.isEmpty()) {
817 SkBitmap bitmap; 844 SkBitmap bitmap;
818 SkDynamicMemoryWStream stream; 845 SkDynamicMemoryWStream stream;
819 if (FLAGS_pre_log) { 846 if (FLAGS_pre_log) {
820 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); 847 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag.c_str( ));
821 } 848 }
822 start(task->sink.tag, task->src.tag, task->src.options, name.c_str() ); 849 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); 850 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log);
824 if (!err.isEmpty()) { 851 if (!err.isEmpty()) {
825 auto elapsed = now_ms() - timerStart; 852 auto elapsed = now_ms() - timerStart;
826 if (err.isFatal()) { 853 if (err.isFatal()) {
827 fail(SkStringPrintf("%s %s %s %s: %s", 854 fail(SkStringPrintf("%s %s %s %s: %s",
828 task->sink.tag, 855 task->sink.tag.c_str(),
829 task->src.tag.c_str(), 856 task->src.tag.c_str(),
830 task->src.options.c_str(), 857 task->src.options.c_str(),
831 name.c_str(), 858 name.c_str(),
832 err.c_str())); 859 err.c_str()));
833 } else { 860 } else {
834 note.appendf(" (skipped: %s)", err.c_str()); 861 note.appendf(" (skipped: %s)", err.c_str());
835 } 862 }
836 done(elapsed, task->sink.tag, task->src.tag, task->src.options, 863 done(elapsed, task->sink.tag.c_str(), task->src.tag, task->src.o ptions,
837 name, note, log); 864 name, note, log);
838 return; 865 return;
839 } 866 }
840 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); 867 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream());
841 868
842 SkString md5; 869 SkString md5;
843 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { 870 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
844 SkMD5 hash; 871 SkMD5 hash;
845 if (data->getLength()) { 872 if (data->getLength()) {
846 hash.writeStream(data, data->getLength()); 873 hash.writeStream(data, data->getLength());
(...skipping 12 matching lines...) Expand all
859 } 886 }
860 } 887 }
861 SkMD5::Digest digest; 888 SkMD5::Digest digest;
862 hash.finish(digest); 889 hash.finish(digest);
863 for (int i = 0; i < 16; i++) { 890 for (int i = 0; i < 16; i++) {
864 md5.appendf("%02x", digest.data[i]); 891 md5.appendf("%02x", digest.data[i]);
865 } 892 }
866 } 893 }
867 894
868 if (!FLAGS_readPath.isEmpty() && 895 if (!FLAGS_readPath.isEmpty() &&
869 !gGold.contains(Gold(task->sink.tag, task->src.tag.c_str(), 896 !gGold.contains(Gold(task->sink.tag.c_str(), task->src.tag.c_str (),
870 task->src.options.c_str(), name, md5))) { 897 task->src.options.c_str(), name, md5))) {
871 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", 898 fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
872 md5.c_str(), 899 md5.c_str(),
873 task->sink.tag, 900 task->sink.tag.c_str(),
874 task->src.tag.c_str(), 901 task->src.tag.c_str(),
875 task->src.options.c_str(), 902 task->src.options.c_str(),
876 name.c_str(), 903 name.c_str(),
877 FLAGS_readPath[0])); 904 FLAGS_readPath[0]));
878 } 905 }
879 906
880 if (!FLAGS_writePath.isEmpty()) { 907 if (!FLAGS_writePath.isEmpty()) {
881 const char* ext = task->sink->fileExtension(); 908 const char* ext = task->sink->fileExtension();
882 if (data->getLength()) { 909 if (data->getLength()) {
883 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt r); 910 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt r);
884 SkASSERT(bitmap.drawsNothing()); 911 SkASSERT(bitmap.drawsNothing());
885 } else if (!bitmap.drawsNothing()) { 912 } else if (!bitmap.drawsNothing()) {
886 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); 913 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap);
887 } 914 }
888 } 915 }
889 } 916 }
890 done(now_ms()-timerStart, task->sink.tag, task->src.tag.c_str(), task->s rc.options.c_str(), 917 done(now_ms()-timerStart, task->sink.tag.c_str(), task->src.tag.c_str(), task->src.options.c_str(),
891 name, note, log); 918 name, note, log);
892 } 919 }
893 920
894 static void WriteToDisk(const Task& task, 921 static void WriteToDisk(const Task& task,
895 SkString md5, 922 SkString md5,
896 const char* ext, 923 const char* ext,
897 SkStream* data, size_t len, 924 SkStream* data, size_t len,
898 const SkBitmap* bitmap) { 925 const SkBitmap* bitmap) {
899 JsonWriter::BitmapResult result; 926 JsonWriter::BitmapResult result;
900 result.name = task.src->name(); 927 result.name = task.src->name();
901 result.config = task.sink.tag; 928 result.config = task.sink.tag.c_str();
902 result.sourceType = task.src.tag; 929 result.sourceType = task.src.tag;
903 result.sourceOptions = task.src.options; 930 result.sourceOptions = task.src.options;
904 result.ext = ext; 931 result.ext = ext;
905 result.md5 = md5; 932 result.md5 = md5;
906 JsonWriter::AddBitmapResult(result); 933 JsonWriter::AddBitmapResult(result);
907 934
908 // If an MD5 is uninteresting, we want it noted in the JSON file, 935 // 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). 936 // but don't want to dump it out as a .png (or whatever ext is).
910 if (gUninterestingHashes.contains(md5)) { 937 if (gUninterestingHashes.contains(md5)) {
911 return; 938 return;
912 } 939 }
913 940
914 const char* dir = FLAGS_writePath[0]; 941 const char* dir = FLAGS_writePath[0];
915 if (0 == strcmp(dir, "@")) { // Needed for iOS. 942 if (0 == strcmp(dir, "@")) { // Needed for iOS.
916 dir = FLAGS_resourcePath[0]; 943 dir = FLAGS_resourcePath[0];
917 } 944 }
918 sk_mkdir(dir); 945 sk_mkdir(dir);
919 946
920 SkString path; 947 SkString path;
921 if (FLAGS_nameByHash) { 948 if (FLAGS_nameByHash) {
922 path = SkOSPath::Join(dir, result.md5.c_str()); 949 path = SkOSPath::Join(dir, result.md5.c_str());
923 path.append("."); 950 path.append(".");
924 path.append(ext); 951 path.append(ext);
925 if (sk_exists(path.c_str())) { 952 if (sk_exists(path.c_str())) {
926 return; // Content-addressed. If it exists already, we're done . 953 return; // Content-addressed. If it exists already, we're done .
927 } 954 }
928 } else { 955 } else {
929 path = SkOSPath::Join(dir, task.sink.tag); 956 path = SkOSPath::Join(dir, task.sink.tag.c_str());
930 sk_mkdir(path.c_str()); 957 sk_mkdir(path.c_str());
931 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str()); 958 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
932 sk_mkdir(path.c_str()); 959 sk_mkdir(path.c_str());
933 if (strcmp(task.src.options.c_str(), "") != 0) { 960 if (strcmp(task.src.options.c_str(), "") != 0) {
934 path = SkOSPath::Join(path.c_str(), task.src.options.c_str()); 961 path = SkOSPath::Join(path.c_str(), task.src.options.c_str());
935 sk_mkdir(path.c_str()); 962 sk_mkdir(path.c_str());
936 } 963 }
937 path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); 964 path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
938 path.append("."); 965 path.append(".");
939 path.append(ext); 966 path.append(ext);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 test(reporter, context->fGrContext, context->fGLContext); 1191 test(reporter, context->fGrContext, context->fGLContext);
1165 } 1192 }
1166 #endif 1193 #endif
1167 } // namespace 1194 } // namespace
1168 1195
1169 1196
1170 template<typename T> 1197 template<typename T>
1171 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo rter, 1198 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo rter,
1172 GrContextFactory* factory) { 1199 GrContextFactory* factory) {
1173 #if SK_SUPPORT_GPU 1200 #if SK_SUPPORT_GPU
1174 const GrGLStandard api = get_gpu_api(); 1201 // Iterate over context types, except use "native" instead of explicitly try ing OpenGL and
1175 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { 1202 // OpenGL ES. Do not use GLES on desktop, since tests do not account for not fixing
1176 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i; 1203 // http://skbug.com/2809
1204 GrContextFactory::GLContextType contextTypes[] = {
1205 GrContextFactory::kNative_GLContextType,
1206 #if SK_ANGLE
1207 #if SK_BUILD_FOR_WIN
1208 GrContextFactory::kANGLE_GLContextType,
1209 #endif
1210 GrContextFactory::kANGLE_GL_GLContextType,
1211 #endif
1212 #if SK_COMMAND_BUFFER
1213 GrContextFactory::kCommandBuffer_GLContextType,
1214 #endif
1215 #if SK_MESA
1216 GrContextFactory::kMESA_GLContextType,
1217 #endif
1218 GrContextFactory::kNull_GLContextType,
1219 GrContextFactory::kDebug_GLContextType,
1220 };
1221 static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kGLContextTy peCnt - 2,
1222 "Skipping unexpected GLContextType for GPU tests");
1223
1224 for (auto& contextType : contextTypes) {
1177 int contextSelector = kNone_GPUTestContexts; 1225 int contextSelector = kNone_GPUTestContexts;
1178 if (GrContextFactory::IsRenderingGLContext(glCtxType)) { 1226 if (GrContextFactory::IsRenderingGLContext(contextType)) {
1179 contextSelector |= kAllRendering_GPUTestContexts; 1227 contextSelector |= kAllRendering_GPUTestContexts;
1180 } 1228 }
1181 if (glCtxType == GrContextFactory::kNative_GLContextType) { 1229 if (contextType == GrContextFactory::kNative_GLContextType) {
1182 contextSelector |= kNative_GPUTestContexts; 1230 contextSelector |= kNative_GPUTestContexts;
1183 } 1231 }
1184 if (glCtxType == GrContextFactory::kNull_GLContextType) { 1232 if (contextType == GrContextFactory::kNull_GLContextType) {
1185 contextSelector |= kNull_GPUTestContexts; 1233 contextSelector |= kNull_GPUTestContexts;
1186 } 1234 }
1187 if ((testContexts & contextSelector) == 0) { 1235 if ((testContexts & contextSelector) == 0) {
1188 continue; 1236 continue;
1189 } 1237 }
1190 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glC txType, api)) { 1238 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(con textType)) {
1191 call_test(test, reporter, context); 1239 call_test(test, reporter, context);
1192 } 1240 }
1193 if (GrContextFactory::ContextInfo* context = 1241 if (GrContextFactory::ContextInfo* context =
1194 factory->getContextInfo(glCtxType, api, 1242 factory->getContextInfo(contextType, GrContextFactory::kEnableNVPR_G LContextOptions)) {
1195 GrContextFactory::kEnableNVPR_GLContextOptio ns)) {
1196 call_test(test, reporter, context); 1243 call_test(test, reporter, context);
1197 } 1244 }
1198 } 1245 }
1199 #endif 1246 #endif
1200 } 1247 }
1201 1248
1202 template 1249 template
1203 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, 1250 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test,
1204 GPUTestContexts testContexts, 1251 GPUTestContexts testContexts,
1205 Reporter* reporter, 1252 Reporter* reporter,
1206 GrContextFactory* factory); 1253 GrContextFactory* factory);
1207 template 1254 template
1208 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG LContext test, 1255 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG LContext test,
1209 GPUTestContexts testC ontexts, 1256 GPUTestContexts testC ontexts,
1210 Reporter* reporter, 1257 Reporter* reporter,
1211 GrContextFactory* fac tory); 1258 GrContextFactory* fac tory);
1212 } // namespace skiatest 1259 } // namespace skiatest
1213 1260
1214 #if !defined(SK_BUILD_FOR_IOS) 1261 #if !defined(SK_BUILD_FOR_IOS)
1215 int main(int argc, char** argv) { 1262 int main(int argc, char** argv) {
1216 SkCommandLineFlags::Parse(argc, argv); 1263 SkCommandLineFlags::Parse(argc, argv);
1217 return dm_main(); 1264 return dm_main();
1218 } 1265 }
1219 #endif 1266 #endif
OLDNEW
« no previous file with comments | « bench/nanobench.cpp ('k') | dm/DMGpuSupport.h » ('j') | tools/flags/SkCommandLineFlags.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698