Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: experimental/tools/SkDmuxWStream.cpp

Issue 868333002: experimental/skp_to_pdf_md5 optionally also outputs pdf files (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/tools/SkDmuxWStream.h ('k') | experimental/tools/skp_to_pdf_md5.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/tools/SkDmuxWStream.cpp
diff --git a/experimental/tools/SkDmuxWStream.cpp b/experimental/tools/SkDmuxWStream.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6dde5bfa3b8475b908a2faf42e8015b33185d372
--- /dev/null
+++ b/experimental/tools/SkDmuxWStream.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkDmuxWStream.h"
+
+SkDmuxWStream::SkDmuxWStream(SkWStream* const streamArray[], size_t count)
+ : fWStreams(streamArray, static_cast<int>(count)), fBytesWritten(0) {}
+
+SkDmuxWStream::~SkDmuxWStream() {
+ for (int i = 0; i < fWStreams.count(); ++i) {
+ fWStreams[i]->flush();
+ }
+}
+
+bool SkDmuxWStream::write(const void* buffer, size_t size) {
+ for (int i = 0; i < fWStreams.count(); ++i) {
+ if (!fWStreams[i]->write(buffer, size)) {
+ return false;
+ }
+ }
+ fBytesWritten += size;
+ return true;
+}
+
+void SkDmuxWStream::newline() {
+ for (int i = 0; i < fWStreams.count(); ++i) {
+ fWStreams[i]->newline();
+ }
+ fBytesWritten += 1; // This may be a lie.
+}
+
+void SkDmuxWStream::flush() {
+ for (int i = 0; i < fWStreams.count(); ++i) {
+ fWStreams[i]->flush();
+ }
+}
+
+size_t SkDmuxWStream::bytesWritten() const { return fBytesWritten; }
« no previous file with comments | « experimental/tools/SkDmuxWStream.h ('k') | experimental/tools/skp_to_pdf_md5.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698