blob: de1fca523386d3b35c507507068bf59073c06e34 [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 */
7
8#include "SkBBoxHierarchy.h"
9#include "SkDrawable.h"
10#include "SkRecord.h"
11#include "SkRecorder.h"
12
13class SkRecordedDrawable : public SkDrawable {
14public:
bungeman6bd52842016-10-27 09:30:08 -070015 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))
msarett95416f42016-04-27 13:51:20 -070020 , fBounds(bounds)
msarett95416f42016-04-27 13:51:20 -070021 {}
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
29protected:
30 SkRect onGetBounds() override { return fBounds; }
31
32 void onDraw(SkCanvas* canvas) override;
33
34 SkPicture* onNewPictureSnapshot() override;
35
36private:
bungeman6bd52842016-10-27 09:30:08 -070037 sk_sp<SkRecord> fRecord;
38 sk_sp<SkBBoxHierarchy> fBBH;
39 std::unique_ptr<SkDrawableList> fDrawableList;
msarett95416f42016-04-27 13:51:20 -070040 const SkRect fBounds;
msarett95416f42016-04-27 13:51:20 -070041};