Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
SkPictureBackedGlyphDrawable Class Referencefinal

#include <SkGlyph.h>

Inheritance diagram for SkPictureBackedGlyphDrawable:
SkDrawable SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkPictureBackedGlyphDrawable (sk_sp< SkPicture > self)
 
- 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 ()
 
virtual void flatten (SkWriteBuffer &) const
 
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
 

Static Public Member Functions

static sk_sp< SkPictureBackedGlyphDrawableMakeFromBuffer (SkReadBuffer &buffer)
 
static void FlattenDrawable (SkWriteBuffer &buffer, SkDrawable *drawable)
 
- 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)
 

Private Member Functions

SkRect onGetBounds () override
 
size_t onApproximateBytesUsed () override
 
void onDraw (SkCanvas *canvas) override
 

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 &)
 
- 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 &)
 
virtual sk_sp< SkPictureonMakePictureSnapshot ()
 

Detailed Description

Definition at line 400 of file SkGlyph.h.

Constructor & Destructor Documentation

◆ SkPictureBackedGlyphDrawable()

SkPictureBackedGlyphDrawable::SkPictureBackedGlyphDrawable ( sk_sp< SkPicture self)

Definition at line 79 of file SkGlyph.cpp.

80 : fPicture(std::move(picture)) {}

Member Function Documentation

◆ FlattenDrawable()

void SkPictureBackedGlyphDrawable::FlattenDrawable ( SkWriteBuffer buffer,
SkDrawable drawable 
)
static

Definition at line 59 of file SkGlyph.cpp.

59 {
60 if (drawable == nullptr) {
61 buffer.writeByteArray(nullptr, 0);
62 return;
63 }
64
66 // These drawables should not have SkImages, SkTypefaces or SkPictures inside of them, so
67 // the default SkSerialProcs are sufficient.
69
70 // If the picture is too big, or there is no picture, then drop by sending an empty byte array.
71 if (!SkTFitsIn<uint32_t>(data->size()) || data->size() == 0) {
72 buffer.writeByteArray(nullptr, 0);
73 return;
74 }
75
76 buffer.writeByteArray(data->data(), data->size());
77}
sk_sp< SkPicture > makePictureSnapshot()
sk_sp< SkData > serialize(const SkSerialProcs *procs=nullptr) const
static const uint8_t buffer[]
sk_sp< const SkPicture > picture
Definition SkRecords.h:299
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ MakeFromBuffer()

sk_sp< SkPictureBackedGlyphDrawable > SkPictureBackedGlyphDrawable::MakeFromBuffer ( SkReadBuffer buffer)
static

Definition at line 37 of file SkGlyph.cpp.

37 {
38 SkASSERT(buffer.isValid());
39
40 sk_sp<SkData> pictureData = buffer.readByteArrayAsData();
41
42 // Return nullptr if invalid or there an empty drawable, which is represented by nullptr.
43 if (!buffer.isValid() || pictureData->size() == 0) {
44 return nullptr;
45 }
46
47 // Propagate the outer buffer's allow-SkSL setting to the picture decoder, using the flag on
48 // the deserial procs.
49 SkDeserialProcs procs;
50 procs.fAllowSkSL = buffer.allowSkSL();
51 sk_sp<SkPicture> picture = SkPicture::MakeFromData(pictureData.get(), &procs);
52 if (!buffer.validate(picture != nullptr)) {
53 return nullptr;
54 }
55
56 return sk_make_sp<SkPictureBackedGlyphDrawable>(std::move(picture));
57}
#define SkASSERT(cond)
Definition SkAssert.h:116
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
T * get() const
Definition SkRefCnt.h:303

◆ onApproximateBytesUsed()

size_t SkPictureBackedGlyphDrawable::onApproximateBytesUsed ( )
overrideprivatevirtual

Reimplemented from SkDrawable.

Definition at line 86 of file SkGlyph.cpp.

86 {
87 return sizeof(SkPictureBackedGlyphDrawable) + fPicture->approximateBytesUsed();
88}
virtual size_t approximateBytesUsed() const =0

◆ onDraw()

void SkPictureBackedGlyphDrawable::onDraw ( SkCanvas canvas)
overrideprivatevirtual

Implements SkDrawable.

Definition at line 90 of file SkGlyph.cpp.

90 {
91 canvas->drawPicture(fPicture);
92}
void drawPicture(const SkPicture *picture)
Definition SkCanvas.h:1961

◆ onGetBounds()

SkRect SkPictureBackedGlyphDrawable::onGetBounds ( )
overrideprivatevirtual

Implements SkDrawable.

Definition at line 82 of file SkGlyph.cpp.

82 {
83 return fPicture->cullRect();
84}
virtual SkRect cullRect() const =0

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