SkRecordedDrawable.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include "include/core/SkDrawable.h"
  10. #include "src/core/SkBBoxHierarchy.h"
  11. #include "src/core/SkRecord.h"
  12. #include "src/core/SkRecorder.h"
  13. class SkRecordedDrawable : public SkDrawable {
  14. public:
  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))
  20. , fBounds(bounds)
  21. {}
  22. void flatten(SkWriteBuffer& buffer) const override;
  23. protected:
  24. SkRect onGetBounds() override { return fBounds; }
  25. void onDraw(SkCanvas* canvas) override;
  26. SkPicture* onNewPictureSnapshot() override;
  27. private:
  28. SK_FLATTENABLE_HOOKS(SkRecordedDrawable)
  29. sk_sp<SkRecord> fRecord;
  30. sk_sp<SkBBoxHierarchy> fBBH;
  31. std::unique_ptr<SkDrawableList> fDrawableList;
  32. const SkRect fBounds;
  33. };
  34. #endif // SkRecordedDrawable_DEFINED