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

Unified Diff: dm/DMSrcSink.cpp

Issue 1062043004: Add a Via to DM that records into two pictures and draws using the second. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 8 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') | no next file » | no next file with comments »
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 3db7582aa151fd4965a55e7e2354c84c14f836f9..de9ee76c8076611960e4a9849fa402326776155b 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -589,7 +589,7 @@ Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
if (!err.isEmpty()) {
return err;
}
- SkAutoTUnref<SkPicture> pic(recorder.endRecording());
+ SkAutoTUnref<SkPicture> pic(recorder.endRecordingAsPicture());
// Turn that picture into a Src that draws into our Sink via tiles + MPD.
struct ProxySrc : public Src {
@@ -638,4 +638,37 @@ Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
return fSink->draw(proxy, bitmap, stream, log);
}
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+ViaSecondPicture::ViaSecondPicture(Sink* sink) : fSink(sink) {}
+
+// 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(
+ const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
+ struct ProxySrc : public Src {
+ const Src& fSrc;
+ ProxySrc(const Src& src) : fSrc(src) {}
+
+ Error draw(SkCanvas* canvas) const override {
+ SkSize size;
+ size = fSrc.size();
+ SkPictureRecorder recorder;
+ SkAutoTUnref<SkPicture> pic;
+ for (int i = 0; i < 2; i++) {
+ Error err = fSrc.draw(recorder.beginRecording(size.width(), size.height()));
+ if (!err.isEmpty()) {
+ return err;
+ }
+ pic.reset(recorder.endRecordingAsPicture());
+ }
+ canvas->drawPicture(pic);
+ return "";
+ }
+ SkISize size() const override { return fSrc.size(); }
+ Name name() const override { sk_throw(); return ""; } // No one should be calling this.
+ } proxy(src);
+ return fSink->draw(proxy, bitmap, stream, log);
+}
+
} // namespace DM
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698