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

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

Issue 2690583002: Make cc/paint have concrete types (Closed)
Patch Set: Rebase 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 {
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,
danakj 2017/03/02 19:44:40 why not chromium-style parameter names?
enne (OOO) 2017/03/02 23:59:43 Just following SkPictureRecorder example. Changed
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);
44 return sk_ref_sp(static_cast<PaintRecord*>(p.get()));
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_;
danakj 2017/03/02 19:44:40 you could use Optional to avoid the private constr
57 };
58
59 } // namespace cc
13 60
14 #endif // CC_PAINT_PAINT_RECORDER_H_ 61 #endif // CC_PAINT_PAINT_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698