CanvasBufferedRenderer.RenderResult


public final 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

static final int

Render request failed with an unknown error

static final int

Render request was completed successfully

Public constructors

RenderResult(
    @NonNull HardwareBuffer buffer,
    SyncFenceCompat mFence,
    int mStatus
)

Public methods

final SyncFenceCompat

Optional fence that should be waited upon before consuming hardwareBuffer.

final @NonNull HardwareBuffer

HardwareBuffer that contains the result of the render request.

final int

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

Constants

ERROR_UNKNOWN

public static final int ERROR_UNKNOWN = 1

Render request failed with an unknown error

SUCCESS

public static final int SUCCESS = 0

Render request was completed successfully

Public constructors

RenderResult

Added in 1.0.2
public RenderResult(
    @NonNull HardwareBuffer buffer,
    SyncFenceCompat mFence,
    int mStatus
)

Public methods

getFence

Added in 1.0.2
public final SyncFenceCompat getFence()

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.

getHardwareBuffer

Added in 1.0.2
public final @NonNull HardwareBuffer getHardwareBuffer()

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.

getStatus

Added in 1.0.2
public final int getStatus()

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