CanvasBufferedRenderer.RenderResult


class CanvasBufferedRenderer.RenderResult


Class that contains data regarding the result of the render request. Consumers are to wait on the provided SyncFenceCompat if it is non null before consuming the HardwareBuffer provided to as well as verify that the status returned by RenderResult.status returns RenderResult.SUCCESS.

For example:

fun handleRenderResult(result: RenderResult) {
// block on the fence if it is non-null
result.fence?.let { fence ->
fence.awaitForever()
fence.close()
}
// consume contents of RenderResult.hardwareBuffer
}

Summary

Constants

const Int

Render request failed with an unknown error

const Int

Render request was completed successfully

Public constructors

RenderResult(buffer: HardwareBuffer, mFence: SyncFenceCompat?, mStatus: Int)

Public properties

SyncFenceCompat?

Optional fence that should be waited upon before consuming hardwareBuffer.

HardwareBuffer

HardwareBuffer that contains the result of the render request.

Int

Status code for the RenderResult either SUCCESS if rendering completed or ERROR_UNKNOWN if the rendering could not be completed.

Constants

ERROR_UNKNOWN

const val ERROR_UNKNOWN = 1: Int

Render request failed with an unknown error

SUCCESS

const val SUCCESS = 0: Int

Render request was completed successfully

Public constructors

RenderResult

Added in 1.0.2
RenderResult(buffer: HardwareBuffer, mFence: SyncFenceCompat?, mStatus: Int)

Public properties

fence

Added in 1.0.2
val fenceSyncFenceCompat?

Optional fence that should be waited upon before consuming hardwareBuffer. On Android U and above, requests to render will return sooner and include this fence as a way to signal that the result of the render request is reflected in the contents of the buffer. This is done to reduce latency and provide opportunities for other systems to block on the fence on the behalf of the application. For example, SurfaceControlCompat.Transaction.setBuffer can be invoked with RenderResult.hardwareBuffer and RenderResult.fence respectively without the application having to explicitly block on this fence. For older Android versions, the rendering pipeline will automatically block on this fence and this value will return null.

hardwareBuffer

Added in 1.0.2
val hardwareBufferHardwareBuffer

HardwareBuffer that contains the result of the render request. Consumers should be sure to block on the SyncFenceCompat instance provided in fence if it is non-null before consuming the contents of this buffer. If fence returns null then this HardwareBuffer can be consumed immediately.

status

Added in 1.0.2
val statusInt

Status code for the RenderResult either SUCCESS if rendering completed or ERROR_UNKNOWN if the rendering could not be completed.