Table of Contents

Class BaseLayerRenderer

Namespace
Gloam.Core.Interfaces.Base
Assembly
Gloam.Core.dll

Base implementation for layer renderers providing common functionality and patterns. Concrete implementations only need to override RenderLayerAsync with their specific rendering logic.

public abstract class BaseLayerRenderer : ILayerRenderer
Inheritance
BaseLayerRenderer
Implements
Derived
Inherited Members

Constructors

BaseLayerRenderer()

protected BaseLayerRenderer()

Properties

IsVisible

Gets or sets whether this layer is visible and should be rendered

public bool IsVisible { get; set; }

Property Value

bool

Name

Gets the name of this layer renderer for debugging and identification purposes.

public abstract string Name { get; }

Property Value

string

Priority

Gets the priority of this layer renderer. Lower values render first.

public abstract int Priority { get; }

Property Value

int

Methods

GetFramesPerSecond(RenderLayerContext)

Helper method to get the frames per second from the context.

protected static float GetFramesPerSecond(RenderLayerContext context)

Parameters

context RenderLayerContext

The rendering context

Returns

float

The current frames per second

IsFirstFrame(RenderLayerContext)

Helper method to check if this is the first frame being rendered.

protected static bool IsFirstFrame(RenderLayerContext context)

Parameters

context RenderLayerContext

The rendering context

Returns

bool

True if this is the first frame, false otherwise

OnPostRenderAsync(RenderLayerContext, CancellationToken)

Called after the main rendering logic. Override to perform cleanup operations. Default implementation does nothing.

protected virtual ValueTask OnPostRenderAsync(RenderLayerContext context, CancellationToken ct = default)

Parameters

context RenderLayerContext

The rendering context

ct CancellationToken

Cancellation token

Returns

ValueTask

OnPreRenderAsync(RenderLayerContext, CancellationToken)

Called before the main rendering logic. Override to perform setup operations. Default implementation does nothing.

protected virtual ValueTask OnPreRenderAsync(RenderLayerContext context, CancellationToken ct = default)

Parameters

context RenderLayerContext

The rendering context

ct CancellationToken

Cancellation token

Returns

ValueTask

RenderAsync(RenderLayerContext, CancellationToken)

Renders the layer with the provided context. This is the main method that concrete implementations must override.

public ValueTask RenderAsync(RenderLayerContext context, CancellationToken ct = default)

Parameters

context RenderLayerContext

The rendering context containing renderer, input, and frame information

ct CancellationToken

Cancellation token to cancel the rendering operation

Returns

ValueTask

RenderLayerAsync(RenderLayerContext, CancellationToken)

Override this method to implement the specific rendering logic for this layer.

protected abstract ValueTask RenderLayerAsync(RenderLayerContext context, CancellationToken ct = default)

Parameters

context RenderLayerContext

The rendering context containing renderer, input, and frame information

ct CancellationToken

Cancellation token to cancel the rendering operation

Returns

ValueTask