pub struct TextLayer { /* private fields */ }Expand description
Owns glyphon’s font/atlas/renderer state plus a reusable buffer pool, and the
per-frame queue of runs and panels. One instance per super::Renderer, and
one per secondary surface.
Implementations§
Source§impl TextLayer
impl TextLayer
Sourcepub fn new(device: &Device, queue: &Queue, format: TextureFormat) -> Self
pub fn new(device: &Device, queue: &Queue, format: TextureFormat) -> Self
Build the text layer on device, targeting format (the surface format).
Loads the system font set once here, not per frame.
Sourcepub fn measure(&mut self, text: &str, size: f32) -> f32
pub fn measure(&mut self, text: &str, size: f32) -> f32
The laid-out width of text at size device pixels, as this layer
would draw it.
Sourcepub fn queue_panels(&mut self, panels: &[Panel])
pub fn queue_panels(&mut self, panels: &[Panel])
Replace this frame’s queued panels with panels.
Sourcepub fn push_panel(&mut self, panel: Panel)
pub fn push_panel(&mut self, panel: Panel)
Append one panel to this frame’s queue — the core’s own furniture, for
the reason push exists.
Sourcepub fn queue(&mut self, runs: &[TextRun<'_>])
pub fn queue(&mut self, runs: &[TextRun<'_>])
Replace this frame’s queued runs with owning copies of runs.
Sourcepub fn push(&mut self, run: TextRun<'_>)
pub fn push(&mut self, run: TextRun<'_>)
Append one run to this frame’s queue, leaving what is already there
alone. The core’s own furniture — the now-playing banner (ADR-0110) —
goes in through this rather than queue, which replaces:
a frontend that queues nothing this frame must not erase it.
Sourcepub fn prepare(
&mut self,
device: &Device,
queue: &Queue,
width: u32,
height: u32,
) -> bool
pub fn prepare( &mut self, device: &Device, queue: &Queue, width: u32, height: u32, ) -> bool
Write the queued panels, shape the queued runs and upload their glyphs to the atlas. Returns whether there is anything to draw; an atlas-full or shaping failure degrades to “no text drawn” rather than panicking on the render path.
Sourcepub fn render_panels(&self, pass: &mut RenderPass<'_>)
pub fn render_panels(&self, pass: &mut RenderPass<'_>)
Draw the prepared panels into pass, as one draw. Separate from
render so a caller can draw between the two — the
shell’s picture sits on its panel and under its caption. Call this first.
Sourcepub fn has_panels(&self) -> bool
pub fn has_panels(&self) -> bool
Whether the last prepare left panels to draw.
Sourcepub fn render<'pass>(&'pass self, pass: &mut RenderPass<'pass>)
pub fn render<'pass>(&'pass self, pass: &mut RenderPass<'pass>)
Draw the prepared runs into pass (a load pass over the scene). No-op if
prepare produced no text. Panels are render_panels’.