GLRenderer.RenderTarget

public final class GLRenderer.RenderTarget


Handle to a android.view.Surface that is given to GLRenderer to handle rendering.

Summary

Public methods

final void
detach(
    boolean cancelPending,
    Function1<@NonNull GLRenderer.RenderTargetUnit> onDetachComplete
)

Removes the corresponding RenderTarget from management of the GLThread.

final boolean

Determines if the current RenderTarget is attached to GLRenderer.

final void
requestRender(
    @WorkerThread Function1<@NonNull GLRenderer.RenderTargetUnit> onRenderComplete
)

Request that this RenderTarget should have its contents redrawn.

final void
resize(
    int width,
    int height,
    @WorkerThread Function1<@NonNull GLRenderer.RenderTargetUnit> onResizeComplete
)

Resize the RenderTarget to the specified width and height.

Public methods

detach

Added in 1.0.0-beta01
public final void detach(
    boolean cancelPending,
    Function1<@NonNull GLRenderer.RenderTargetUnit> onDetachComplete
)

Removes the corresponding RenderTarget from management of the GLThread. This destroys the EGLSurface associated with this surface and subsequent requests to render into the surface with the provided token are ignored.

If the cancelPending flag is set to true, any queued request to render that has not started yet is cancelled. However, if this is invoked in the middle of the frame being rendered, it will continue to process the current frame.

Additionally if this flag is false, all pending requests to render will be processed before the RenderTarget is detached.

This is a convenience method around GLRenderer.detach

Note the detach operation will only occur if the RenderTarget is attached, that is isAttached returns true. If the RenderTarget is detached or the GLRenderer that created this RenderTarget is stopped, this is a no-op.

isAttached

Added in 1.0.0-beta01
public final boolean isAttached()

Determines if the current RenderTarget is attached to GLRenderer. This is true until detach has been called. If the RenderTarget is no longer in an attached state (i.e. this returns false). Subsequent calls to requestRender will be ignored.

requestRender

Added in 1.0.0-beta01
public final void requestRender(
    @WorkerThread Function1<@NonNull GLRenderer.RenderTargetUnit> onRenderComplete
)

Request that this RenderTarget should have its contents redrawn. This consumes an optional callback that is invoked on the backing thread when the rendering is completed.

Note the render operation will only occur if the RenderTarget is attached, that is isAttached returns true. If the RenderTarget is detached or the GLRenderer that created this RenderTarget is stopped, this is a no-op.

Parameters
@WorkerThread Function1<@NonNull GLRenderer.RenderTargetUnit> onRenderComplete

Optional callback called on the backing thread when rendering is finished

resize

Added in 1.0.0-beta01
public final void resize(
    int width,
    int height,
    @WorkerThread Function1<@NonNull GLRenderer.RenderTargetUnit> onResizeComplete
)

Resize the RenderTarget to the specified width and height. This will destroy the EGLSurface created by RenderCallback.onSurfaceCreated and invoke it again with the updated dimensions. An optional callback is invoked on the backing thread after the resize operation is complete

Note the resize operation will only occur if the RenderTarget is attached, that is isAttached returns true. If the RenderTarget is detached or the GLRenderer that created this RenderTarget is stopped, this is a no-op.

Parameters
int width

New target width to resize the RenderTarget

int height

New target height to resize the RenderTarget

@WorkerThread Function1<@NonNull GLRenderer.RenderTargetUnit> onResizeComplete

Optional callback invoked after the resize is complete