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 // This class is only used by casting from an SkPicture in PaintRecorder. |
16 return record; | 19 // This will be replaced with its own functionality in a future patch. |
| 20 class CC_PAINT_EXPORT PaintRecord : private SkPicture { |
| 21 public: |
| 22 void playback(PaintCanvas* canvas); |
| 23 |
| 24 using SkPicture::playback; |
| 25 using SkPicture::approximateBytesUsed; |
| 26 using SkPicture::approximateOpCount; |
| 27 using SkPicture::cullRect; |
| 28 using SkRefCnt::ref; |
| 29 using SkRefCnt::unref; |
| 30 |
| 31 private: |
| 32 friend class PaintRecorder; |
| 33 friend const SkPicture* ToSkPicture(const PaintRecord* record); |
| 34 friend SkPicture* ToSkPicture(PaintRecord* record); |
| 35 friend sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record); |
| 36 friend sk_sp<const SkPicture> ToSkPicture(sk_sp<const PaintRecord> record); |
| 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(PaintRecord); |
| 39 }; |
| 40 |
| 41 ALWAYS_INLINE const SkPicture* ToSkPicture(const PaintRecord* record) { |
| 42 return static_cast<const SkPicture*>(record); |
17 } | 43 } |
18 | 44 |
19 inline SkPicture* ToSkPicture(PaintRecord* record) { | 45 ALWAYS_INLINE SkPicture* ToSkPicture(PaintRecord* record) { |
20 return record; | 46 return static_cast<SkPicture*>(record); |
21 } | 47 } |
22 | 48 |
23 inline sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record) { | 49 ALWAYS_INLINE sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record) { |
24 return record; | 50 return sk_ref_sp(ToSkPicture(record.get())); |
25 } | 51 } |
26 | 52 |
27 inline sk_sp<const SkPicture> ToSkPicture(sk_sp<const PaintRecord> record) { | 53 ALWAYS_INLINE sk_sp<const SkPicture> ToSkPicture( |
28 return record; | 54 sk_sp<const PaintRecord> record) { |
| 55 return sk_ref_sp(ToSkPicture(record.get())); |
29 } | 56 } |
30 | 57 |
31 } // namespace cc | 58 } // namespace cc |
32 | 59 |
33 #endif // CC_PAINT_PAINT_RECORD_H_ | 60 #endif // CC_PAINT_PAINT_RECORD_H_ |
OLD | NEW |