msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Hal Canary | 03a7f5f | 2017-02-10 09:06:38 -0500 | [diff] [blame] | 7 | #ifndef SkRecordedDrawable_DEFINED |
| 8 | #define SkRecordedDrawable_DEFINED |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkDrawable.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/core/SkRecord.h" |
| 12 | #include "src/core/SkRecorder.h" |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 13 | |
| 14 | class SkRecordedDrawable : public SkDrawable { |
| 15 | public: |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 16 | SkRecordedDrawable(sk_sp<SkRecord> record, sk_sp<SkBBoxHierarchy> bbh, |
| 17 | std::unique_ptr<SkDrawableList> drawableList, const SkRect& bounds) |
| 18 | : fRecord(std::move(record)) |
| 19 | , fBBH(std::move(bbh)) |
| 20 | , fDrawableList(std::move(drawableList)) |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 21 | , fBounds(bounds) |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 22 | {} |
| 23 | |
| 24 | void flatten(SkWriteBuffer& buffer) const override; |
| 25 | |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 26 | protected: |
| 27 | SkRect onGetBounds() override { return fBounds; } |
| 28 | |
| 29 | void onDraw(SkCanvas* canvas) override; |
| 30 | |
| 31 | SkPicture* onNewPictureSnapshot() override; |
| 32 | |
| 33 | private: |
Mike Klein | 4fee323 | 2018-10-18 17:27:16 -0400 | [diff] [blame] | 34 | SK_FLATTENABLE_HOOKS(SkRecordedDrawable) |
| 35 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 36 | sk_sp<SkRecord> fRecord; |
| 37 | sk_sp<SkBBoxHierarchy> fBBH; |
| 38 | std::unique_ptr<SkDrawableList> fDrawableList; |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 39 | const SkRect fBounds; |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 40 | }; |
Hal Canary | 03a7f5f | 2017-02-10 09:06:38 -0500 | [diff] [blame] | 41 | #endif // SkRecordedDrawable_DEFINED |