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

Unified Diff: dm/DMSrcSink.cpp

Issue 1644043003: SkMojo: test linking Skia against the Mojo SDK (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-01-29 (Friday) 12:55:47 EST Created 4 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
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 29886807a7117b412ddce12102d6433e7dc289cd..44bb3e09d0c510c8b6d67b373c7253dbf917e1cd 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -31,6 +31,10 @@
#include "SkSwizzler.h"
#include <functional>
+#ifdef SK_MOJO_EXPERIMENT
+#include "SkMojo.mojom.h"
mtklein 2016/01/29 18:09:40 Indent this #include a bit?
hal.canary 2016/01/29 18:44:50 done
+#endif
+
DEFINE_bool(multiPage, false, "For document-type backends, render the source"
" into multiple pages");
@@ -1233,6 +1237,40 @@ Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+#ifdef SK_MOJO_EXPERIMENT
+
+Error ViaMojo::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
mtklein 2016/01/29 18:09:40 Let's indent the bits inside the #ifdef / #else
hal.canary 2016/01/29 18:44:50 done
+ SkPictureRecorder recorder;
+ SkRect size = SkRect::Make(SkIRect::MakeSize(src.size()));
+ Error err = src.draw(recorder.beginRecording(size));
+ if (!err.isEmpty()) {
+ return err;
+ }
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+
+ SkASSERT(picture);
+ SkDynamicMemoryWStream buffer;
+ picture->serialize(&buffer);
+ auto mojoPicture = SkMojo::FlattenedPicture::New();
mtklein 2016/01/29 18:09:40 While we're getting used to the types, let's write
hal.canary 2016/01/29 18:44:50 done
+ mojoPicture->data.resize(buffer.bytesWritten());
+ buffer.copyTo(mojoPicture->data.data());
+ SkASSERT(mojoPicture.get() && mojoPicture->data);
mtklein 2016/01/29 18:09:40 // TODO: serialize + deserialize FlattenedPicture
hal.canary 2016/01/29 18:44:50 the todo is done.
+ SkMemoryStream tmpStream(mojoPicture->data.data(), mojoPicture->data.size());
+ picture.reset(SkPicture::CreateFromStream(&tmpStream));
+ auto fn = [&](SkCanvas* canvas) -> Error {
+ canvas->drawPicture(picture.get());
+ return check_against_reference(bitmap, src, fSink);
+ };
+ return draw_to_canvas(fSink, bitmap, stream, log, src.size(), fn);
+}
+#else // not SK_MOJO_EXPERIMENT
+Error ViaMojo::draw(const Src&, SkBitmap*, SkWStream*, SkString*) const {
+ return "Mojo is missing!";
+}
+#endif
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
// This is like SkRecords::Draw, in that it plays back SkRecords ops into a Canvas.
// Unlike SkRecords::Draw, it builds a single-op sub-picture out of each Draw-type op.
// This is an only-slightly-exaggerated simluation of Blink's Slimming Paint pictures.
« no previous file with comments | « dm/DMSrcSink.h ('k') | experimental/mojo/.gitignore » ('j') | experimental/mojo/generate.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698