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

Side by Side Diff: cc/paint/paint_recorder.h

Issue 2820133005: Revert of Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « cc/paint/paint_record.cc ('k') | cc/paint/paint_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CC_PAINT_PAINT_RECORDER_H_ 5 #ifndef CC_PAINT_PAINT_RECORDER_H_
6 #define CC_PAINT_PAINT_RECORDER_H_ 6 #define CC_PAINT_PAINT_RECORDER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/optional.h" 11 #include "base/optional.h"
12 #include "cc/paint/paint_canvas.h"
12 #include "cc/paint/paint_record.h" 13 #include "cc/paint/paint_record.h"
13 #include "cc/paint/record_paint_canvas.h" 14 #include "cc/paint/skia_paint_canvas.h"
15 #include "third_party/skia/include/core/SkPictureRecorder.h"
14 16
15 namespace cc { 17 namespace cc {
16 18
17 class PaintOpBuffer;
18
19 class CC_PAINT_EXPORT PaintRecorder { 19 class CC_PAINT_EXPORT PaintRecorder {
20 public: 20 public:
21 PaintRecorder(); 21 PaintRecorder();
22 ~PaintRecorder(); 22 ~PaintRecorder();
23 23
24 PaintCanvas* beginRecording(const SkRect& bounds); 24 ALWAYS_INLINE PaintCanvas* beginRecording(const SkRect& bounds) {
25 uint32_t record_flags = 0;
26 canvas_.emplace(recorder_.beginRecording(bounds, nullptr, record_flags));
27 return getRecordingCanvas();
28 }
25 29
26 // TODO(enne): should make everything go through the non-rect version. 30 ALWAYS_INLINE PaintCanvas* beginRecording(SkScalar width, SkScalar height) {
27 // See comments in RecordPaintCanvas ctor for why. 31 uint32_t record_flags = 0;
28 PaintCanvas* beginRecording(SkScalar width, SkScalar height) { 32 canvas_.emplace(
29 return beginRecording(SkRect::MakeWH(width, height)); 33 recorder_.beginRecording(width, height, nullptr, record_flags));
34 return getRecordingCanvas();
30 } 35 }
31 36
32 // Only valid between between and finish recording. 37 // Only valid between between and finish recording.
33 ALWAYS_INLINE RecordPaintCanvas* getRecordingCanvas() { 38 ALWAYS_INLINE PaintCanvas* getRecordingCanvas() {
34 return canvas_.has_value() ? &canvas_.value() : nullptr; 39 return canvas_.has_value() ? &canvas_.value() : nullptr;
35 } 40 }
36 41
37 sk_sp<PaintRecord> finishRecordingAsPicture(); 42 ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPicture() {
43 sk_sp<SkPicture> picture = recorder_.finishRecordingAsPicture();
44 // Some users (e.g. printing) use the existence of the recording canvas
45 // to know if recording is finished, so reset it here.
46 canvas_.reset();
47 return sk_ref_sp(static_cast<PaintRecord*>(picture.get()));
48 }
38 49
39 private: 50 private:
40 sk_sp<PaintOpBuffer> buffer_; 51 SkPictureRecorder recorder_;
41 base::Optional<RecordPaintCanvas> canvas_; 52 base::Optional<SkiaPaintCanvas> canvas_;
42 53
43 DISALLOW_COPY_AND_ASSIGN(PaintRecorder); 54 DISALLOW_COPY_AND_ASSIGN(PaintRecorder);
44 }; 55 };
45 56
46 } // namespace cc 57 } // namespace cc
47 58
48 #endif // CC_PAINT_PAINT_RECORDER_H_ 59 #endif // CC_PAINT_PAINT_RECORDER_H_
OLDNEW
« no previous file with comments | « cc/paint/paint_record.cc ('k') | cc/paint/paint_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698