-
- All Implemented Interfaces:
-
app.rive.core.CheckableAutoCloseable,java.lang.AutoCloseable
public abstract class RenderContext implements CheckableAutoCloseable
A backend agnostic rendering context base class. Implementers contain the necessary state for Rive to render, both in Kotlin and with associated native objects.
Meant for use with a single CommandQueue.
⚠️ As it contains native resources, it implements CheckableAutoCloseable and should be closed when no longer needed, unless it is passed to a CommandQueue, in which case it assumes ownership of this object and will close it when it is disposed.
-
-
Field Summary
Fields Modifier and Type Field Description private final LongnativeObjectPointerprivate final Booleanclosed
-
Constructor Summary
Constructors Constructor Description RenderContext()
-
Method Summary
Modifier and Type Method Description final LonggetNativeObjectPointer()BooleangetClosed()Unitclose()Closes this resource, releasing any underlying resources. abstract RiveSurfacecreateSurface(SurfaceTexture surfaceTexture, DrawKey drawKey, CommandQueue commandQueue)Creates a backend-specific RiveSurface. abstract RiveSurfacecreateImageSurface(Integer width, Integer height, DrawKey drawKey, CommandQueue commandQueue)Creates an off-screen RiveSurface that renders into a pixel buffer instead of an Android Surface. -
-
Method Detail
-
getNativeObjectPointer
final Long getNativeObjectPointer()
-
createSurface
abstract RiveSurface createSurface(SurfaceTexture surfaceTexture, DrawKey drawKey, CommandQueue commandQueue)
Creates a backend-specific RiveSurface.
⚠️ The returned RiveSurface must be closed with CommandQueue.destroyRiveSurface when no longer needed.
- Parameters:
surfaceTexture- The Android SurfaceTexture to render against, likely created from a TextureView.drawKey- The key used to uniquely identify the draw operation in the CommandQueue.commandQueue- The owning command queue, used to create render targets on the command server thread.
-
createImageSurface
abstract RiveSurface createImageSurface(Integer width, Integer height, DrawKey drawKey, CommandQueue commandQueue)
Creates an off-screen RiveSurface that renders into a pixel buffer instead of an Android Surface. This surface can be used to capture rendered output for tasks such as snapshot testing.
⚠️ The returned RiveSurface must be closed with CommandQueue.destroyRiveSurface when no longer needed.
- Parameters:
width- The width of the surface in pixels.height- The height of the surface in pixels.drawKey- The key used to uniquely identify the draw operation in the CommandQueue.commandQueue- The owning command queue, used to create render targets on the command * server thread.
-
-
-
-