Import PNG images in the native PDF device

This commit is contained in:
gloamxun committed 2026-11-21 04:13:18 +08:00
1 parent 297431a547
commit 555a029505
13 files changed
+467 -35

No files matched your search

+12 -2
View File
@@ -322,9 +322,16 @@ impl DisplayList {
self.pdf_resources.viewport.as_ref().map_or(1.0, |viewport| viewport.unit())
}
fn svg_paint_items(&self) -> impl Iterator<Item = &DisplayItem> {
self.items
.iter()
.filter(|item| !matches!(item, DisplayItem::PdfImageObject(_)))
}
/// Compare the inputs consumed by SVG rendering. Font data for glyphs not
/// present on this page and source locations do not affect its SVG.
pub fn same_svg_paint(&self, other: &Self) -> bool {
let mut right = other.svg_paint_items();
self.width == other.width
&& self.height == other.height
&& self.units == other.units
@@ -333,8 +340,10 @@ impl DisplayList {
&& self.pdf_resources.opacity == other.pdf_resources.opacity
&& self.pdf_resources.viewport == other.pdf_resources.viewport
&& self.pdf_resources.needs_pdf_for_preview == other.pdf_resources.needs_pdf_for_preview
&& self.items.len() == other.items.len()
&& self.items.iter().zip(&other.items).all(|(left, right)| {
&& self.svg_paint_items().all(|left| {
let Some(right) = right.next() else {
return false;
};
match (left.native_svg_glyph(), right.native_svg_glyph()) {
(Some(Ok(left)), Some(Ok(right))) => left == right,
(None, None) => {
@@ -344,6 +353,7 @@ impl DisplayList {
_ => false,
}
})
&& right.next().is_none()
}
pub fn push(&mut self, item: DisplayItem) {