PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Integration: #3020 number its hayro-interpret patch 48 (40 is #2987's)
aionggec6a8166bb6a
diff --git a/crates/render/src/raster.rs b/crates/render/src/raster.rsindex e256209b9..b77e415c0 100644--- a/crates/render/src/raster.rs+++ b/crates/render/src/raster.rs@@ -7159,7 +7159,7 @@ endstream endobjassert_eq!(decodes("B"), 5, "a JPX soft mask decodes for the size it is drawn at");}- // ICC profiles whose stream dictionaries are the same (vendored hayro-interpret patch 40).+ // ICC profiles whose stream dictionaries are the same (vendored hayro-interpret patch 48).mod icc_profile_cache;/// Render `pdf`'s first page at 72 dpi with no time limit beyond the test's own.diff --git a/crates/render/src/raster/tests/icc_profile_cache.rs b/crates/render/src/raster/tests/icc_profile_cache.rsindex 61b7dd2f2..dd6bce8d5 100644--- a/crates/render/src/raster/tests/icc_profile_cache.rs+++ b/crates/render/src/raster/tests/icc_profile_cache.rs@@ -1,5 +1,5 @@//! Two `/ICCBased` profiles whose stream dictionaries are byte for byte the same (`/N 3` and one-//! `/Length`) each draw through their own profile (vendored hayro-interpret patch 40). hayro+//! `/Length`) each draw through their own profile (vendored hayro-interpret patch 48). hayro//! cached the colour space it read from a profile stream by the dictionary's bytes alone, so//! the second profile drew through whichever was read first.//!diff --git a/vendor/hayro-interpret/src/cache.rs b/vendor/hayro-interpret/src/cache.rsindex 3884fcb23..bbc26e163 100644--- a/vendor/hayro-interpret/src/cache.rs+++ b/vendor/hayro-interpret/src/cache.rs@@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::{Arc, Mutex};type CacheMap = HashMap<u128, Option<Box<dyn Any + Send + Sync>>>;-/// The objects read from a document, by key. PdfCraft patch (40): the second field counts the+/// The objects read from a document, by key. PdfCraft patch (48): the second field counts the/// ICC profiles read through it ([`Cache::icc_profile_reads`]).#[derive(Clone)]pub(crate) struct Cache(Arc<Mutex<CacheMap>>, Arc<AtomicUsize>);@@ -23,13 +23,13 @@ impl Cache {Self(Arc::new(Mutex::new(HashMap::new())), Arc::default())}- /// PdfCraft patch (40): count one ICC profile read, the colour space of an `/ICCBased`+ /// PdfCraft patch (48): count one ICC profile read, the colour space of an `/ICCBased`/// profile no entry held yet being built from it.pub(crate) fn count_icc_profile_read(&self) {self.1.fetch_add(1, Ordering::Relaxed);}- /// PdfCraft patch (40): how many ICC profiles were read through this cache.+ /// PdfCraft patch (48): how many ICC profiles were read through this cache.pub(crate) fn icc_profile_reads(&self) -> usize {self.1.load(Ordering::Relaxed)}diff --git a/vendor/hayro-interpret/src/color.rs b/vendor/hayro-interpret/src/color.rsindex ad69b9886..202739659 100644--- a/vendor/hayro-interpret/src/color.rs+++ b/vendor/hayro-interpret/src/color.rs@@ -122,7 +122,7 @@ pub(crate) enum ColorSpaceType {DeviceN(DeviceN),}-/// PdfCraft patch (40): what the colour space read from an `/ICCBased` profile stream is cached+/// PdfCraft patch (48): what the colour space read from an `/ICCBased` profile stream is cached/// by. hayro keyed it by the stream dictionary's bytes alone, so two different profiles with the/// same `/N` and `/Length` shared whichever was read first, and colours in the second were/// drawn through the first.@@ -138,7 +138,7 @@ enum IccProfileKey<'a> {Content { dict: u128, data: &'a [u8] },}-/// PdfCraft patch (40): the object of the `/ICCBased` profile `stream` that `array` names, or+/// PdfCraft patch (48): the object of the `/ICCBased` profile `stream` that `array` names, or/// `None` for a stream written directly in the array (its dictionary lies within the array's/// bytes). Such a stream has no object of its own: its dictionary reports the object that/// holds the array, which every other stream written there reports too.@@ -168,7 +168,7 @@ impl ColorSpaceType {let dict = icc_stream.dict();let num_components = dict.get::<usize>(N)?;- // PdfCraft patch (40): cached by what the profile is read from (see+ // PdfCraft patch (48): cached by what the profile is read from (see// `IccProfileKey`), not by the stream dictionary's bytes alone.let read = || {let data = icc_stream.raw_data();diff --git a/vendor/hayro-interpret/src/context.rs b/vendor/hayro-interpret/src/context.rsindex fa7e960f9..39806fcd8 100644--- a/vendor/hayro-interpret/src/context.rs+++ b/vendor/hayro-interpret/src/context.rs@@ -147,7 +147,7 @@ impl<'a> InterpreterCache<'a> {self.decoded_cache.decodes()}- /// PdfCraft patch (40): how many `/ICCBased` profiles were read through this cache, for+ /// PdfCraft patch (48): how many `/ICCBased` profiles were read through this cache, for/// diagnostics and tests. A profile used again, by the same stream object or by a copy with/// the same dictionary and bytes, is read once.pub fn icc_profile_reads(&self) -> usize {