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)
19//
20// Measure sizes a view before a surface exists (owner goroutine, not for every
21// frame); it changes no Renderer state:
22//
23// width, height, err := r.Measure(&model, view, maxWidth)
24type Renderer = ui.Renderer
25
26// RendererConfig configures NewRenderer. MainDevice and Formats come from the
27// compositor's linux-dmabuf feedback.
28type RendererConfig = ui.RendererConfig
29
30// Format is a DRM format and modifier the compositor accepts.
31type Format = ui.Format
32
33// Input is one platform input event; Text is valid only during Renderer.Input.
34type Input = ui.Input
35
36// Output describes one frame to present, in physical pixels. All file
37// descriptors stay owned by the Renderer: duplicate them before handing them to
38// a transport that consumes descriptors. Slices are valid until the next Render.
39type Output = ui.Output
40
41// Plane, Timeline and Retired are parts of Output. A Timeline FD is valid only
42// when Output.NewTimelines is set. The client must stop watching and destroy
43// each Retired buffer before the next Render.
44type (
45 Plane = ui.Plane
46 Timeline = ui.Timeline
47 Retired = ui.Retired
48)
49
50// Clipboard is an optional asynchronous clipboard; IME an optional input method.
51type (
52 Clipboard = ui.Clipboard
53 IME = ui.IME
54)
55
56// Cursor is the pointer shape the surface wants.
57type Cursor = ui.Cursor
58
59const (
60 CursorDefault = ui.CursorDefault
61 CursorPointer = ui.CursorPointer
62 CursorText = ui.CursorText
63 CursorNotAllowed = ui.CursorNotAllowed
64)
65
66// NewRenderer opens the GPU named by cfg.MainDevice and loads fonts and
67// styles. It allocates no images.
68func NewRenderer(cfg RendererConfig) (*Renderer, error) { return ui.NewRenderer(cfg) }