1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:37:36 +00:00

LibGfx+icc: Print primary platform

There's a small, old-timey list of platforms in the spec, but as far
as I can tell nobody is using additional platforms on Linux or Android
or what. So let's try going with an enum class instead of the FourCC
machinery for now.
This commit is contained in:
Nico Weber 2023-01-07 15:22:15 -05:00 committed by Sam Atkins
parent 6d70b6a3a7
commit aee7c44064
3 changed files with 42 additions and 1 deletions

View file

@ -99,7 +99,7 @@ struct ICCHeader {
DateTimeNumber profile_creation_time;
BigEndian<u32> profile_file_signature;
BigEndian<u32> primary_platform;
BigEndian<PrimaryPlatform> primary_platform;
BigEndian<u32> profile_flags;
BigEndian<u32> device_manufacturer;
@ -226,6 +226,19 @@ ErrorOr<void> parse_file_signature(ICCHeader const& header)
return {};
}
ErrorOr<PrimaryPlatform> parse_primary_platform(ICCHeader const& header)
{
// ICC v4, 7.2.10 Primary platform field
switch (header.primary_platform) {
case PrimaryPlatform::Apple:
case PrimaryPlatform::Microsoft:
case PrimaryPlatform::SiliconGraphics:
case PrimaryPlatform::Sun:
return header.primary_platform;
}
return Error::from_string_literal("ICC::Profile: Invalid primary platform");
}
Optional<DeviceManufacturer> parse_device_manufacturer(ICCHeader const& header)
{
// ICC v4, 7.2.12 Device manufacturer field
@ -439,6 +452,21 @@ StringView profile_connection_space_name(ColorSpace color_space)
}
}
StringView primary_platform_name(PrimaryPlatform primary_platform)
{
switch (primary_platform) {
case PrimaryPlatform::Apple:
return "Apple"sv;
case PrimaryPlatform::Microsoft:
return "Microsoft"sv;
case PrimaryPlatform::SiliconGraphics:
return "Silicon Graphics"sv;
case PrimaryPlatform::Sun:
return "Sun"sv;
}
VERIFY_NOT_REACHED();
}
StringView rendering_intent_name(RenderingIntent rendering_intent)
{
switch (rendering_intent) {
@ -482,6 +510,7 @@ ErrorOr<NonnullRefPtr<Profile>> Profile::try_load_from_externally_owned_memory(R
profile->m_data_color_space = TRY(parse_data_color_space(header));
profile->m_connection_space = TRY(parse_connection_space(header));
profile->m_creation_timestamp = TRY(parse_creation_date_time(header));
profile->m_primary_platform = TRY(parse_primary_platform(header));
profile->m_flags = Flags { header.profile_flags };
profile->m_device_manufacturer = parse_device_manufacturer(header);
profile->m_device_model = parse_device_model(header);