-
- All Implemented Interfaces:
-
android.view.Choreographer.FrameCallback,app.rive.runtime.kotlin.core.RefCount
public abstract class Renderer extends NativeObject implements Choreographer.FrameCallback
-
-
Field Summary
Fields Modifier and Type Field Description private BooleanisPlayingprivate BooleanisAttachedprivate final Floatwidthprivate final Floatheightprivate final FloataverageFpsprivate RendererTypetypeprivate final Booleantraceprivate final BooleanhasCppObjectprivate AtomicIntegerrefsprivate LongcppPointerprivate final <ERROR CLASS>dependenciesprivate final IntegerrefCount
-
Constructor Summary
Constructors Constructor Description Renderer(RendererType type, Boolean trace)
-
Method Summary
Modifier and Type Method Description final BooleangetIsPlaying()final UnitsetIsPlaying(Boolean isPlaying)final BooleangetIsAttached()final UnitsetIsAttached(Boolean isAttached)final FloatgetWidth()final FloatgetHeight()final FloatgetAverageFps()final RendererTypegetType()final UnitsetType(RendererType type)final BooleangetTrace()final BooleangetHasCppObject()final AtomicIntegergetRefs()final UnitsetRefs(AtomicInteger refs)final LonggetCppPointer()final UnitsetCppPointer(Long cppPointer)final <ERROR CLASS>getDependencies()IntegergetRefCount()UnitcppDelete(Long pointer)Unitmake()abstract Unitdraw()abstract Unitadvance(Float elapsed)final Unitstart()Starts the renderer and registers for frameCallbacks. final UnitsetSurface(Surface surface)final Unitstop()Calls stopThread and removes any pending FrameCallbacks from the Choreographer. UnitscheduleFrame()final Unitsave()final Unitrestore()final Unitalign(Fit fit, Alignment alignment, RectF targetBounds, RectF sourceBounds, Float scaleFactor)final Unittransform(Float x, Float sy, Float sx, Float y, Float tx, Float ty)final Unitscale(Float sx, Float sy)final Unittranslate(Float dx, Float dy)UnitdoFrame(Long frameTimeNanos)Unitdelete()Trigger a deletion of the underlying C++ object. -
-
Constructor Detail
-
Renderer
Renderer(RendererType type, Boolean trace)
-
-
Method Detail
-
getIsPlaying
final Boolean getIsPlaying()
-
setIsPlaying
final Unit setIsPlaying(Boolean isPlaying)
-
getIsAttached
final Boolean getIsAttached()
-
setIsAttached
final Unit setIsAttached(Boolean isAttached)
-
getAverageFps
final Float getAverageFps()
-
getType
@VisibleForTesting(otherwise = 2) final RendererType getType()
-
setType
final Unit setType(RendererType type)
-
getHasCppObject
final Boolean getHasCppObject()
-
getRefs
final AtomicInteger getRefs()
-
setRefs
final Unit setRefs(AtomicInteger refs)
-
getCppPointer
final Long getCppPointer()
-
setCppPointer
final Unit setCppPointer(Long cppPointer)
-
getDependencies
final <ERROR CLASS> getDependencies()
-
getRefCount
Integer getRefCount()
-
draw
@WorkerThread() abstract Unit draw()
-
advance
@WorkerThread() abstract Unit advance(Float elapsed)
-
start
final Unit start()
Starts the renderer and registers for frameCallbacks.
Goal: When we trigger start, doFrame gets called once per frame until we stop or the animation finishes.
Gotchas:
scheduleFrame triggers callbacks to doFrame which in turn schedules more frames
If we call scheduleFrame multiple times we enter multiple parallel animations loops
To avoid this we check isPlaying and deregister FrameCallbacks when stop is called by users
-
setSurface
final Unit setSurface(Surface surface)
-
stop
@CallSuper() final Unit stop()
Calls stopThread and removes any pending FrameCallbacks from the Choreographer.
Note: this is not safe to call from the animation thread. e.g inside draw/advance callbacks.
-
scheduleFrame
Unit scheduleFrame()
-
align
final Unit align(Fit fit, Alignment alignment, RectF targetBounds, RectF sourceBounds, Float scaleFactor)
-
-
-
-