SoftwareRenderBuffer

class SoftwareRenderBuffer(val width: Int, val height: Int, riveWorker: RiveWorker) : CheckableAutoCloseable

CPU-backed offscreen render target for snapshot-style rendering.

Use this when you need software pixels, such as snapshot testing or CPU-side image processing. For realtime presentation on hardware-accelerated canvases, prefer HardwareRenderBuffer.

The dimensions of this buffer are fixed at construction and cannot be resized. To render at a different size, create a new buffer.

Ownership/lifecycle:

  • This class owns its internal render surface and must be closed.

  • Callers own destination bitmaps passed to renderInto; reuse a destination bitmap per size for repeated renders.

  • Callers should recycle destination bitmaps when they are no longer needed.

Performance:

  • Rendering is synchronous and includes CPU pixel conversion.

  • This is typically slower than HardwareRenderBuffer for continuous realtime rendering.

Threading:

  • renderInto is synchronous with respect to buffer population.

API level:

  • Available on all Android API levels supported by this runtime.

Parameters

width

Width in pixels.

height

Height in pixels.

riveWorker

Worker used for drawing.

Throws

if width or height are not > 0.

Constructors

Link copied to clipboard
constructor(width: Int, height: Int, riveWorker: RiveWorker)

Properties

Link copied to clipboard
open override val closed: Boolean

Whether this resource has been closed.

Link copied to clipboard
val height: Int
Link copied to clipboard

Surface used for rendering and layout operations such as Artboard.resizeArtboard.

Link copied to clipboard
val width: Int

Functions

Link copied to clipboard
open override fun close()

Closes this resource, releasing any underlying resources.

Link copied to clipboard
fun renderInto(bitmap: Bitmap, artboard: Artboard, stateMachine: StateMachine, fit: Fit = RenderingDefaults.defaultFit(), clearColor: Int = RenderingDefaults.CLEAR_COLOR): Bitmap

Synchronously renders into bitmap.