Chromium Code Reviews| 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 "cc/paint/paint_export.h" | |
| 8 #include "third_party/skia/include/core/SkPicture.h" | 10 #include "third_party/skia/include/core/SkPicture.h" |
| 9 #include "third_party/skia/include/utils/SkPictureUtils.h" | 11 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 10 | 12 |
| 11 namespace cc { | 13 namespace cc { |
| 12 | 14 |
| 13 using PaintRecord = SkPicture; | 15 class PaintCanvas; |
| 14 | 16 |
| 15 inline const SkPicture* ToSkPicture(const PaintRecord* record) { | 17 class CC_PAINT_EXPORT PaintRecord : private SkPicture { |
| 16 return record; | 18 public: |
| 19 void playback(PaintCanvas* canvas); | |
| 20 | |
| 21 using SkPicture::playback; | |
| 22 using SkPicture::approximateBytesUsed; | |
| 23 using SkPicture::approximateOpCount; | |
| 24 using SkPicture::cullRect; | |
| 25 using SkRefCnt::ref; | |
| 26 using SkRefCnt::unref; | |
| 27 | |
| 28 private: | |
| 29 friend class PaintRecorder; | |
| 30 friend const SkPicture* ToSkPicture(const PaintRecord* record); | |
| 31 friend SkPicture* ToSkPicture(PaintRecord* record); | |
| 32 friend sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record); | |
| 33 friend sk_sp<const SkPicture> ToSkPicture(sk_sp<const PaintRecord> record); | |
| 34 }; | |
| 35 | |
| 36 ALWAYS_INLINE const SkPicture* ToSkPicture(const PaintRecord* record) { | |
| 37 return static_cast<const SkPicture*>(record); | |
| 17 } | 38 } |
| 18 | 39 |
| 19 inline SkPicture* ToSkPicture(PaintRecord* record) { | 40 ALWAYS_INLINE SkPicture* ToSkPicture(PaintRecord* record) { |
| 20 return record; | 41 return static_cast<SkPicture*>(record); |
| 21 } | 42 } |
| 22 | 43 |
| 23 inline sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record) { | 44 ALWAYS_INLINE sk_sp<SkPicture> ToSkPicture(sk_sp<PaintRecord> record) { |
| 24 return record; | 45 return sk_sp<SkPicture>(ToSkPicture(record.get())); |
|
danakj
2017/03/02 19:44:40
This adopts the pointer. But |record| will deref i
| |
| 25 } | 46 } |
| 26 | 47 |
| 27 inline sk_sp<const SkPicture> ToSkPicture(sk_sp<const PaintRecord> record) { | 48 ALWAYS_INLINE sk_sp<const SkPicture> ToSkPicture( |
| 28 return record; | 49 sk_sp<const PaintRecord> record) { |
| 50 return sk_sp<const SkPicture>(ToSkPicture(record.get())); | |
|
danakj
2017/03/02 19:44:40
same?
| |
| 29 } | 51 } |
| 30 | 52 |
| 31 } // namespace cc | 53 } // namespace cc |
| 32 | 54 |
| 33 #endif // CC_PAINT_PAINT_RECORD_H_ | 55 #endif // CC_PAINT_PAINT_RECORD_H_ |
| OLD | NEW |