render

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package render prepares ordered physical-pixel primitives for Vulkan submission. It does not own the display list or its borrowed font faces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame struct {
	Quads   []Quad
	Uploads []text.Upload
}

type ListBuffer

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

ListBuffer is a single-owner scratch area for repeated ListBatches calls. The slices it returns alias its storage: they are valid only until the next List or Release call, and must not be retained, shared across goroutines, or used while another List may run. This is safe for consumers that copy the data synchronously (Target.submit uploads instances into GPU memory and resolve copies the batches before recording returns); anything that keeps the slices past that point must use ListBatches instead. Retained frames hold only render.Frame, never these slices, so a blocked frame is re-listed on retry. Stats.Skipped shares the same lifetime. The zero value is ready to use.

func (*ListBuffer) List

func (b *ListBuffer) List(frame Frame) ([]vkdevice.Instance, []vkdevice.Batch, ListStats)

List is ListBatches reusing this buffer's storage where capacity allows.

func (*ListBuffer) Release

func (b *ListBuffer) Release()

Release drops borrowed image references from the previous result. Call it once the result has been consumed so an idle buffer does not pin images.

type ListStats

type ListStats struct {
	Drawn   int
	Skipped map[string]int
}

ListStats reports every skipped prepared quad by operation.

func ListBatches

func ListBatches(frame Frame) ([]vkdevice.Instance, []vkdevice.Batch, ListStats)

ListBatches groups consecutive atlas draws and isolates each image draw. First indexes the returned instances, retaining exact painter's order. The returned slices and map are freshly allocated and owned by the caller.

func ListInstances

func ListInstances(frame Frame) ([]vkdevice.Instance, ListStats)

ListInstances converts prepared physical quads to straight-sRGB GPU inputs. Unknown operations are counted, not silently drawn as rectangles. Uploads remain the caller's responsibility.

type Preparer

type Preparer struct {
	Atlas *text.Atlas
	// contains filtered or unexported fields
}

Preparer owns the glyph atlas and the obligation to deliver its changes to the GPU mirror. Prepare hands the caller every change not yet known to be submitted; Submitted is the only acknowledgement. A frame that is retried, abandoned, superseded or never reached submission therefore never loses atlas changes: the next Prepare resends whole pages (placements are kept).

func NewPreparer

func NewPreparer(size, pages int) (*Preparer, error)

NewPreparer bounds the grayscale glyph atlas. Call Prepare synchronously with layout; the atlas and shaped faces are not safe for concurrent use.

func (*Preparer) Prepare

func (p *Preparer) Prepare(commands []layout.Command, scale float64, width, height int) (Frame, error)

Prepare converts logical rectangles once, using layout.Physical as the sole logical-to-physical edge-rounding boundary. A clip-push intersects its parent clip; rounded clips intentionally use only their axis-aligned bounds in V1. Clip-pop without a push and unknown operations are rejected, not dropped. Image commands without a source are rejected. Failed frames do not produce partial output.

func (*Preparer) PrepareInto added in v0.6.1

func (p *Preparer) PrepareInto(quads []Quad, commands []layout.Command, scale float64, width, height int) (Frame, error)

PrepareInto is Prepare reusing quads' backing array for the returned frame's Quads. The frame aliases quads, so it is valid only until quads is reused: callers that keep frames must use Prepare. Pass the last frame's Quads unchanged: its length tells how much of a past peak buffer is still needed.

func (*Preparer) Submitted

func (p *Preparer) Submitted(uploads []text.Upload)

Submitted acknowledges that uploads, as returned in the most recent Prepare's Frame.Uploads, were recorded in a successfully submitted GPU submission. Any other slice (an older, superseded frame or foreign data) is ignored and the latest frame's uploads stay owed. Call it on the Prepare owner's loop.

type Quad

type Quad struct {
	Op     string
	Rect   layout.Rect
	Clip   layout.Rect
	Color  css.Color
	Radii  [4]float64
	Widths layout.Edges
	Colors css.ColorSides
	Glyph  text.Placement
	Image  image.Image
	// Shape is the original box when the draw bounds extend past it.
	Shape layout.Rect
	// Shadow holds physical offset, blur and spread. Inset is carried separately.
	Shadow [4]float64
	Inset  bool
}

Quad is a physical-pixel rectangle with a physical clip. Color is straight sRGB; conversion to premultiplied linear color belongs at the GPU boundary. Glyphs refer to an atlas placement valid only for this prepared frame.

Jump to

Keyboard shortcuts

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