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

Unified Diff: cc/paint/paint_recorder.cc

Issue 2768143002: Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: more const casting Created 3 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 | « cc/paint/paint_recorder.h ('k') | cc/paint/record_paint_canvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/paint/paint_recorder.cc
diff --git a/cc/paint/paint_recorder.cc b/cc/paint/paint_recorder.cc
index 672f0712725d4f1c20b56631d66061c737455c40..2ed17c74e29d02ee54f07a326ebc63cdcea935e6 100644
--- a/cc/paint/paint_recorder.cc
+++ b/cc/paint/paint_recorder.cc
@@ -4,9 +4,36 @@
#include "cc/paint/paint_recorder.h"
+#include "cc/paint/paint_op_buffer.h"
+
namespace cc {
PaintRecorder::PaintRecorder() = default;
+
PaintRecorder::~PaintRecorder() = default;
+PaintCanvas* PaintRecorder::beginRecording(const SkRect& bounds) {
+ buffer_.reset(new PaintOpBuffer(bounds));
+ canvas_.emplace(buffer_.get());
+ return getRecordingCanvas();
+}
+
+sk_sp<PaintRecord> PaintRecorder::finishRecordingAsPicture() {
+ // SkPictureRecorder users expect that their saves are automatically
+ // closed for them.
+ //
+ // NOTE: Blink paint in general doesn't appear to need this, but the
+ // RecordingImageBufferSurface::fallBackToRasterCanvas finishing off the
+ // current frame depends on this. Maybe we could remove this assumption and
+ // just have callers do it.
+ canvas_->restoreToCount(1);
+
+ // Some users (e.g. printing) use the existence of the recording canvas
+ // to know if recording is finished, so reset it here.
+ canvas_.reset();
+
+ buffer_->ShrinkToFit();
+ return std::move(buffer_);
+}
+
} // namespace cc
« no previous file with comments | « cc/paint/paint_recorder.h ('k') | cc/paint/record_paint_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698