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

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

Issue 2690583002: Make cc/paint have concrete types (Closed)
Patch Set: Fix chromeos build Created 3 years, 9 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
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"
9 #include "base/memory/ptr_util.h"
10 #include "cc/paint/paint_canvas.h"
11 #include "cc/paint/paint_record.h"
8 #include "third_party/skia/include/core/SkPictureRecorder.h" 12 #include "third_party/skia/include/core/SkPictureRecorder.h"
9 13
10 namespace cc { 14 namespace cc {
11 using PaintRecorder = SkPictureRecorder; 15
12 } 16 class PaintRecorder : private SkPictureRecorder {
vmpstr 2017/03/02 21:52:42 I'm a bit hesitant about private inheritance... Wh
enne (OOO) 2017/03/02 23:59:44 Sure, changed to composition here. I think PaintR
17 public:
18 using SkPictureRecorder::SkPictureRecorder;
19 using SkPictureRecorder::RecordFlags;
20 using SkPictureRecorder::FinishFlags;
21
22 ALWAYS_INLINE PaintCanvas* beginRecording(const SkRect& bounds,
23 SkBBHFactory* bbhFactory = nullptr,
24 uint32_t recordFlags = 0) {
25 canvas_.SetInternalSkCanvas(
26 SkPictureRecorder::beginRecording(bounds, bbhFactory, recordFlags));
27 return getRecordingCanvas();
28 }
29
30 ALWAYS_INLINE PaintCanvas* beginRecording(SkScalar width,
31 SkScalar height,
32 SkBBHFactory* bbhFactory = nullptr,
33 uint32_t recordFlags = 0) {
34 canvas_.SetInternalSkCanvas(SkPictureRecorder::beginRecording(
35 width, height, bbhFactory, recordFlags));
36 return getRecordingCanvas();
37 }
38
39 ALWAYS_INLINE PaintCanvas* getRecordingCanvas() { return &canvas_; }
40
41 ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPicture(
42 uint32_t endFlags = 0) {
43 sk_sp<SkPicture> p = SkPictureRecorder::finishRecordingAsPicture(endFlags);
vmpstr 2017/03/02 21:52:42 p = picture?
44 return sk_ref_sp(static_cast<PaintRecord*>(p.get()));
vmpstr 2017/03/02 21:52:42 That's kind of an awkward pattern... Does static_c
enne (OOO) 2017/03/02 23:59:44 Yeah, it doesn't work, sorry.
45 }
46
47 ALWAYS_INLINE sk_sp<PaintRecord> finishRecordingAsPictureWithCull(
48 const SkRect& cullRect,
49 uint32_t endFlags = 0) {
50 sk_sp<SkPicture> p =
51 SkPictureRecorder::finishRecordingAsPictureWithCull(cullRect, endFlags);
52 return sk_ref_sp(static_cast<PaintRecord*>(p.get()));
53 }
54
55 private:
56 PaintCanvas canvas_;
57 };
58
59 } // namespace cc
13 60
14 #endif // CC_PAINT_PAINT_RECORDER_H_ 61 #endif // CC_PAINT_PAINT_RECORDER_H_
OLDNEW
« cc/paint/paint_flags.h ('K') | « cc/paint/paint_record.cc ('k') | cc/paint/paint_shader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698