diff options
author | halcanary <halcanary@google.com> | 2015-01-30 11:00:12 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-30 11:00:12 -0800 |
commit | 022afb8384019b448c7c1c62a9ff63fa9e477737 (patch) | |
tree | 13d646c61c5dd75b1515c9d5f2d4b76532001be2 | |
parent | 23b03c3c5a79d624c12bd1af5d11ba87967c53e2 (diff) |
DM::NullSink
Motivation: The null sink can act as a control for experiments.
Review URL: https://codereview.chromium.org/873723007
-rw-r--r-- | dm/DM.cpp | 4 | ||||
-rw-r--r-- | dm/DMJsonWriter.cpp | 1 | ||||
-rw-r--r-- | dm/DMSrcSink.h | 10 |
3 files changed, 14 insertions, 1 deletions
@@ -221,6 +221,7 @@ static Sink* create_sink(const char* tag) { SINK("8888", RasterSink, kN32_SkColorType); SINK("pdf", PDFSink); SINK("skp", SKPSink); + SINK("null", NullSink); } #undef SINK return NULL; @@ -339,7 +340,8 @@ struct Task { const char* ext = task->sink->fileExtension(); if (data->getLength()) { WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); - } else { + SkASSERT(bitmap.drawsNothing()); + } else if (!bitmap.drawsNothing()) { WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); } } diff --git a/dm/DMJsonWriter.cpp b/dm/DMJsonWriter.cpp index 56c1301df1..8f1fa7ed3c 100644 --- a/dm/DMJsonWriter.cpp +++ b/dm/DMJsonWriter.cpp @@ -75,6 +75,7 @@ void JsonWriter::DumpJson() { } SkString path = SkOSPath::Join(FLAGS_writePath[0], "dm.json"); + sk_mkdir(FLAGS_writePath[0]); SkFILEWStream stream(path.c_str()); stream.writeText(Json::StyledWriter().write(root).c_str()); stream.flush(); diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index e163a24253..67c8e5cf4f 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -8,6 +8,7 @@ #include "SkCanvas.h" #include "SkData.h" #include "SkGPipe.h" +#include "SkNullCanvas.h" #include "SkPicture.h" #include "gm.h" @@ -175,6 +176,15 @@ private: SkAutoTDelete<Sink> fSink; }; +class NullSink : public Sink { +public: + Error draw(const Src& src, SkBitmap*, SkWStream* out) const SK_OVERRIDE { + return src.draw(SkCreateNullCanvas()); + } + int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; } + const char* fileExtension() const SK_OVERRIDE { return ""; } +}; + } // namespace DM #endif//DMSrcSink_DEFINED |