Package io.github.humbleui.skija
Class Drawable
- java.lang.Object
-
- io.github.humbleui.skija.impl.Native
-
- io.github.humbleui.skija.impl.Managed
-
- io.github.humbleui.skija.impl.RefCnt
-
- io.github.humbleui.skija.Drawable
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public abstract class Drawable extends RefCnt
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.RefCnt
RefCnt._FinalizerHolder
-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.Managed
Managed.CleanerThunk
-
-
Field Summary
Fields Modifier and Type Field Description io.github.humbleui.types.Rect_bounds-
Fields inherited from class io.github.humbleui.skija.impl.Managed
_cleanable
-
-
Constructor Summary
Constructors Constructor Description Drawable()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void_nDraw(long ptr, long canvasPtr, float[] matrix)static int_nGetGenerationId(long ptr)void_nInit(long ptr)static long_nMake()static long_nMakePictureSnapshot(long ptr)static void_nNotifyDrawingChanged(long ptr)void_onDraw(long canvasPtr)Drawabledraw(Canvas canvas)Draws into the specified content.Drawabledraw(Canvas canvas, float x, float y)Draws into the specified content.Drawabledraw(Canvas canvas, @Nullable Matrix33 matrix)Draws into the specified content.@NotNull io.github.humbleui.types.RectgetBounds()Return the (conservative) bounds of what the drawable will draw.intgetGenerationId()Return a unique value for this instance.PicturemakePictureSnapshot()DrawablenotifyDrawingChanged()Calling this invalidates the previous generation ID, and causes a new one to be computed the next time getGenerationId() is called.abstract voidonDraw(Canvas canvas)abstract @NotNull io.github.humbleui.types.RectonGetBounds()-
Methods inherited from class io.github.humbleui.skija.impl.RefCnt
_nGetFinalizer, _nGetRefCount, getRefCount, toString
-
Methods inherited from class io.github.humbleui.skija.impl.Managed
_nInvokeFinalizer, close, isClosed
-
Methods inherited from class io.github.humbleui.skija.impl.Native
_nativeEquals, equals, getPtr, hashCode
-
-
-
-
Method Detail
-
draw
@NonExtendable public Drawable draw(Canvas canvas)
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.
-
draw
@NonExtendable public Drawable draw(Canvas canvas, float x, float y)
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.
-
draw
@NonExtendable public Drawable draw(Canvas canvas, @Nullable @Nullable Matrix33 matrix)
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.
-
makePictureSnapshot
@NonExtendable public Picture makePictureSnapshot()
-
getGenerationId
public int getGenerationId()
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.
-
getBounds
@NonExtendable @NotNull public @NotNull io.github.humbleui.types.Rect getBounds()
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.
-
notifyDrawingChanged
@NonExtendable public Drawable notifyDrawingChanged()
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.
-
onDraw
@OverrideOnly public abstract void onDraw(Canvas canvas)
-
onGetBounds
@OverrideOnly @NotNull public abstract @NotNull io.github.humbleui.types.Rect onGetBounds()
-
_onDraw
@Internal public void _onDraw(long canvasPtr)
-
_nMake
@Internal public static long _nMake()
-
_nInit
@Internal public void _nInit(long ptr)
-
_nDraw
@Internal public static void _nDraw(long ptr, long canvasPtr, float[] matrix)
-
_nMakePictureSnapshot
@Internal public static long _nMakePictureSnapshot(long ptr)
-
_nGetGenerationId
@Internal public static int _nGetGenerationId(long ptr)
-
_nNotifyDrawingChanged
@Internal public static void _nNotifyDrawingChanged(long ptr)
-
-