From 275542aaf8a74e0cec96dce0231cb339503db18b Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 20 Feb 2024 10:51:56 -0500 Subject: [PATCH] LibGfx/ICC: Add another version of the Apple P3 profile to quirks list Improves appearance of page 6 of https://fredrikbk.com/publications/copy-and-patch.pdf --- Userland/Libraries/LibGfx/ICC/Profile.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index 6b693480c8a..ca29a63de1c 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -760,6 +760,10 @@ ErrorOr Profile::check_tag_types() // (The macOS 13.1 /System/Library/ColorSync/Profiles/Display\ P3.icc file no longer has this quirk.) static constexpr Crypto::Hash::MD5::DigestType apple_p3_2015_id = { 0xe5, 0xbb, 0x0e, 0x98, 0x67, 0xbd, 0x46, 0xcd, 0x4b, 0xbe, 0x44, 0x6e, 0xbd, 0x1b, 0x75, 0x98 }; + // Profile ID of the "Display P3" profile in object 881 in https://fredrikbk.com/publications/copy-and-patch.pdf + // (The macOS 13.1 /System/Library/ColorSync/Profiles/Display\ P3.icc file no longer has this quirk.) + static constexpr Crypto::Hash::MD5::DigestType apple_p3_2017_id = { 0xca, 0x1a, 0x95, 0x82, 0x25, 0x7f, 0x10, 0x4d, 0x38, 0x99, 0x13, 0xd5, 0xd1, 0xea, 0x15, 0x82 }; + auto has_type = [&](auto tag, std::initializer_list types, std::initializer_list v4_types) { if (auto type = m_tag_table.get(tag); type.has_value()) { auto type_matches = [&](auto wanted_type) { return type.value()->type() == wanted_type; }; @@ -914,7 +918,7 @@ ErrorOr Profile::check_tag_types() // The v4 spec requires multiLocalizedUnicodeType for this, but I'm aware of a single file // that still uses the v2 'text' type here: /System/Library/ColorSync/Profiles/ITU-2020.icc on macOS 13.1. // https://openradar.appspot.com/radar?id=5529765549178880 - bool has_v2_cprt_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id; + bool has_v2_cprt_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id || id() == apple_p3_2017_id; if (is_v4() && type.value()->type() != MultiLocalizedUnicodeTagData::Type && (!has_v2_cprt_type_in_v4_file_quirk || type.value()->type() != TextTagData::Type)) return Error::from_string_literal("ICC::Profile: copyrightTag has unexpected v4 type"); if (is_v2() && type.value()->type() != TextTagData::Type) @@ -1103,7 +1107,7 @@ ErrorOr Profile::check_tag_types() // The v4 spec requires multiLocalizedUnicodeType for this, but I'm aware of a single file // that still uses the v2 'desc' type here: /System/Library/ColorSync/Profiles/ITU-2020.icc on macOS 13.1. // https://openradar.appspot.com/radar?id=5529765549178880 - bool has_v2_desc_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id; + bool has_v2_desc_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id || id() == apple_p3_2017_id; if (is_v4() && type.value()->type() != MultiLocalizedUnicodeTagData::Type && (!has_v2_desc_type_in_v4_file_quirk || type.value()->type() != TextDescriptionTagData::Type)) return Error::from_string_literal("ICC::Profile: profileDescriptionTag has unexpected v4 type"); if (is_v2() && type.value()->type() != TextDescriptionTagData::Type)