Raxol.Terminal.Rendering.Backend behaviour (Raxol v2.0.1)
View SourceBehaviour definition for terminal rendering backends.
This module defines the interface that all rendering backends must implement, including GPU-accelerated backends (OpenGL, Metal, Vulkan) and software rendering.
Summary
Callbacks
Checks if the backend is available on the current system.
Gets the backend's capabilities and supported features.
Creates a rendering surface with the specified options.
Destroys a rendering surface and releases its resources.
Disables a visual effect.
Enables a visual effect on the rendering backend.
Gets rendering performance statistics.
Initializes the rendering backend with the given configuration.
Renders terminal content to the specified surface.
Updates the backend configuration.
Types
@type effect_type() :: :blur | :glow | :scanlines | :chromatic_aberration | :vignette
@type render_opts() :: [ viewport: {integer(), integer(), pos_integer(), pos_integer()}, scale: float(), vsync: boolean(), effects: list() ]
@type stats() :: %{ fps: float(), frame_time: float(), draw_calls: non_neg_integer(), vertices: non_neg_integer(), memory_usage: non_neg_integer() }
@type surface() :: %{ id: String.t(), width: pos_integer(), height: pos_integer(), format: atom(), backend: atom() }
@type terminal_buffer() :: %{ lines: list(), width: pos_integer(), height: pos_integer(), cursor: map(), colors: map() }
Callbacks
@callback available?() :: boolean()
Checks if the backend is available on the current system.
@callback capabilities() :: %{ max_texture_size: pos_integer(), supports_shaders: boolean(), supports_effects: [effect_type()], hardware_accelerated: boolean() }
Gets the backend's capabilities and supported features.
@callback create_surface(state :: term(), opts :: keyword()) :: {:ok, surface(), new_state :: term()} | {:error, reason :: term()}
Creates a rendering surface with the specified options.
@callback destroy_surface(state :: term(), surface :: surface()) :: {:ok, new_state :: term()} | {:error, reason :: term()}
Destroys a rendering surface and releases its resources.
@callback disable_effect(state :: term(), effect :: effect_type()) :: {:ok, new_state :: term()} | {:error, reason :: term()}
Disables a visual effect.
@callback enable_effect( state :: term(), effect :: effect_type(), params :: keyword() ) :: {:ok, new_state :: term()} | {:error, reason :: term()}
Enables a visual effect on the rendering backend.
Gets rendering performance statistics.
Initializes the rendering backend with the given configuration.
@callback render( state :: term(), surface :: surface(), buffer :: terminal_buffer(), opts :: render_opts() ) :: {:ok, new_state :: term()} | {:error, reason :: term()}
Renders terminal content to the specified surface.
@callback update_config(state :: term(), config :: map()) :: {:ok, new_state :: term()} | {:error, reason :: term()}
Updates the backend configuration.