GPUI.Display behaviour (gpui v0.2.0-rc.1)

Copy Markdown View Source

Display boundary for rendered GPUI session snapshots and native input events.

Displays own renderer-specific lifecycle and resources. Application sessions remain renderer-independent. Runtime and remote-client boundaries validate callback return values and convert raised or exited callbacks into structured :display_callback_failed errors.

Summary

Functions

Runs work asynchronously and replies to the original GenServer caller.

Waits until a display has rendered the requested window frame.

Waits for a frame generation newer than the supplied token.

Returns the current rendered-frame generation for a display window.

Drains pending native or test events from a display module.

Injects one event into a display's pending event queue.

Returns bounded optional presentation support advertised by a display.

Replies to a caller after the selected display frame completes.

Delegates a frame API call to a display and replies asynchronously.

Starts a display module and normalizes its startup result.

Synchronizes a renderer-independent snapshot through a display module.

Types

event()

@type event() :: map()

snapshot()

@type snapshot() :: GPUI.Snapshot.t()

Callbacks

await_frame(server, pos_integer, pos_integer)

(optional)
@callback await_frame(GenServer.server(), pos_integer(), pos_integer()) ::
  :ok | {:error, term()}

await_frame_after(server, pos_integer, non_neg_integer, pos_integer)

(optional)
@callback await_frame_after(
  GenServer.server(),
  pos_integer(),
  non_neg_integer(),
  pos_integer()
) :: :ok | {:error, term()}

drain_events(server)

@callback drain_events(GenServer.server()) :: {:ok, [event()]} | {:error, term()}

frame_token(server, pos_integer)

(optional)
@callback frame_token(GenServer.server(), pos_integer()) ::
  {:ok, non_neg_integer()} | {:error, term()}

inject_event(server, map)

@callback inject_event(GenServer.server(), map()) :: {:ok, term()} | {:error, term()}

presentation_capabilities(server)

(optional)
@callback presentation_capabilities(GenServer.server()) ::
  {:ok, [GPUI.Schema.Extension.Support.t()]} | {:error, term()}

start_link(keyword)

@callback start_link(keyword()) :: GenServer.on_start()

sync(server, snapshot)

@callback sync(GenServer.server(), snapshot()) :: :ok | {:error, term()}

Functions

async_reply(from, callback, normalize \\ &Function.identity/1)

@spec async_reply(GenServer.from(), (-> term()), (term() -> term())) :: :ok

Runs work asynchronously and replies to the original GenServer caller.

call_await_frame(server, window_id, timeout)

@spec call_await_frame(GenServer.server(), pos_integer(), pos_integer()) ::
  :ok | {:error, term()}

Waits until a display has rendered the requested window frame.

call_await_frame_after(server, window_id, generation, timeout)

@spec call_await_frame_after(
  GenServer.server(),
  pos_integer(),
  non_neg_integer(),
  pos_integer()
) :: :ok | {:error, term()}

Waits for a frame generation newer than the supplied token.

call_frame_token(server, window_id)

@spec call_frame_token(GenServer.server(), pos_integer()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Returns the current rendered-frame generation for a display window.

drain(display_module, display)

@spec drain(module(), GenServer.server()) :: {:ok, [event()]} | {:error, term()}

Drains pending native or test events from a display module.

inject(display_module, display, event)

@spec inject(module(), GenServer.server(), event()) ::
  {:ok, term()} | {:error, term()}

Injects one event into a display's pending event queue.

presentation_capabilities(display_module, display)

@spec presentation_capabilities(module(), GenServer.server()) ::
  {:ok, [GPUI.Schema.Extension.Support.t()]} | {:error, term()}

Returns bounded optional presentation support advertised by a display.

reply_after_frame(display_module, display, window_id, timeout, from)

@spec reply_after_frame(
  module(),
  GenServer.server(),
  pos_integer(),
  pos_integer(),
  GenServer.from()
) :: :ok

Replies to a caller after the selected display frame completes.

reply_from_display(display_module, display, callback, args, from)

@spec reply_from_display(
  module(),
  GenServer.server(),
  atom(),
  [term()],
  GenServer.from()
) :: :ok

Delegates a frame API call to a display and replies asynchronously.

start(display_module, opts)

@spec start(
  module(),
  keyword()
) :: {:ok, pid()} | {:error, term()}

Starts a display module and normalizes its startup result.

sync_snapshot(display_module, display, snapshot)

@spec sync_snapshot(module(), GenServer.server(), snapshot()) ::
  :ok | {:error, term()}

Synchronizes a renderer-independent snapshot through a display module.