-
- All Implemented Interfaces:
-
app.rive.core.CheckableAutoCloseable,java.lang.AutoCloseable
public abstract class RiveSurface implements CheckableAutoCloseable
A backend agnostic collection of surface properties needed for rendering.
A Rive render target, created natively which renders to the GL framebuffer
A draw key, which uniquely identifies draw operations in the CommandQueue
It also stores the width and height of the surface.
⚠️ This class assumes ownership of all resources and should be closed when no longer needed.
Alone it is not sufficient for rendering, as it lacks a backend-specific surface, which is provided by sub-classes.
-
-
Field Summary
Fields Modifier and Type Field Description private final Booleanclosedprivate final UniquePointerrenderTargetPointerprivate final LongsurfaceNativePointerprivate final DrawKeydrawKeyprivate final Integerwidthprivate final Integerheight
-
Constructor Summary
Constructors Constructor Description RiveSurface(Long renderTargetPointer, DrawKey drawKey, Integer width, Integer height)
-
Method Summary
Modifier and Type Method Description BooleangetClosed()final UniquePointergetRenderTargetPointer()The native pointer to the Rive render target, held in a unique pointer. abstract LonggetSurfaceNativePointer()The native pointer to the backend-specific surface, e.g. final DrawKeygetDrawKey()final IntegergetWidth()final IntegergetHeight()Unitclose()Closes the render target unique pointer, which in turn disposes the RiveSurface at large. -
-
Constructor Detail
-
RiveSurface
RiveSurface(Long renderTargetPointer, DrawKey drawKey, Integer width, Integer height)
- Parameters:
renderTargetPointer- The native pointer to the Rive render target.drawKey- The key used to uniquely identify the draw operation in the CommandQueue.width- The width of the surface in pixels.height- The height of the surface in pixels.
-
-
Method Detail
-
getRenderTargetPointer
final UniquePointer getRenderTargetPointer()
The native pointer to the Rive render target, held in a unique pointer.
-
getSurfaceNativePointer
abstract Long getSurfaceNativePointer()
The native pointer to the backend-specific surface, e.g. EGLSurface for OpenGL.
-
getDrawKey
final DrawKey getDrawKey()
-
close
@WorkerThread() Unit close()
Closes the render target unique pointer, which in turn disposes the RiveSurface at large.
⚠️ Do not call this directly from the main thread. It is meant to be called on the command server thread as a scheduled close using CommandQueue.destroyRiveSurface. This ensures that any draw calls in flight have a valid TextureView until completed.
-
-
-
-