Drawable

class Drawable

Base-class for objects that draw into Canvas.

The object has a generation ID, which is guaranteed to be unique across all drawables. To allow for clients of the drawable that may want to cache the results, the drawable must change its generation ID whenever its internal state changes such that it will draw differently.

Classes

Type

Members:

Methods

Deserialize

__init__

draw

Overloaded function.

getBounds

Return the (conservative) bounds of what the drawable will draw.

getFlattenableType

getGenerationID

Return a unique value for this instance.

getTypeName

Returns the name of the object's class.

newPictureSnapshot

notifyDrawingChanged

Calling this invalidates the previous generation ID, and causes a new one to be computed the next time getGenerationID() is called.

ref

Increment the reference count.

serialize

unique

May return true if the caller is the only owner.

unref

Decrement the reference count.

Attributes

kColorFilter_Type

kDrawLooper_Type

kDrawable_Type

kImageFilter_Type

kMaskFilter_Type

kPathEffect_Type

Methods

static Drawable.Deserialize(type: skia.Flattanable.Type, b: Buffer) skia.Flattanable
Drawable.__init__(*args, **kwargs)
Drawable.draw(*args, **kwargs)

Overloaded function.

  1. draw(self: skia.Drawable, canvas: SkCanvas, matrix: skia.Matrix = None) -> None

    Draws into the specified content.

    The drawing sequence will be balanced upon return (i.e. the saveLevel() on the canvas will match what it was when draw() was called, and the current matrix and clip settings will not be changed.

  2. draw(self: skia.Drawable, canvas: SkCanvas, x: float, y: float) -> None

Drawable.getBounds(self: skia.Drawable) skia.Rect

Return the (conservative) bounds of what the drawable will draw.

If the drawable can change what it draws (e.g. animation or in response to some external change), then this must return a bounds that is always valid for all possible states.

Drawable.getFlattenableType(self: skia.Flattanable) skia.Flattanable.Type
Drawable.getGenerationID(self: skia.Drawable) int

Return a unique value for this instance.

If two calls to this return the same value, it is presumed that calling the draw() method will render the same thing as well.

Subclasses that change their state should call notifyDrawingChanged() to ensure that a new value will be returned the next time it is called.

Drawable.getTypeName(self: skia.Flattanable) str

Returns the name of the object’s class.

Implemented in Drawable.

Drawable.newPictureSnapshot(self: skia.Drawable) skia.Picture
Drawable.notifyDrawingChanged(self: skia.Drawable) None

Calling this invalidates the previous generation ID, and causes a new one to be computed the next time getGenerationID() is called.

Typically this is called by the object itself, in response to its internal state changing.

Drawable.ref(self: skia.RefCntBase) None

Increment the reference count.

Must be balanced by a call to unref().

Drawable.serialize(self: skia.Flattanable) skia.Data
Drawable.unique(self: skia.RefCntBase) bool

May return true if the caller is the only owner.

Ensures that all previous owner’s actions are complete.

Drawable.unref(self: skia.RefCntBase) None

Decrement the reference count.

If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.

Attributes

Drawable.kColorFilter_Type = <Type.kColorFilter_Type: 0>
Drawable.kDrawLooper_Type = <Type.kDrawLooper_Type: 3>
Drawable.kDrawable_Type = <Type.kDrawable_Type: 2>
Drawable.kImageFilter_Type = <Type.kImageFilter_Type: 4>
Drawable.kMaskFilter_Type = <Type.kMaskFilter_Type: 5>
Drawable.kPathEffect_Type = <Type.kPathEffect_Type: 6>