Prune commentary and stale Rust port notes

This commit is contained in:
iris committed 2026-09-10 00:44:13 -04:00
1 parent 3ae034a47b
commit 1e6d3b1edd
84 files changed
+334 -5648

No files matched your search

-41
View File
@@ -16,7 +16,6 @@ pub struct Text {
pub struct TextView {
pub attrs: MutDetect<TextAttrs>,
pub buf: MutDetect<TextBuffer>,
// cache
tex: Option<RenderedText>,
width: Option<f32>,
pub hint: Option<StrongWidget>,
@@ -27,14 +26,10 @@ impl TextView {
self.buf.is_empty()
}
/// The width the text was last laid out against, so an editor asking for
/// the layout gets the same wrapping the last draw used.
pub fn wrap_width(&self) -> Option<f32> {
self.width
}
}
impl TextView {
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<StrongWidget>) -> Self {
Self {
attrs: attrs.into(),
@@ -45,8 +40,6 @@ impl TextView {
}
}
/// region where the text should be draw
/// does not include extra height or width from weird unicode
pub fn region(&self) -> UiRegion {
self.tex()
.map(|t| t.size)
@@ -60,13 +53,6 @@ impl TextView {
} else {
None
};
// The atlas generation is part of the cache key, not a separate
// invalidation path: a `RenderedText` is only meaningful against the
// atlas its glyphs were placed in, and a renderer rebuild clears
// that atlas out from under every widget at once
// (`GlyphAtlas::clear`). Without this the text drawn before the
// rebuild is re-emitted with the old atlas's coordinates and comes
// back as fragments of whatever now occupies them.
let generation = painter.atlas_generation();
if width == self.width
&& let Some(tex) = &self.tex
@@ -78,11 +64,6 @@ impl TextView {
}
self.width = width;
let tex = painter.render_text(&mut self.buf, &self.attrs, width);
// Gated on `iris::diagnostics::trace_enabled` since 2026-09-07
// (docs/RUST.md's review, D1): one line per text *shape* (a cache
// miss), unconditional, is many per frame while rows compose --
// see `android::view::IrisViewPeer::render`'s own doc for the same
// finding on its two per-frame lines.
if crate::diagnostics::trace_enabled() {
log::debug!(
target: "iris::frame",
@@ -100,12 +81,6 @@ impl TextView {
pub fn tex(&self) -> Option<&RenderedText> {
self.tex.as_ref()
}
/// Draws within `painter.region()` and reports the size used -- what
/// `desired_width`/`desired_height` used to answer separately, folded
/// into the one draw (LAYOUT.md section 4): the shaped layout this
/// reads is already memoized by width in `render`, so a second call at
/// the same width (a redraw with nothing else changed) is a cache hit,
/// not a re-shape.
pub fn draw(&mut self, painter: &mut Painter) -> Size {
let tex = self.render(painter);
if self.is_blank()
@@ -185,19 +160,6 @@ mod tests {
use crate::layout_tests::TestRsc;
use crate::prelude::*;
/// A renderer rebuild empties the glyph atlas under every widget at
/// once (`iris_core::GlyphAtlas::clear`, called from
/// `IrisViewPeer::surface_changed`'s new-renderer branch). Anything
/// still holding a `RenderedText` from before then owns UV rectangles
/// into a texture that no longer exists -- what Iris photographed on
/// 2026-09-06 as every pre-resume glyph coming back as fragments while
/// the text drawn after the resume was perfect.
///
/// The check is the atlas repopulating: `TextView::render`'s cache
/// short-circuits before `TextData::place`, so without the generation
/// in its key the second frame rasterises nothing and the atlas stays
/// empty. (`Painter::glyphs`'s `debug_assert!` fires here too, which is
/// the same finding from the submission side.)
#[test]
fn clearing_the_atlas_re_renders_cached_text_instead_of_reusing_it() {
let mut rsc = TestRsc {
@@ -215,9 +177,6 @@ mod tests {
let rasterised = rsc.ui.text.atlas.glyph_count();
assert!(rasterised > 0, "the first frame rasterised no glyphs");
// Exactly what the new-renderer branch does, in order: empty the
// atlas, then redraw everything (`resize` is what marks the tree
// for a full redraw, and a real `surface_changed` always calls it).
rsc.ui.text.atlas.clear();
assert_eq!(rsc.ui.text.atlas.glyph_count(), 0);
render.resize((800.0, 600.0));