diff --git a/core/src/primitive/color.rs b/core/src/primitive/color.rs index d94d516..458b807 100644 --- a/core/src/primitive/color.rs +++ b/core/src/primitive/color.rs @@ -10,7 +10,6 @@ pub struct Color { pub a: T, } -/// Defaults to visible, unstyled text for Parley's brush requirement. impl Default for Color { fn default() -> Self { Self::BLACK diff --git a/core/src/primitive/text.rs b/core/src/primitive/text.rs index cc0b61e..91076da 100644 --- a/core/src/primitive/text.rs +++ b/core/src/primitive/text.rs @@ -9,7 +9,6 @@ use swash::{ zeno::{Format, Vector}, }; -/// Shared font, layout, rasterization, and glyph-atlas state. pub struct TextData { pub font_cx: FontContext, pub layout_cx: LayoutContext, @@ -28,7 +27,6 @@ impl Default for TextData { } } -/// An owned font family that can be stored by a widget. #[derive(Clone, PartialEq)] pub enum Family { SansSerif, @@ -56,7 +54,6 @@ pub struct TextAttrs { pub line_height: f32, pub family: Family, pub wrap: bool, - /// Alignment within the text's region. pub align: RegionAlign, } @@ -80,7 +77,6 @@ impl Default for TextAttrs { pub struct TextBuffer { text: String, layout: Layout, - /// The inputs used to build the cached layout. shaped: Option<(TextAttrs, Option)>, } @@ -149,7 +145,6 @@ impl TextBuffer { } impl TextData { - /// Rasterizes uncached glyphs and places them relative to the text origin. pub fn place(&mut self, buffer: &TextBuffer, textures: &mut Textures) -> Vec { let mut placed = Vec::new(); for line in buffer.layout.lines() { @@ -229,7 +224,6 @@ fn hash_coords(coords: &[i16]) -> u64 { h } -/// Cached glyph placement for a laid-out string. #[derive(Clone)] pub struct RenderedText { pub glyphs: std::sync::Arc>, diff --git a/core/src/primitive/texture.rs b/core/src/primitive/texture.rs index 51f9074..95c210e 100644 --- a/core/src/primitive/texture.rs +++ b/core/src/primitive/texture.rs @@ -29,7 +29,6 @@ pub struct Textures { pub enum TextureUpdate<'a> { Push(&'a DynamicImage), Set(u32, &'a DynamicImage), - /// Overwrite one rectangle without uploading the entire texture. Patch(u32, PatchRect, &'a DynamicImage), Free(u32), PushFree, @@ -92,7 +91,6 @@ impl Textures { } } - /// The stored image for a handle, to be written into before `patch`. pub fn image_mut(&mut self, handle: &TextureHandle) -> &mut DynamicImage { self.images[handle.inner.view_idx as usize] .as_mut() diff --git a/core/src/render/atlas.rs b/core/src/render/atlas.rs index 703114b..3996d00 100644 --- a/core/src/render/atlas.rs +++ b/core/src/render/atlas.rs @@ -1,5 +1,3 @@ -//! Packs reusable rasterized glyphs into shared texture pages. - use crate::{ PatchRect, TextureHandle, Textures, util::{HashMap, Vec2}, @@ -7,14 +5,12 @@ use crate::{ use image::RgbaImage; use swash::scale::image::{Content, Image}; -/// A 1024-pixel RGBA8 page occupies 4 MiB. const PAGE: u32 = 1024; /// Transparent margin kept around every glyph, so that sampling one cannot /// pick up its neighbour along a shared edge. const PAD: u32 = 1; -/// Includes every input that can change the rasterized pixels. #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct GlyphKey { pub font: u64, @@ -45,7 +41,6 @@ pub struct GlyphEntry { struct Page { handle: TextureHandle, - /// Shelf packing is effective because glyphs at one size have similar heights. x: u32, y: u32, shelf_height: u32, @@ -64,7 +59,6 @@ impl GlyphAtlas { self.entries.get(key).copied() } - /// Returns `None` when a glyph has no pixels or cannot fit on a page. pub fn insert( &mut self, key: GlyphKey, @@ -78,7 +72,6 @@ impl GlyphAtlas { return None; } if w + PAD * 2 > PAGE || h + PAD * 2 > PAGE { - // Never silently crop an oversized glyph. self.entries.insert(key, None); return None; } @@ -142,7 +135,6 @@ impl GlyphAtlas { (self.pages.len() - 1, PAD, PAD) } - /// Record that a glyph has no pixels, so it is not re-rasterised. pub fn insert_empty(&mut self, key: GlyphKey) { self.entries.insert(key, None); } @@ -157,7 +149,6 @@ impl GlyphAtlas { } fn fits(page: &Page, need_w: u32, need_h: u32) -> bool { - // On the current shelf, or on a new one above it. (page.x + need_w <= PAGE && page.y + need_h <= PAGE) || (need_w + PAD <= PAGE && page.y + page.shelf_height + need_h <= PAGE) } @@ -202,7 +193,6 @@ fn write_glyph(page: &mut RgbaImage, image: &Image, x: u32, y: u32) { } } -/// Where a glyph goes on screen, in pixels relative to the text's origin. #[derive(Clone, Copy)] pub struct PlacedGlyph { pub entry: GlyphEntry, diff --git a/core/src/render/primitive.rs b/core/src/render/primitive.rs index 1d91ce2..28f6b3d 100644 --- a/core/src/render/primitive.rs +++ b/core/src/render/primitive.rs @@ -231,7 +231,6 @@ pub struct TexturePrimitive { pub sampler_idx: u32, } -/// An atlas subrectangle, tinted for masks or unchanged for color glyphs. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct GlyphPrimitive { diff --git a/core/src/ui/painter.rs b/core/src/ui/painter.rs index c120ce6..3e17ead 100644 --- a/core/src/ui/painter.rs +++ b/core/src/ui/painter.rs @@ -100,7 +100,6 @@ impl<'a> Painter<'a> { ui.text.render(buffer, attrs, width, &mut ui.textures) } - /// Draws one atlas-sampling quad per glyph. pub fn glyphs(&mut self, text: &RenderedText, origin: UiRegion) { let flags_for = |is_color| { if is_color { diff --git a/src/widget/text/edit.rs b/src/widget/text/edit.rs index e50fb23..faec85d 100644 --- a/src/widget/text/edit.rs +++ b/src/widget/text/edit.rs @@ -104,7 +104,6 @@ pub struct TextEditCtx<'a> { } impl<'a> TextEditCtx<'a> { - /// Returns a layout synchronized with the current text. fn layout(&mut self) -> &Layout { let attrs = self.text.view.attrs.clone(); let width = self.text.view.wrap_width(); @@ -112,7 +111,6 @@ impl<'a> TextEditCtx<'a> { self.text.view.buf.layout() } - /// Keep the selection valid after the text underneath it changed. fn refresh(&mut self) { if let Some(sel) = self.text.selection { let layout = self.layout(); @@ -180,7 +178,6 @@ impl<'a> TextEditCtx<'a> { self.set_caret(at + text.len()); } - /// True when there was a span to remove. pub fn clear_span(&mut self) -> bool { let Some(sel) = self.text.selection else { return false; diff --git a/src/widget/text/mod.rs b/src/widget/text/mod.rs index dbe5e7b..c72c53e 100644 --- a/src/widget/text/mod.rs +++ b/src/widget/text/mod.rs @@ -27,7 +27,6 @@ impl TextView { self.buf.is_empty() } - /// The width used by the cached layout. pub fn wrap_width(&self) -> Option { self.width }