From 99cab4e3081e7e0ae8a72eb53cb42b1bef3719a3 Mon Sep 17 00:00:00 2001 From: mtklein Date: Fri, 31 Jul 2015 06:43:04 -0700 Subject: [PATCH] DM: track a direct/indirect bit for each Sink too. The decoding tests can now veto indirect sinks like pipe-8888. This moves Sink type detection from automatic to explicit; I can't think of any way to automatically differentiate pipe-8888 from 8888 based only on the output. (They should ideally be identical, after all.) BUG=skia:4138 Review URL: https://codereview.chromium.org/1263113002 --- dm/DM.cpp | 9 +-------- dm/DMSrcSink.cpp | 14 ++++++++------ dm/DMSrcSink.h | 25 +++++++++++++++++++++---- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/dm/DM.cpp b/dm/DM.cpp index f194304ecf..9dcdff1a0f 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -172,8 +172,6 @@ struct TaggedSrc : public SkAutoTDelete { struct TaggedSink : public SkAutoTDelete { const char* tag; - const char* options; - SinkType type; }; static const bool kMemcpyOK = true; @@ -358,14 +356,9 @@ static void push_sink(const char* tag, Sink* s) { exit(1); } - SinkType type = kRaster_SinkType; - if (sink->enclave() == kGPU_Enclave) { type = kGPU_SinkType; } - if (stream.bytesWritten() > 0) { type = kVector_SinkType; } - TaggedSink& ts = gSinks.push_back(); ts.reset(sink.detach()); ts.tag = tag; - ts.type = type; } static bool gpu_supported() { @@ -501,7 +494,7 @@ struct Task { // - the Src vetoes the Sink; // - this Src / Sink combination is on the blacklist; // - it's a dry run. - SkString note(task->src->veto(task->sink.type) ? " (veto)" : ""); + SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, task->src.options, name.c_str()); if (!whyBlacklisted.isEmpty()) { diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 0cd2ac9347..d1d9be030f 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -71,11 +71,12 @@ CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, float scale) , fScale(scale) {} -bool CodecSrc::veto(SinkType type) const { - // No need to test decoding to non-raster backend. +bool CodecSrc::veto(SinkFlags flags) const { + // No need to test decoding to non-raster or indirect backend. // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferred decode to // let the GPU handle it. - return type != kRaster_SinkType; + return flags.type != SinkFlags::kRaster + || flags.approach != SinkFlags::kDirect; } Error CodecSrc::draw(SkCanvas* canvas) const { @@ -460,10 +461,11 @@ Name CodecSrc::name() const { ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {} -bool ImageSrc::veto(SinkType type) const { - // No need to test decoding to non-raster backend. +bool ImageSrc::veto(SinkFlags flags) const { + // No need to test decoding to non-raster or indirect backend. // TODO: Instead, use lazy decoding to allow the GPU to handle cases like YUV. - return type != kRaster_SinkType; + return flags.type != SinkFlags::kRaster + || flags.approach != SinkFlags::kDirect; } Error ImageSrc::draw(SkCanvas* canvas) const { diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index 3b180eacf5..0aa22a0608 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -53,7 +53,10 @@ private: bool fFatal; }; -enum SinkType { kGPU_SinkType, kVector_SinkType, kRaster_SinkType }; +struct SinkFlags { + enum { kNull, kGPU, kVector, kRaster } type; + enum { kDirect, kIndirect } approach; +}; struct Src { // All Srcs must be thread safe. @@ -62,7 +65,7 @@ struct Src { virtual SkISize size() const = 0; virtual Name name() const = 0; virtual void modifyGrContextOptions(GrContextOptions* options) const {} - virtual bool veto(SinkType) const { return false; } + virtual bool veto(SinkFlags) const { return false; } }; struct Sink { @@ -75,6 +78,8 @@ struct Sink { // File extension for the content draw() outputs, e.g. "png", "pdf". virtual const char* fileExtension() const = 0; + + virtual SinkFlags flags() const = 0; }; enum { kAnyThread_Enclave, kGPU_Enclave }; @@ -114,7 +119,7 @@ public: Error draw(SkCanvas*) const override; SkISize size() const override; Name name() const override; - bool veto(SinkType) const override; + bool veto(SinkFlags) const override; private: Path fPath; Mode fMode; @@ -132,7 +137,7 @@ public: Error draw(SkCanvas*) const override; SkISize size() const override; Name name() const override; - bool veto(SinkType) const override; + bool veto(SinkFlags) const override; private: Path fPath; const int fDivisor; @@ -158,6 +163,7 @@ public: Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override { return kAnyThread_Enclave; } const char* fileExtension() const override { return ""; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkFlags::kDirect }; } }; @@ -168,6 +174,7 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override; const char* fileExtension() const override { return "png"; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; } private: GrContextFactory::GLContextType fContextType; GrGLStandard fGpuAPI; @@ -183,6 +190,7 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override { return kAnyThread_Enclave; } const char* fileExtension() const override { return "pdf"; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } }; class XPSSink : public Sink { @@ -192,6 +200,7 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override { return kAnyThread_Enclave; } const char* fileExtension() const override { return "xps"; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } }; class RasterSink : public Sink { @@ -201,6 +210,7 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override { return kAnyThread_Enclave; } const char* fileExtension() const override { return "png"; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; } private: SkColorType fColorType; }; @@ -212,6 +222,7 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override { return kAnyThread_Enclave; } const char* fileExtension() const override { return "skp"; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } }; class SVGSink : public Sink { @@ -221,6 +232,7 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; int enclave() const override { return kAnyThread_Enclave; } const char* fileExtension() const override { return "svg"; } + SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } }; @@ -231,6 +243,11 @@ public: explicit Via(Sink* sink) : fSink(sink) {} const char* fileExtension() const override { return fSink->fileExtension(); } int enclave() const override { return fSink->enclave(); } + SinkFlags flags() const override { + SinkFlags flags = fSink->flags(); + flags.approach = SinkFlags::kIndirect; + return flags; + } protected: SkAutoTDelete fSink; };