Reuse unchanged shipout drawing lists after checkpoint resume

This commit is contained in:
gloamxun committed 2026-11-28 22:50:16 +08:00
1 parent e7ab132520
commit 6939ff71ff
5 files changed
+88 -7

No files matched your search

@@ -66,6 +66,21 @@ fn pdf_resource_entries_empty(entries: &Arc<[u8]>) -> bool {
}
impl NativeShipout {
/// The checkpoint and its resumed execution share actual TeX lists.
/// Check that identity first, then compare the rest of the shipout snapshot.
pub fn shares_local_layout_with(&self, prior: &Self) -> bool {
let shared = match (&self.box_node.content, &prior.box_node.content) {
(BoxContent::Horizontal(current), BoxContent::Horizontal(previous)) => {
Arc::ptr_eq(current, previous)
}
(BoxContent::Vertical(current), BoxContent::Vertical(previous)) => {
Arc::ptr_eq(current, previous)
}
_ => false,
};
shared && self == prior
}
pub fn display_list(&self) -> Result<crate::render::DisplayList, String> {
self.display_list_prefix(None)
}
+10 -1
View File
@@ -778,6 +778,15 @@ impl Execution {
/// Paint actual shipped boxes using their captured device state. No
/// pagination or application of the job's final device settings.
pub fn shipout_display_lists(&self) -> Result<Vec<crate::render::DisplayList>, Error> {
self.shipout_display_lists_with(NativeShipout::display_list)
}
/// Lower shipped boxes, optionally reusing their immutable local layout.
/// The current revision still resolves all deferred and document-wide PDF data.
pub fn shipout_display_lists_with(
&self,
mut lower: impl FnMut(&NativeShipout) -> Result<crate::render::DisplayList, String>,
) -> Result<Vec<crate::render::DisplayList>, Error> {
if self.native_page.is_none() {
return Err(Error::at(
&self.sources,
@@ -803,7 +812,7 @@ impl Execution {
});
}
if let Event::Shipout(b) = e {
pages.push(b.display_list().map_err(|message| {
pages.push(lower(b).map_err(|message| {
Error::at(
&self.sources,
self.state.input_profile(),