renderer.go RawHistoryFolder
1//go:build linux
2
3package nefergui
4
5import "github.com/bnema/nefergui/internal/ui"
6
7// Renderer renders views into DMA-BUF buffers for a Wayland client the
8// application owns. It imports no Wayland library, starts no goroutine and is
9// used from one owner goroutine. Typical loop: forward Wayland events with
10// Input and Resize, call Render when a redraw is needed, import and present
11// the Output buffer, and call Released when its ReleaseFD becomes readable.
12//
13// Pending() reports a built frame waiting for the GPU rather than the
14// compositor; arm a short timer (about 2 ms) and call Render again.
15//
16// Render is generic over the model type, so it is a generic method:
17//
18// ok, err := r.Render(&out, &model, view)
19type Renderer = ui.Renderer
20
21// RendererConfig configures NewRenderer. MainDevice and Formats come from the
22// compositor's linux-dmabuf feedback.
23type RendererConfig = ui.RendererConfig
24
25// Format is a DRM format and modifier the compositor accepts.
26type Format = ui.Format
27
28// Input is one platform input event; Text is valid only during Renderer.Input.
29type Input = ui.Input
30
31// Output describes one frame to present, in physical pixels. All file
32// descriptors stay owned by the Renderer: duplicate them before handing them to
33// a transport that consumes descriptors. Slices are valid until the next Render.
34type Output = ui.Output
35
36// Plane, Timeline and Retired are parts of Output. A Timeline FD is valid only
37// when Output.NewTimelines is set. The client must stop watching and destroy
38// each Retired buffer before the next Render.
39type (
40 Plane = ui.Plane
41 Timeline = ui.Timeline
42 Retired = ui.Retired
43)
44
45// Clipboard is an optional asynchronous clipboard; IME an optional input method.
46type (
47 Clipboard = ui.Clipboard
48 IME = ui.IME
49)
50
51// Cursor is the pointer shape the surface wants.
52type Cursor = ui.Cursor
53
54const (
55 CursorDefault = ui.CursorDefault
56 CursorPointer = ui.CursorPointer
57 CursorText = ui.CursorText
58 CursorNotAllowed = ui.CursorNotAllowed
59)
60
61// NewRenderer opens the GPU named by cfg.MainDevice and loads fonts and
62// styles. It allocates no images.
63func NewRenderer(cfg RendererConfig) (*Renderer, error) { return ui.NewRenderer(cfg) }