Hardware Render Buffer
GPU-backed offscreen render target for realtime canvas presentation (API 29+).
Use this when you need high-throughput rendering into a hardware-accelerated Canvas without CPU pixel readback. For software pixels, snapshot testing, or CPU-side image workflows, use SoftwareRenderBuffer.
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 an ImageReader surface and a callback thread to receive messages from it, and must be closed.
It is expected that there is only a single consumer using consumeLatestBitmap.
Performance:
render enqueues GPU work and returns; frame publication is asynchronous.
Frame publication notifications are exposed via frameAvailable.
Threading:
Image acquisition and hardware-buffer wrapping run on a dedicated HandlerThread.
render and consumeLatestBitmap are safe to call from the caller thread (typically main).
API level:
Requires Android API 29+ for hardware bitmap and usage-flag support.
Parameters
Width in pixels.
Height in pixels.
Worker used for draw submission.
Throws
if width or height are not > 0.
if hardware rendering is unsupported on this API level.