OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/paint/paint_recorder.h" | 5 #include "cc/paint/paint_recorder.h" |
6 | 6 |
| 7 #include "cc/paint/paint_op_buffer.h" |
| 8 |
7 namespace cc { | 9 namespace cc { |
8 | 10 |
9 PaintRecorder::PaintRecorder() = default; | 11 PaintRecorder::PaintRecorder() = default; |
| 12 |
10 PaintRecorder::~PaintRecorder() = default; | 13 PaintRecorder::~PaintRecorder() = default; |
11 | 14 |
| 15 PaintCanvas* PaintRecorder::beginRecording(const SkRect& bounds) { |
| 16 buffer_.reset(new PaintOpBuffer(bounds)); |
| 17 canvas_.emplace(buffer_.get()); |
| 18 return getRecordingCanvas(); |
| 19 } |
| 20 |
| 21 sk_sp<PaintRecord> PaintRecorder::finishRecordingAsPicture() { |
| 22 // SkPictureRecorder users expect that their saves are automatically |
| 23 // closed for them. |
| 24 // |
| 25 // NOTE: Blink paint in general doesn't appear to need this, but the |
| 26 // RecordingImageBufferSurface::fallBackToRasterCanvas finishing off the |
| 27 // current frame depends on this. Maybe we could remove this assumption and |
| 28 // just have callers do it. |
| 29 canvas_->restoreToCount(1); |
| 30 |
| 31 // Some users (e.g. printing) use the existence of the recording canvas |
| 32 // to know if recording is finished, so reset it here. |
| 33 canvas_.reset(); |
| 34 |
| 35 buffer_->ShrinkToFit(); |
| 36 return std::move(buffer_); |
| 37 } |
| 38 |
12 } // namespace cc | 39 } // namespace cc |
OLD | NEW |