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 #ifndef SkRecordedDrawable_DEFINED 8 #define SkRecordedDrawable_DEFINED 9 10 #include "include/core/SkDrawable.h" 11 #include "src/core/SkRecord.h" 12 #include "src/core/SkRecorder.h" 13 14 class SkRecordedDrawable : public SkDrawable { 15 public: SkRecordedDrawable(sk_sp<SkRecord> record,sk_sp<SkBBoxHierarchy> bbh,std::unique_ptr<SkDrawableList> drawableList,const SkRect & bounds)16 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)) 21 , fBounds(bounds) 22 {} 23 24 void flatten(SkWriteBuffer& buffer) const override; 25 26 protected: onGetBounds()27 SkRect onGetBounds() override { return fBounds; } 28 size_t onApproximateBytesUsed() override; 29 30 void onDraw(SkCanvas* canvas) override; 31 32 SkPicture* onNewPictureSnapshot() override; 33 34 private: 35 SK_FLATTENABLE_HOOKS(SkRecordedDrawable) 36 37 sk_sp<SkRecord> fRecord; 38 sk_sp<SkBBoxHierarchy> fBBH; 39 std::unique_ptr<SkDrawableList> fDrawableList; 40 const SkRect fBounds; 41 }; 42 #endif // SkRecordedDrawable_DEFINED 43