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