compositor/compositor.go

Functions Structs

Functions

func Compose

Compose walks the layer tree rooted at root and builds a composed

scene.Scene by appending each PictureLayer's scene at its accumulated

offset. The composed scene is returned for rendering.

 

This is called every frame. The cost is O(layers), not O(draw_commands).

For 10 boundaries: 10 AppendWithTranslation calls. The actual scene

data is not re-recorded — only references are assembled.

 

Flutter equivalent: compositeFrame() → SceneBuilder.addRetained().

func (c *Compositor) Compose(root Layer) *scene.Scene {
	c.composed.Reset()
	c.composeLayer(root, 0, 0)
	return c.composed
}

func ComposedScene

ComposedScene returns the last composed scene without re-composing.

Returns nil if Compose has not been called.

func (c *Compositor) ComposedScene() *scene.Scene {
	return c.composed
}

func New

New creates a new Compositor.

func New() *Compositor {
	return &Compositor{
		composed: scene.NewScene(),
	}
}

Structs

type Compositor struct

Compositor assembles a layer tree into a composed scene.Scene by walking

layers and appending their content by REFERENCE (AppendWithTranslation),

not by copying the entire encoding into a flat scene.

 

NOT IN PRODUCTION PIPELINE: the production render loop (desktop.draw)

uses direct per-boundary GPU textures instead. Compositor is retained

for future use with animated transforms and opacity layers.

 

Flutter equivalent: SceneBuilder in compositeFrame().

type Compositor struct {
	composed *scene.Scene
}