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
This commit is contained in:
mtklein 2015-07-31 06:43:04 -07:00 committed by Commit bot
parent 58ff81b42b
commit 99cab4e308
3 changed files with 30 additions and 18 deletions

View File

@ -172,8 +172,6 @@ struct TaggedSrc : public SkAutoTDelete<Src> {
struct TaggedSink : public SkAutoTDelete<Sink> {
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()) {

View File

@ -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 {

View File

@ -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<Sink> fSink;
};