Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
SkRecordedDrawable Class Reference

#include <SkRecordedDrawable.h>

Inheritance diagram for SkRecordedDrawable:
SkDrawable SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkRecordedDrawable (sk_sp< SkRecord > record, sk_sp< SkBBoxHierarchy > bbh, std::unique_ptr< SkDrawableList > drawableList, const SkRect &bounds)
 
void flatten (SkWriteBuffer &buffer) const override
 
- Public Member Functions inherited from SkDrawable
void draw (SkCanvas *, const SkMatrix *=nullptr)
 
void draw (SkCanvas *, SkScalar x, SkScalar y)
 
std::unique_ptr< GpuDrawHandlersnapGpuDrawHandler (GrBackendApi backendApi, const SkMatrix &matrix, const SkIRect &clipBounds, const SkImageInfo &bufferInfo)
 
sk_sp< SkPicturemakePictureSnapshot ()
 
uint32_t getGenerationID ()
 
SkRect getBounds ()
 
size_t approximateBytesUsed ()
 
void notifyDrawingChanged ()
 
SkFlattenable::Type getFlattenableType () const override
 
Factory getFactory () const override
 
const char * getTypeName () const override
 
- Public Member Functions inherited from SkFlattenable
 SkFlattenable ()
 
sk_sp< SkDataserialize (const SkSerialProcs *=nullptr) const
 
size_t serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

SkRect onGetBounds () override
 
size_t onApproximateBytesUsed () override
 
void onDraw (SkCanvas *canvas) override
 
sk_sp< SkPictureonMakePictureSnapshot () override
 
- Protected Member Functions inherited from SkDrawable
 SkDrawable ()
 
virtual std::unique_ptr< GpuDrawHandleronSnapGpuDrawHandler (GrBackendApi, const SkMatrix &, const SkIRect &, const SkImageInfo &)
 
virtual std::unique_ptr< GpuDrawHandleronSnapGpuDrawHandler (GrBackendApi, const SkMatrix &)
 

Additional Inherited Members

- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type ,
  kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type
}
 
typedef sk_sp< SkFlattenable >(* Factory) (SkReadBuffer &)
 
- Static Public Member Functions inherited from SkDrawable
static SkFlattenable::Type GetFlattenableType ()
 
static sk_sp< SkDrawableDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static void Register (const char name[], Factory)
 
static sk_sp< SkFlattenableDeserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
 

Detailed Description

Definition at line 27 of file SkRecordedDrawable.h.

Constructor & Destructor Documentation

◆ SkRecordedDrawable()

SkRecordedDrawable::SkRecordedDrawable ( sk_sp< SkRecord record,
sk_sp< SkBBoxHierarchy bbh,
std::unique_ptr< SkDrawableList drawableList,
const SkRect bounds 
)
inline

Definition at line 29 of file SkRecordedDrawable.h.

31 : fRecord(std::move(record))
32 , fBBH(std::move(bbh))
33 , fDrawableList(std::move(drawableList))
34 , fBounds(bounds)
35 {}

Member Function Documentation

◆ flatten()

void SkRecordedDrawable::flatten ( SkWriteBuffer ) const
overridevirtual

Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).

DEPRECATED public : will move to protected ... use serialize() instead

Reimplemented from SkFlattenable.

Definition at line 60 of file SkRecordedDrawable.cpp.

60 {
61 // Write the bounds.
62 buffer.writeRect(fBounds);
63
64 // Create an SkPictureRecord to record the draw commands.
66 SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height()), 0);
67
68 // If the query contains the whole picture, don't bother with the bounding box hierarchy.
69 SkBBoxHierarchy* bbh;
70 if (pictureRecord.getLocalClipBounds().contains(fBounds)) {
71 bbh = nullptr;
72 } else {
73 bbh = fBBH.get();
74 }
75
76 // Record the draw commands.
77 SkDrawable* const* drawables = fDrawableList ? fDrawableList->begin() : nullptr;
78 int drawableCount = fDrawableList ? fDrawableList->count() : 0;
79 pictureRecord.beginRecording();
80 SkRecordDraw(*fRecord, &pictureRecord, nullptr, drawables, drawableCount, bbh, nullptr);
81 pictureRecord.endRecording();
82
83 // Flatten the recorded commands and drawables.
84 SkPictureData pictureData(pictureRecord, info);
85 pictureData.flatten(buffer);
86}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
void SkRecordDraw(const SkRecord &record, SkCanvas *canvas, SkPicture const *const drawablePicts[], SkDrawable *const drawables[], int drawableCount, const SkBBoxHierarchy *bbh, SkPicture::AbortCallback *callback)
T * get() const
Definition SkRefCnt.h:303
static const uint8_t buffer[]
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762

◆ onApproximateBytesUsed()

size_t SkRecordedDrawable::onApproximateBytesUsed ( )
overrideprotectedvirtual

Reimplemented from SkDrawable.

Definition at line 23 of file SkRecordedDrawable.cpp.

23 {
24 size_t drawablesSize = 0;
25 if (fDrawableList) {
26 for (auto&& drawable : *fDrawableList) {
27 drawablesSize += drawable->approximateBytesUsed();
28 }
29 }
30 return sizeof(*this) +
31 (fRecord ? fRecord->bytesUsed() : 0) +
32 (fBBH ? fBBH->bytesUsed() : 0) +
33 drawablesSize;
34}
virtual size_t bytesUsed() const =0
size_t bytesUsed() const
Definition SkRecord.cpp:25

◆ onDraw()

void SkRecordedDrawable::onDraw ( SkCanvas canvas)
overrideprotectedvirtual

Implements SkDrawable.

Definition at line 36 of file SkRecordedDrawable.cpp.

36 {
37 SkDrawable* const* drawables = nullptr;
38 int drawableCount = 0;
39 if (fDrawableList) {
40 drawables = fDrawableList->begin();
41 drawableCount = fDrawableList->count();
42 }
43 SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH.get(), nullptr);
44}

◆ onGetBounds()

SkRect SkRecordedDrawable::onGetBounds ( )
inlineoverrideprotectedvirtual

Implements SkDrawable.

Definition at line 40 of file SkRecordedDrawable.h.

40{ return fBounds; }

◆ onMakePictureSnapshot()

sk_sp< SkPicture > SkRecordedDrawable::onMakePictureSnapshot ( )
overrideprotectedvirtual

Default implementation calls onDraw() with a canvas that records into a picture. Subclasses may override if they have a more efficient way to return a picture for the current state of their drawable. Note: this picture must draw the same as what would be drawn from onDraw().

Reimplemented from SkDrawable.

Definition at line 46 of file SkRecordedDrawable.cpp.

46 {
47 // TODO: should we plumb-down the BBHFactory and recordFlags from our host
48 // PictureRecorder?
49 std::unique_ptr<SkBigPicture::SnapshotArray> pictList{
50 fDrawableList ? fDrawableList->newDrawableSnapshot() : nullptr
51 };
52
53 size_t subPictureBytes = 0;
54 for (int i = 0; pictList && i < pictList->count(); i++) {
55 subPictureBytes += pictList->begin()[i]->approximateBytesUsed();
56 }
57 return sk_make_sp<SkBigPicture>(fBounds, fRecord, std::move(pictList), fBBH, subPictureBytes);
58}

The documentation for this class was generated from the following files: