Reuse cached layouts for relocated native shipouts

This commit is contained in:
gloamxun committed 2026-12-01 22:30:37 +08:00
1 parent 41a459b4ca
commit 57c05d9635
8 files changed
+394 -26

No files matched your search

@@ -43,6 +43,7 @@ mod scheduling;
mod specials;
mod statistics;
mod continuation;
pub use continuation::RelocatedShipoutSuffix;
mod xdv_annotation;
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
@@ -87,10 +87,43 @@ impl InputFrame {
}
}
/// Source coordinates for the shipouts copied from a moved execution suffix.
pub struct RelocatedShipoutSuffix {
first_page: usize,
map: SourceRelocation,
}
impl RelocatedShipoutSuffix {
/// Relocate a raw local layout from the exact donor execution at the
/// given zero-based shipout index. The host must match that execution
/// before supplying a cached list.
pub fn relocate_layout(
&self,
index: usize,
layout: &crate::render::DisplayList,
) -> Option<crate::render::DisplayList> {
if index < self.first_page {
return None;
}
layout.relocate_sources(|span| self.map.relocate_span(span))
}
}
impl EntryCheckpoint {
/// Construct an execution with the current prefix and a previously
/// completed suffix. The host must still validate and replay that suffix.
pub fn splice_settled_suffix(&self, prior: &Self, completed: &Execution) -> Option<Execution> {
self.splice_settled_suffix_with_layout(prior, completed)
.map(|(execution, _)| execution)
}
/// Also return the coordinate mapping for copied shipouts whose cached
/// local layouts belong to the supplied completed execution.
pub fn splice_settled_suffix_with_layout(
&self,
prior: &Self,
completed: &Execution,
) -> Option<(Execution, Option<RelocatedShipoutSuffix>)> {
if self.entry != self.active_source
|| prior.entry != prior.active_source
|| self.entry != prior.entry
@@ -190,7 +223,13 @@ impl EntryCheckpoint {
execution.events.push(offset_event_steps(event, offset)?);
}
}
Some(execution)
let layout = relocation.map(|map| RelocatedShipoutSuffix {
// The executor records one top-level shipout event whenever
// this count advances. Form canvases do not enter this sequence.
first_page: old.shipped_pages,
map,
});
Some((execution, layout))
}
/// Carry later checkpoints from the suffix accepted by
/// splice_settled_suffix into this revision. The host must still replay
+3 -1
View File
@@ -71,7 +71,9 @@ pub use case::CaseCode;
pub use context::{ContextFrame, ContextKind, InputContext};
pub use device::{NativeShipout, ShipoutDevice, ShipoutSpecial};
pub use diagnostics::{DiagnosticBox, DiagnosticNode, ShowBoxReport};
pub use engine::{CheckpointDecision, CheckpointSource, EntryCheckpoint, Executor, Limits};
pub use engine::{
CheckpointDecision, CheckpointSource, EntryCheckpoint, Executor, Limits, RelocatedShipoutSuffix,
};
pub use font_catalog::{
FontCatalog, FontCharacter, FontId, FontInstance, FontLimits, FontResource,
};