Allocate native PNG transparency and palette objects
This commit is contained in:
1 parent
51451813dc
commit
342bedf9b4
9 files changed
+215
-29
No files matched your search
@@ -452,6 +452,7 @@ impl Executor {
|
||||
let mut has_space_nodes = false;
|
||||
let mut has_explicit_space = false;
|
||||
let mut pdf_objects = Vec::new();
|
||||
let mut pdf_images = Vec::new();
|
||||
let mut pdf_forms = Vec::new();
|
||||
let mut xdv_annotations = std::collections::BTreeMap::new();
|
||||
let mut reopened_images = false;
|
||||
@@ -496,6 +497,17 @@ impl Executor {
|
||||
self.current = output.span;
|
||||
self.tick()?;
|
||||
pdf_forms.push((form.number, output.span));
|
||||
} else if let OutputOperation::PdfImage { image, .. } = &output.operation
|
||||
&& !unicode_pages && device.pdf.is_some()
|
||||
{
|
||||
self.current = output.span;
|
||||
self.tick()?;
|
||||
if let Some(page) = &mut shipout.pdf_objects
|
||||
&& page.png_group.is_none()
|
||||
{
|
||||
page.png_group = image.png_group;
|
||||
}
|
||||
pdf_images.push((image.id, output.span));
|
||||
} else if let OutputOperation::PdfColor { stack, action } = &output.operation {
|
||||
if device.pdf.is_none() {
|
||||
return self.fail("cannot ship a PDF color operation to DVI");
|
||||
@@ -705,6 +717,10 @@ impl Executor {
|
||||
.finish_page(self.shipped_pages as u32 + 1, limit)
|
||||
.map_err(|message| self.error(message, current))?;
|
||||
}
|
||||
for (image, span) in pdf_images {
|
||||
self.current = span;
|
||||
self.declare_pdf_image(image, files)?;
|
||||
}
|
||||
if reopened_images {
|
||||
self.rebind_shipped_format_images(&mut shipout.box_node)?;
|
||||
}
|
||||
|
||||
@@ -233,6 +233,11 @@ impl Executor {
|
||||
self.reads.insert(Dependency::PdfObjects);
|
||||
image.pdf_object_number = Some(self.state.pdf_objects.get_or_insert_with(Default::default)
|
||||
.reserve_image(id, self.limits.tokens).map_err(|error| self.error(error, token.span))?);
|
||||
let header = header.expect("prepared pdfTeX header");
|
||||
if image.image.reserves_png_group((header.major, i32::from(header.minor))) {
|
||||
image.png_group = Some(self.state.pdf_objects.as_deref_mut().expect("registered image")
|
||||
.reserve_png_group(self.limits.tokens).map_err(|error| self.error(error, token.span))?);
|
||||
}
|
||||
}
|
||||
let saved = (pdftex && self.state.is_initex())
|
||||
.then(|| FormatPdfImage::capture(&image, &attributes, format_kind));
|
||||
@@ -486,7 +491,7 @@ impl Executor {
|
||||
pending_xdv: None,
|
||||
});
|
||||
let hidden = special.hidden;
|
||||
self.emit_pdf_image_object(image.clone(), special.attributes);
|
||||
self.emit_pdf_image_object(image.clone(), special.attributes, None);
|
||||
Ok((!hidden).then_some(image))
|
||||
}
|
||||
|
||||
@@ -538,7 +543,18 @@ impl Executor {
|
||||
} else {
|
||||
text.into_bytes()
|
||||
};
|
||||
self.emit_pdf_image_object(image, attributes);
|
||||
let png_auxiliary = if self.state.input_profile() == InputProfile::TeX8Bit
|
||||
&& let Some(header) = self.state.pdf_header_options
|
||||
&& let Some(is_mask) = image.image.png_auxiliary_stream((header.major, i32::from(header.minor)))
|
||||
{
|
||||
self.reads.insert(Dependency::PdfObjects);
|
||||
Some(self.state.pdf_objects.get_or_insert_with(Default::default)
|
||||
.reserve_png_auxiliary(is_mask, self.limits.tokens)
|
||||
.map_err(|error| self.error(error, self.current))?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.emit_pdf_image_object(image, attributes, png_auxiliary);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -578,7 +594,9 @@ impl Executor {
|
||||
.map_err(|message| self.error(message, b.span))
|
||||
}
|
||||
|
||||
fn emit_pdf_image_object(&mut self, image: Arc<PdfImageUse>, attributes: Vec<u8>) {
|
||||
fn emit_pdf_image_object(
|
||||
&mut self, image: Arc<PdfImageUse>, attributes: Vec<u8>, png_auxiliary: Option<u32>,
|
||||
) {
|
||||
let compression = self
|
||||
.read_parameter(Parameter::Pdfcompresslevel)
|
||||
.width()
|
||||
@@ -587,6 +605,7 @@ impl Executor {
|
||||
image,
|
||||
attributes,
|
||||
compression,
|
||||
png_auxiliary,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ use std::{
|
||||
sync::{Arc, Mutex, OnceLock, Weak},
|
||||
};
|
||||
|
||||
const SCHEMA: u32 = 88;
|
||||
const COMPATIBLE_SCHEMAS: [u32; 55] = [
|
||||
27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, SCHEMA,
|
||||
const SCHEMA: u32 = 89;
|
||||
const COMPATIBLE_SCHEMAS: [u32; 56] = [
|
||||
27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, SCHEMA,
|
||||
];
|
||||
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
@@ -208,8 +208,13 @@ impl FormatImage {
|
||||
} else {
|
||||
saved.image.image.color_space.is_none()
|
||||
};
|
||||
let valid_group = saved.image.png_group.is_none_or(|group| {
|
||||
image.schema >= 89 && saved.kind == FormatImageKind::Png
|
||||
&& pdf_objects.is_some_and(|objects| objects.is_png_group(group))
|
||||
});
|
||||
if !valid_profile
|
||||
|| !valid_number
|
||||
|| !valid_group
|
||||
|| saved.image.id != index + 1
|
||||
|| saved.path().as_os_str().is_empty()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user