Apply XDV color state and page backgrounds at shipout

This commit is contained in:
gloamxun committed 2026-11-25 20:09:15 +08:00
1 parent cc147e93d8
commit 8be7867b37
10 files changed
+590 -19

No files matched your search

+16 -6
View File
@@ -41,6 +41,10 @@ pub struct NativeShipout {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub(super) pdf_graphics_steps: Vec<Option<PdfGraphics>>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub(super) xdv_color_steps: BTreeMap<usize, Arc<PdfColorProgram>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(super) pdf_background: Option<Arc<PdfColorProgram>>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub(super) pdf_special_images: BTreeMap<usize, (Arc<crate::pdf_image::PdfImageUse>, TokenOrigin)>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub specials: Vec<ShipoutSpecial>,
@@ -77,6 +81,7 @@ impl NativeShipout {
pdf: self.device.pdf.clone(),
pdf_font_bindings: self.pdf_font_bindings.clone(),
pdf_links: self.pdf_links.clone(),
pdf_background: self.pdf_background.clone(),
pdf_text_spaces: self.pdf_text_spaces.clone(),
pdf_resources: crate::pdf_device::page_resources::PageResources {
entries: self.pdf_resource_entries.clone(),
@@ -130,12 +135,17 @@ impl NativeShipout {
}
boxes::GeometryItem::PdfGraphics { x, y } => {
match graphics_steps.next() {
Some((_, Some(operation))) => page.items.push(DisplayItem::PdfGraphics {
x: self.device.horizontal_origin + x,
y: self.device.vertical_origin + self.box_node.height + y,
operation: operation.clone(),
}),
Some((step, None)) => {
Some((step, operation)) => {
if let Some(operation) = operation {
page.items.push(DisplayItem::PdfGraphics {
x: self.device.horizontal_origin + x,
y: self.device.vertical_origin + self.box_node.height + y,
operation: operation.clone(),
});
}
if let Some(program) = self.xdv_color_steps.get(&step) {
page.items.push(DisplayItem::PdfColor(program.clone()));
}
if let Some((image, origin)) = self.pdf_special_images.get(&step) {
let [left, bottom] = image.xdv.as_ref().unwrap().layout_offset;
page.sources.insert(