Documentation
¶
Overview ¶
Package shmwindow is the renderer of a Linux window without a GPU (SPEC §9.6): the software renderer (package soft) draws the frame into memory that a gpu.PixelTarget gives, and the window shows it, through wl_shm on Wayland. It is to Linux what gdiwindow is to Windows, nativewindow to Android and canvas2d to the web, with one difference that matters on a machine whose CPU is the rasterizer: it draws only what changed.
A surface keeps the pixels of its window across frames, as offscreen.Surface does. Each frame clears and redraws only the rectangles that the damage tracker finds (SPEC §9.1, "Damage"), and then copies into the buffer the target gave the rectangles that buffer is missing: what this frame changed, and what the frames since the buffer was last shown changed (its age, as with EGL_EXT_buffer_age). The window is told only what this frame changed.
The sequence of calls is plain Go over a gpu.PixelTarget, which a test replaces with a fake; the memory, the protocol and the release of buffers are the platform backend's.
Flutter: no counterpart (Flutter's Linux embedder has a software compositor that copies the whole frame, shell/platform/linux/fl_compositor_software.cc)
Index ¶
- type Options
- type Renderer
- func (r *Renderer) Attach(h gpu.SurfaceHandle) (gpu.Surface, error)
- func (r *Renderer) Close() error
- func (r *Renderer) Invalidate(s gpu.Surface)
- func (r *Renderer) Render(s gpu.Surface, scene *ui.Scene, size ui.Size, dpr float32) error
- func (r *Renderer) RenderCapture(s gpu.Surface, scene *ui.Scene, size ui.Size, _ float32, capture bool) (*image.RGBA, error)
- func (r *Renderer) Snapshot(scene *ui.Scene, size ui.Size) (*image.RGBA, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Background is what shows where the scene draws nothing. The window is opaque, so only the
// color's red, green and blue count; the zero value is black.
Background ui.Color
}
Options are the optional parameters of NewRenderer.
Flutter: no counterpart
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is a gpu.Renderer that draws with soft into the buffers of a gpu.PixelTarget.
Flutter: shell/platform/linux/fl_compositor_software.cc FlCompositorSoftware
func NewRenderer ¶
func NewRenderer(targets func(gpu.SurfaceHandle) (gpu.PixelTarget, bool), opts ...Options) *Renderer
NewRenderer makes a renderer. targets gives the gpu.PixelTarget of the window that a surface handle names, and false when there is none. More than one options value panics with MultipleOptions.
Flutter: no counterpart
func (*Renderer) Attach ¶
Attach starts drawing into the window that the handle names, which must be of kind gpu.SurfaceKindWayland or gpu.SurfaceKindX11 and have a target. It fails with RendererClosed after Close, with SurfaceKindUnsupported for another kind and with PixelTargetMissing for a window with no target.
Flutter: no counterpart
func (*Renderer) Close ¶
Close stops the renderer; its surfaces are destroyed by their owners. It is safe to call twice.
Flutter: no counterpart
func (*Renderer) Invalidate ¶
Invalidate says that the window lost its content, so that the next frame is drawn and presented whole. A surface that is not this renderer's is ignored.
Flutter: no counterpart
func (*Renderer) Render ¶
Render draws the scene into the surface at the size in device pixels and presents it. A nil scene draws the background only. The scene's coordinates are already in device pixels, so dpr is not used.
Flutter: no counterpart
func (*Renderer) RenderCapture ¶
func (r *Renderer) RenderCapture(s gpu.Surface, scene *ui.Scene, size ui.Size, _ float32, capture bool) (*image.RGBA, error)
RenderCapture is Render that also returns, when capture is set, the frame it presented, top row first. The image belongs to the caller.
Flutter: no counterpart