pixelpool

package
v1.16.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pixelpool is the buffers of one window that a CPU renderer draws into: the part of the Wayland and X11 backends that hands a buffer out only when the display server no longer reads it, and says how old its content is (SPEC §9.6; steps 32.1 and 32.2).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	// Pixels is the memory of the buffer.
	Pixels() []byte
	// Free gives the buffer back; it is safe to call twice.
	Free()
}

Buffer is the memory of one buffer of a pool: a wl_shm buffer on Wayland, a shared-memory image on X11.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is the buffers of one window that a CPU renderer draws into (SPEC §9.6): one is never handed out while the server reads it, and each remembers which frame it holds, so that the renderer can redraw only what changed since (buffer age). Only the UI thread uses it.

func New

func New(make func(width, height int, release func()) (Buffer, error)) *Pool

New makes a pool whose buffers come from make.

func (*Pool) Acquire

func (p *Pool) Acquire(width, height int) (*Slot, int, error)

Acquire returns a buffer of the size that the server does not read, and its age: 0 for one that holds no frame, n for the frame of n presentations ago. Of the idle buffers it takes the one that was written last, which has the smallest age. When every buffer is busy a new one is made, up to maxBuffers; it fails with ShmPoolExhausted after that, and with the error of make when the memory cannot be made.

func (*Pool) Close

func (p *Pool) Close()

Close frees every buffer. A buffer that the server still holds is freed too: the server has its own mapping of the memory.

func (*Pool) Present

func (p *Pool) Present(s *Slot)

Present marks the slot as shown by the next presentation and held by the server.

type Slot

type Slot struct {
	// Buf is the buffer.
	Buf Buffer
	// Width and Height are its size in pixels.
	Width, Height int
	// contains filtered or unexported fields
}

Slot is a buffer of a Pool and what is known of it.

func (*Slot) Released

func (s *Slot) Released()

Released is the server's word that it no longer reads the buffer (wl_buffer.release, the completion event of MIT-SHM). An idle buffer of a size that is no longer asked for, or that is more than the pool keeps, is freed; the pool being closed frees all.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL