desktop/desktop.go

Functions

Functions

func Run

Run starts a desktop application with a per-boundary GPU texture render loop.

 

ADR-007 Phase 7: per-boundary GPU textures with damage-aware blit.

 

The rendering pipeline:

1. Frame() flushes signals, layouts, animations

2. PaintBoundaryLayers: re-record dirty+visible boundaries (Flutter flushPaint)

3. renderBoundaryTextures: per-boundary offscreen GPU textures (MSAA)

4. compositeTextures: blit all textures to surface (non-MSAA)

5. DrawOverlays + damage tracking + present

 

Run blocks until the window is closed.

func Run(gogpuApp *gogpu.App, uiApp *app.App) error {
	if gogpuApp == nil {
		return fmt.Errorf("desktop: gogpuApp must not be nil")
	}
	if uiApp == nil {
		return fmt.Errorf("desktop: uiApp must not be nil")
	}

	// Scene composition: full draw every frame, RepaintBoundary cache for efficiency.
	uiApp.Window().SetRenderMode(app.RenderModeHostManaged)

	rl := &renderLoop{
		gogpuApp:	gogpuApp,
		uiApp:		uiApp,
	}

	gogpuApp.OnDraw(rl.draw)

	gogpuApp.OnClose(func() {
		rl.releaseBoundaryTextures()
		gg.CloseAccelerator()
		if rl.canvas != nil {
			_ = rl.canvas.Close()
		}
	})

	return gogpuApp.Run()
}