mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-28 12:08:46 -06:00
hayro-interpret cached the colour space built from an /ICCBased profile stream under the hash of the stream's dictionary bytes alone. Two different profiles with the same /N and /Length (any two uncompressed RGB profiles of one size) shared whichever was read first, so colours in the second space were drawn through the first profile for the rest of the document. Found while fixing #1201. The space is now keyed by what its profile is read from (IccProfileKey): the stream object a space names, looked up without reading the stream, and on a miss the old dictionary key plus the stream's own bytes (decrypted, not decoded), so byte-for-byte copies in other objects still share one parsed profile and a lookup never decodes. A stream written directly in the colour space array reports the object holding the array, as every other stream written there does; it is recognised by its dictionary lying within the array's bytes and keyed by content only. InterpreterCache::icc_profile_reads counts the profiles read, so the tests can check that the cache still hits. Tests: two synthetic RGB profiles of one length (linear sRGB, and red and blue swapped) as objects, a reused object, a copy and direct streams on one page.