DM::NullSink

Motivation:  The null sink can act as a control for experiments.

Review URL: https://codereview.chromium.org/873723007
This commit is contained in:
halcanary 2015-01-30 11:00:12 -08:00 committed by Commit bot
parent 23b03c3c5a
commit 022afb8384
3 changed files with 14 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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();

View File

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