blob: 2f8f6cc01e8cc648872188102ab9810685f34e69 [file] [log] [blame]
msarett95416f42016-04-27 13:51:20 -07001/*
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 Canary03a7f5f2017-02-10 09:06:38 -05007#ifndef SkRecordedDrawable_DEFINED
8#define SkRecordedDrawable_DEFINED
msarett95416f42016-04-27 13:51:20 -07009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkDrawable.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/core/SkRecord.h"
12#include "src/core/SkRecorder.h"
msarett95416f42016-04-27 13:51:20 -070013
14class SkRecordedDrawable : public SkDrawable {
15public:
bungeman6bd52842016-10-27 09:30:08 -070016 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))
msarett95416f42016-04-27 13:51:20 -070021 , fBounds(bounds)
msarett95416f42016-04-27 13:51:20 -070022 {}
23
24 void flatten(SkWriteBuffer& buffer) const override;
25
msarett95416f42016-04-27 13:51:20 -070026protected:
27 SkRect onGetBounds() override { return fBounds; }
28
29 void onDraw(SkCanvas* canvas) override;
30
31 SkPicture* onNewPictureSnapshot() override;
32
33private:
Mike Klein4fee3232018-10-18 17:27:16 -040034 SK_FLATTENABLE_HOOKS(SkRecordedDrawable)
35
bungeman6bd52842016-10-27 09:30:08 -070036 sk_sp<SkRecord> fRecord;
37 sk_sp<SkBBoxHierarchy> fBBH;
38 std::unique_ptr<SkDrawableList> fDrawableList;
msarett95416f42016-04-27 13:51:20 -070039 const SkRect fBounds;
msarett95416f42016-04-27 13:51:20 -070040};
Hal Canary03a7f5f2017-02-10 09:06:38 -050041#endif // SkRecordedDrawable_DEFINED