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 | |
| 10 | #include "SkBBoxHierarchy.h" |
| 11 | #include "SkDrawable.h" |
| 12 | #include "SkRecord.h" |
| 13 | #include "SkRecorder.h" |
| 14 | |
| 15 | class SkRecordedDrawable : public SkDrawable { |
| 16 | public: |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 17 | SkRecordedDrawable(sk_sp<SkRecord> record, sk_sp<SkBBoxHierarchy> bbh, |
| 18 | std::unique_ptr<SkDrawableList> drawableList, const SkRect& bounds) |
| 19 | : fRecord(std::move(record)) |
| 20 | , fBBH(std::move(bbh)) |
| 21 | , fDrawableList(std::move(drawableList)) |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 22 | , fBounds(bounds) |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 23 | {} |
| 24 | |
| 25 | void flatten(SkWriteBuffer& buffer) const override; |
| 26 | |
| 27 | static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer); |
| 28 | |
| 29 | Factory getFactory() const override { return CreateProc; } |
| 30 | |
| 31 | protected: |
| 32 | SkRect onGetBounds() override { return fBounds; } |
| 33 | |
| 34 | void onDraw(SkCanvas* canvas) override; |
| 35 | |
| 36 | SkPicture* onNewPictureSnapshot() override; |
| 37 | |
| 38 | private: |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 39 | sk_sp<SkRecord> fRecord; |
| 40 | sk_sp<SkBBoxHierarchy> fBBH; |
| 41 | std::unique_ptr<SkDrawableList> fDrawableList; |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 42 | const SkRect fBounds; |
msarett | 95416f4 | 2016-04-27 13:51:20 -0700 | [diff] [blame] | 43 | }; |
Hal Canary | 03a7f5f | 2017-02-10 09:06:38 -0500 | [diff] [blame^] | 44 | #endif // SkRecordedDrawable_DEFINED |