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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SamplePipeControllers.h" 9 #include "SamplePipeControllers.h"
10 #include "SkCommonFlags.h" 10 #include "SkCommonFlags.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 582
583 Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const { 583 Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const {
584 // Record our Src into a picture. 584 // Record our Src into a picture.
585 SkSize size; 585 SkSize size;
586 size = src.size(); 586 size = src.size();
587 SkPictureRecorder recorder; 587 SkPictureRecorder recorder;
588 Error err = src.draw(recorder.beginRecording(size.width(), size.height(), fF actory.get())); 588 Error err = src.draw(recorder.beginRecording(size.width(), size.height(), fF actory.get()));
589 if (!err.isEmpty()) { 589 if (!err.isEmpty()) {
590 return err; 590 return err;
591 } 591 }
592 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 592 SkAutoTUnref<SkPicture> pic(recorder.endRecordingAsPicture());
593 593
594 // Turn that picture into a Src that draws into our Sink via tiles + MPD. 594 // Turn that picture into a Src that draws into our Sink via tiles + MPD.
595 struct ProxySrc : public Src { 595 struct ProxySrc : public Src {
596 const int fW, fH; 596 const int fW, fH;
597 const SkPicture* fPic; 597 const SkPicture* fPic;
598 const SkISize fSize; 598 const SkISize fSize;
599 ProxySrc(int w, int h, const SkPicture* pic, SkISize size) 599 ProxySrc(int w, int h, const SkPicture* pic, SkISize size)
600 : fW(w), fH(h), fPic(pic), fSize(size) {} 600 : fW(w), fH(h), fPic(pic), fSize(size) {}
601 601
602 Error draw(SkCanvas* canvas) const override { 602 Error draw(SkCanvas* canvas) const override {
(...skipping 28 matching lines...) Expand all
631 } 631 }
632 surfaces.unrefAll(); 632 surfaces.unrefAll();
633 return ""; 633 return "";
634 } 634 }
635 SkISize size() const override { return fSize; } 635 SkISize size() const override { return fSize; }
636 Name name() const override { sk_throw(); return ""; } // No one should be calling this. 636 Name name() const override { sk_throw(); return ""; } // No one should be calling this.
637 } proxy(fW, fH, pic, src.size()); 637 } proxy(fW, fH, pic, src.size());
638 return fSink->draw(proxy, bitmap, stream, log); 638 return fSink->draw(proxy, bitmap, stream, log);
639 } 639 }
640 640
641 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
642
643 ViaSecondPicture::ViaSecondPicture(Sink* sink) : fSink(sink) {}
644
645 // Draw the Src into two pictures, then draw the second picture into the wrapped Sink.
646 // This tests that any shortcuts we may take while recording that second picture are legal.
647 Error ViaSecondPicture::draw(
648 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t {
649 struct ProxySrc : public Src {
650 const Src& fSrc;
651 ProxySrc(const Src& src) : fSrc(src) {}
652
653 Error draw(SkCanvas* canvas) const override {
654 SkSize size;
655 size = fSrc.size();
656 SkPictureRecorder recorder;
657 SkAutoTUnref<SkPicture> pic;
658 for (int i = 0; i < 2; i++) {
659 Error err = fSrc.draw(recorder.beginRecording(size.width(), size .height()));
660 if (!err.isEmpty()) {
661 return err;
662 }
663 pic.reset(recorder.endRecordingAsPicture());
664 }
665 canvas->drawPicture(pic);
666 return "";
667 }
668 SkISize size() const override { return fSrc.size(); }
669 Name name() const override { sk_throw(); return ""; } // No one should be calling this.
670 } proxy(src);
671 return fSink->draw(proxy, bitmap, stream, log);
672 }
673
641 } // namespace DM 674 } // namespace DM
OLDNEW
« 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