195416f477d2ca264f2fb065455e95778a2289a1dmsarett/*
295416f477d2ca264f2fb065455e95778a2289a1dmsarett * Copyright 2016 Google Inc.
395416f477d2ca264f2fb065455e95778a2289a1dmsarett *
495416f477d2ca264f2fb065455e95778a2289a1dmsarett * Use of this source code is governed by a BSD-style license that can be
595416f477d2ca264f2fb065455e95778a2289a1dmsarett * found in the LICENSE file.
695416f477d2ca264f2fb065455e95778a2289a1dmsarett */
703a7f5fe2de9b0c886be4063533c91720ced0bf9Hal Canary#ifndef SkRecordedDrawable_DEFINED
803a7f5fe2de9b0c886be4063533c91720ced0bf9Hal Canary#define SkRecordedDrawable_DEFINED
995416f477d2ca264f2fb065455e95778a2289a1dmsarett
1095416f477d2ca264f2fb065455e95778a2289a1dmsarett#include "SkBBoxHierarchy.h"
1195416f477d2ca264f2fb065455e95778a2289a1dmsarett#include "SkDrawable.h"
1295416f477d2ca264f2fb065455e95778a2289a1dmsarett#include "SkRecord.h"
1395416f477d2ca264f2fb065455e95778a2289a1dmsarett#include "SkRecorder.h"
1495416f477d2ca264f2fb065455e95778a2289a1dmsarett
1595416f477d2ca264f2fb065455e95778a2289a1dmsarettclass SkRecordedDrawable : public SkDrawable {
1695416f477d2ca264f2fb065455e95778a2289a1dmsarettpublic:
176bd5284415bd983b0628c4941dff5def40018f5abungeman    SkRecordedDrawable(sk_sp<SkRecord> record, sk_sp<SkBBoxHierarchy> bbh,
186bd5284415bd983b0628c4941dff5def40018f5abungeman                       std::unique_ptr<SkDrawableList> drawableList, const SkRect& bounds)
196bd5284415bd983b0628c4941dff5def40018f5abungeman        : fRecord(std::move(record))
206bd5284415bd983b0628c4941dff5def40018f5abungeman        , fBBH(std::move(bbh))
216bd5284415bd983b0628c4941dff5def40018f5abungeman        , fDrawableList(std::move(drawableList))
2295416f477d2ca264f2fb065455e95778a2289a1dmsarett        , fBounds(bounds)
2395416f477d2ca264f2fb065455e95778a2289a1dmsarett    {}
2495416f477d2ca264f2fb065455e95778a2289a1dmsarett
2595416f477d2ca264f2fb065455e95778a2289a1dmsarett    void flatten(SkWriteBuffer& buffer) const override;
2695416f477d2ca264f2fb065455e95778a2289a1dmsarett
2795416f477d2ca264f2fb065455e95778a2289a1dmsarett    static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
2895416f477d2ca264f2fb065455e95778a2289a1dmsarett
2995416f477d2ca264f2fb065455e95778a2289a1dmsarett    Factory getFactory() const override { return CreateProc; }
3095416f477d2ca264f2fb065455e95778a2289a1dmsarett
3195416f477d2ca264f2fb065455e95778a2289a1dmsarettprotected:
3295416f477d2ca264f2fb065455e95778a2289a1dmsarett    SkRect onGetBounds() override { return fBounds; }
3395416f477d2ca264f2fb065455e95778a2289a1dmsarett
3495416f477d2ca264f2fb065455e95778a2289a1dmsarett    void onDraw(SkCanvas* canvas) override;
3595416f477d2ca264f2fb065455e95778a2289a1dmsarett
3695416f477d2ca264f2fb065455e95778a2289a1dmsarett    SkPicture* onNewPictureSnapshot() override;
3795416f477d2ca264f2fb065455e95778a2289a1dmsarett
3895416f477d2ca264f2fb065455e95778a2289a1dmsarettprivate:
396bd5284415bd983b0628c4941dff5def40018f5abungeman    sk_sp<SkRecord>                 fRecord;
406bd5284415bd983b0628c4941dff5def40018f5abungeman    sk_sp<SkBBoxHierarchy>          fBBH;
416bd5284415bd983b0628c4941dff5def40018f5abungeman    std::unique_ptr<SkDrawableList> fDrawableList;
4295416f477d2ca264f2fb065455e95778a2289a1dmsarett    const SkRect                    fBounds;
4395416f477d2ca264f2fb065455e95778a2289a1dmsarett};
4403a7f5fe2de9b0c886be4063533c91720ced0bf9Hal Canary#endif  // SkRecordedDrawable_DEFINED
45