Merge disk-cache-per-frame-files: third review round of step 1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76andClaude Opus 5.5 committed 2026-11-07 04:55:26 +01:00
commit dc88b8b534
6 files changed
+40 -7

No files matched your search

Generated
+2
View File
@@ -1468,6 +1468,7 @@ dependencies = [
"effectcraft-script",
"image",
"serde_json",
"tempfile",
"thiserror 2.0.21",
]
@@ -1878,6 +1879,7 @@ dependencies = [
"lz4_flex",
"rayon",
"serde",
"tempfile",
"web-time",
]
+1
View File
@@ -19,3 +19,4 @@ effectcraft-model = { workspace = true }
[dev-dependencies]
effectcraft-script = { workspace = true }
effectcraft-host = { workspace = true }
tempfile = { workspace = true }
+3 -2
View File
@@ -646,7 +646,9 @@ mod tests {
thread_local! {
static NOTED: std::cell::RefCell<Vec<String>> = const { std::cell::RefCell::new(Vec::new()) };
}
let base = std::env::temp_dir().join(format!("ec-confine-3184-{}", std::process::id()));
// (a fresh directory, removed when the test ends, panicking or not)
let tmp = tempfile::tempdir().unwrap();
let base = tmp.path();
let (inside, outside) = (base.join("in"), base.join("elsewhere"));
for d in [&inside, &outside] {
std::fs::create_dir_all(d).unwrap();
@@ -666,7 +668,6 @@ mod tests {
assert!(!shown && !files.is_complete(), "outside the roots: {files:?}");
// The next render on the thread is not affected.
assert!(read(&footage(&inside)).1.is_complete());
let _ = std::fs::remove_dir_all(&base);
}
#[test]
+3
View File
@@ -26,3 +26,6 @@ rayon = { workspace = true }
web-time = { workspace = true }
serde = { workspace = true }
log = { workspace = true }
[dev-dependencies]
tempfile = { workspace = true }
+7
View File
@@ -668,7 +668,14 @@ fn note_layout_fonts(ctx: &EvalCtx, styles: &[effectcraft_keyframe::CharStyle],
if resolved.iter().any(|r| r.missing) {
log.mark_incomplete();
}
// Each run's face, glyphs or not: an empty paragraph's face sets its line's metrics (in a
// box, the first baseline that places every later line).
let mut faces: Vec<fonts::FaceId> = Vec::new();
for r in &resolved {
if !faces.contains(&r.face) {
faces.push(r.face);
}
}
for g in &layout.glyphs {
if g.id == 0 || resolved.get(g.run).is_none_or(|r| r.face != g.face) {
log.mark_incomplete();
+24 -5
View File
@@ -742,10 +742,9 @@ fn text_notes_the_font_files_it_draws_with() {
}]
}
}
let dir = std::env::temp_dir().join(format!("effectcraft-font-reads-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let font = dir.join("reads-test-sans.ttf");
// (a fresh directory, removed when the test ends, panicking or not)
let dir = tempfile::tempdir().unwrap();
let font = dir.path().join("reads-test-sans.ttf");
std::fs::write(&font, fonts::INTER_REGULAR).unwrap();
fonts::add_source(&OneFile(font.clone()));
let stamp = FileStamp::native(&font.to_string_lossy()).unwrap();
@@ -781,5 +780,25 @@ fn text_notes_the_font_files_it_draws_with() {
// One it lacks (Inter has no CJK) is drawn with a fallback face, or none: another installed
// font could take it, so the list can't vouch for the text.
assert!(!files_with("Reads Test Sans", Some('\u{4e2d}')).is_complete());
let _ = std::fs::remove_dir_all(&dir);
// An empty first paragraph in the face draws no glyph, but in a box its face sets the first
// baseline that places the lines after it: the file is read all the same.
let (mut p, cid, comp) = setup(200, 80);
let base = TextDoc {
text: "\rHi".into(),
font: fonts::DEFAULT_FAMILY.into(),
style: "Regular".into(),
size: 30.0,
box_size: Some([180.0, 60.0]),
..Default::default()
};
let first = effectcraft_keyframe::CharStyle { font: "Reads Test Sans".into(), ..base.base_style() };
let runs = vec![effectcraft_keyframe::StyleRun { len: 1, style: first }, effectcraft_keyframe::StyleRun { len: 2, style: base.base_style() }];
let l = text_layer(&mut p, &comp, TextDoc { runs, ..base });
p.comp_mut(cid).unwrap().layers.push(l);
let log = ReadLog::new();
let c = EvalCtx { reads: Some(&log), ..ctx(&p, cid, 0.0) };
assert!(text_geom(&c, &p.comp(cid).unwrap().layers[0]).is_some());
let files = log.into_files();
assert!(files.is_complete(), "{files:?}");
assert_eq!(files.get(&font.to_string_lossy()), Some(stamp), "{files:?}");
}