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