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 #ifndef CC_PAINT_PAINT_RECORD_H_ | 5 #ifndef CC_PAINT_PAINT_RECORD_H_ |
6 #define CC_PAINT_PAINT_RECORD_H_ | 6 #define CC_PAINT_PAINT_RECORD_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | |
9 #include "base/macros.h" | |
10 #include "cc/paint/paint_export.h" | |
8 #include "third_party/skia/include/core/SkPicture.h" | 11 #include "third_party/skia/include/core/SkPicture.h" |
9 #include "third_party/skia/include/utils/SkPictureUtils.h" | 12 #include "third_party/skia/include/utils/SkPictureUtils.h" |
10 | 13 |
11 namespace cc { | 14 namespace cc { |
12 | 15 |
13 using PaintRecord = SkPicture; | 16 class PaintCanvas; |
14 | 17 |
15 inline const SkPicture* ToSkPicture(const PaintRecord* record) { | 18 class CC_PAINT_EXPORT PaintRecord : private SkPicture { |
vmpstr
2017/03/03 07:12:08
This class kinda looks funny, since it has no cons
| |
16 return record; | 19 public: |
20 void playback(PaintCanvas* canvas); | |
21 | |
22 using SkPicture::playback; | |
23 using SkPicture::approximateBytesUsed; | |
24 using SkPicture::approximateOpCount; | |
25 using SkPicture::cullRect; | |
26 using SkRefCnt::ref; | |
27 using SkRefCnt::unref; | |
28 | |
29 private: | |
30 friend class PaintRecorder; | |
31 friend const SkPicture* ToSkPicture(const PaintRecord* record); | |
32 friend SkPicture* ToSkPicture(PaintRecord* record); | |
33 friend sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record); | |
34 friend sk_sp<const SkPicture> ToSkPicture(sk_sp<const PaintRecord> record); | |
35 | |
36 DISALLOW_COPY_AND_ASSIGN(PaintRecord); | |
37 }; | |
38 | |
39 ALWAYS_INLINE const SkPicture* ToSkPicture(const PaintRecord* record) { | |
40 return static_cast<const SkPicture*>(record); | |
17 } | 41 } |
18 | 42 |
19 inline SkPicture* ToSkPicture(PaintRecord* record) { | 43 ALWAYS_INLINE SkPicture* ToSkPicture(PaintRecord* record) { |
20 return record; | 44 return static_cast<SkPicture*>(record); |
21 } | 45 } |
22 | 46 |
23 inline sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record) { | 47 ALWAYS_INLINE sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record) { |
24 return record; | 48 return sk_ref_sp(ToSkPicture(record.get())); |
25 } | 49 } |
26 | 50 |
27 inline sk_sp<const SkPicture> ToSkPicture(sk_sp<const PaintRecord> record) { | 51 ALWAYS_INLINE sk_sp<const SkPicture> ToSkPicture( |
28 return record; | 52 sk_sp<const PaintRecord> record) { |
53 return sk_ref_sp(ToSkPicture(record.get())); | |
29 } | 54 } |
30 | 55 |
31 } // namespace cc | 56 } // namespace cc |
32 | 57 |
33 #endif // CC_PAINT_PAINT_RECORD_H_ | 58 #endif // CC_PAINT_PAINT_RECORD_H_ |
OLD | NEW |