Skip to main content

gpu_canvas

Function gpu_canvas 

Source
pub fn gpu_canvas(
    content: impl FnOnce(&mut GpuCanvasContext<'_, '_>) + 'static,
) -> GpuCanvas
Expand description

Build a GPU canvas, an ordinary box whose content a paint-time callback supplies.

The callback receives a GpuCanvasContext, the only place raw GPU import is reachable: call GpuCanvasContext::paint_surface to composite a surface produced outside GPUI, or GpuCanvasContext::paint_texture for a texture made on the window renderer’s own device. The callback is FnOnce and consumed once, matching crate::Canvas: the element tree is rebuilt every frame, so it is used exactly once. Paint time is when the window’s renderer — and so its device — is guaranteed to exist.