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

Unified Diff: dm/DMSrcSink.cpp

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test for writeImage Created 4 years, 3 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 | « dm/DMSrcSink.h ('k') | gyp/core.gyp » ('j') | src/core/SkPipe.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index c3c8a7bc6e9b6a4bfd5c2298fc626c7cce25153f..6b330231d23622ef020c95ecee0ed41e862b52c2 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -30,6 +30,7 @@
#include "SkOpts.h"
#include "SkPictureData.h"
#include "SkPictureRecorder.h"
+#include "SkPipe.h"
#include "SkRandom.h"
#include "SkRecordDraw.h"
#include "SkRecorder.h"
@@ -1241,6 +1242,15 @@ Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
}
return draw_skdocument(src, doc.get(), dst);
}
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+PipeSink::PipeSink() {}
+
+Error PipeSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
+ return src.draw(SkPipeSerializer().beginWrite(SkRect::Make(src.size()), dst));
+}
+
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SKPSink::SKPSink() {}
@@ -1511,6 +1521,22 @@ Error ViaDefer::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
+ auto size = src.size();
+ return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+ SkDynamicMemoryWStream tmpStream;
+ Error err = src.draw(SkPipeSerializer().beginWrite(SkRect::Make(size), &tmpStream));
+ if (!err.isEmpty()) {
+ return err;
+ }
+ sk_sp<SkData> data = tmpStream.detachAsData();
+ SkPipeDeserializer().playback(data->data(), data->size(), canvas);
+ return check_against_reference(bitmap, src, fSink);
+ });
+}
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
// Draw the Src into two pictures, then draw the second picture into the wrapped Sink.
// This tests that any shortcuts we may take while recording that second picture are legal.
Error ViaSecondPicture::draw(
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/core.gyp » ('j') | src/core/SkPipe.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698