mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +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:
parent
6d70b6a3a7
commit
aee7c44064
3 changed files with 42 additions and 1 deletions
|
@ -99,7 +99,7 @@ struct ICCHeader {
|
||||||
DateTimeNumber profile_creation_time;
|
DateTimeNumber profile_creation_time;
|
||||||
|
|
||||||
BigEndian<u32> profile_file_signature;
|
BigEndian<u32> profile_file_signature;
|
||||||
BigEndian<u32> primary_platform;
|
BigEndian<PrimaryPlatform> primary_platform;
|
||||||
|
|
||||||
BigEndian<u32> profile_flags;
|
BigEndian<u32> profile_flags;
|
||||||
BigEndian<u32> device_manufacturer;
|
BigEndian<u32> device_manufacturer;
|
||||||
|
@ -226,6 +226,19 @@ ErrorOr<void> parse_file_signature(ICCHeader const& header)
|
||||||
return {};
|
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)
|
Optional<DeviceManufacturer> parse_device_manufacturer(ICCHeader const& header)
|
||||||
{
|
{
|
||||||
// ICC v4, 7.2.12 Device manufacturer field
|
// 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)
|
StringView rendering_intent_name(RenderingIntent rendering_intent)
|
||||||
{
|
{
|
||||||
switch (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_data_color_space = TRY(parse_data_color_space(header));
|
||||||
profile->m_connection_space = TRY(parse_connection_space(header));
|
profile->m_connection_space = TRY(parse_connection_space(header));
|
||||||
profile->m_creation_timestamp = TRY(parse_creation_date_time(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_flags = Flags { header.profile_flags };
|
||||||
profile->m_device_manufacturer = parse_device_manufacturer(header);
|
profile->m_device_manufacturer = parse_device_manufacturer(header);
|
||||||
profile->m_device_model = parse_device_model(header);
|
profile->m_device_model = parse_device_model(header);
|
||||||
|
|
|
@ -104,6 +104,15 @@ enum class ColorSpace : u32 {
|
||||||
StringView data_color_space_name(ColorSpace);
|
StringView data_color_space_name(ColorSpace);
|
||||||
StringView profile_connection_space_name(ColorSpace);
|
StringView profile_connection_space_name(ColorSpace);
|
||||||
|
|
||||||
|
// ICC v4, 7.2.10 Primary platform field, Table 20 — Primary platforms
|
||||||
|
enum class PrimaryPlatform : u32 {
|
||||||
|
Apple = 0x4150504C, // 'APPL'
|
||||||
|
Microsoft = 0x4D534654, // 'MSFT'
|
||||||
|
SiliconGraphics = 0x53474920, // 'SGI '
|
||||||
|
Sun = 0x53554E57, // 'SUNW'
|
||||||
|
};
|
||||||
|
StringView primary_platform_name(PrimaryPlatform);
|
||||||
|
|
||||||
// ICC v4, 7.2.15 Rendering intent field
|
// ICC v4, 7.2.15 Rendering intent field
|
||||||
enum class RenderingIntent {
|
enum class RenderingIntent {
|
||||||
Perceptual,
|
Perceptual,
|
||||||
|
@ -215,6 +224,7 @@ public:
|
||||||
ColorSpace connection_space() const { return m_connection_space; }
|
ColorSpace connection_space() const { return m_connection_space; }
|
||||||
|
|
||||||
time_t creation_timestamp() const { return m_creation_timestamp; }
|
time_t creation_timestamp() const { return m_creation_timestamp; }
|
||||||
|
PrimaryPlatform primary_platform() const { return m_primary_platform; }
|
||||||
Flags flags() const { return m_flags; }
|
Flags flags() const { return m_flags; }
|
||||||
Optional<DeviceManufacturer> device_manufacturer() const { return m_device_manufacturer; }
|
Optional<DeviceManufacturer> device_manufacturer() const { return m_device_manufacturer; }
|
||||||
Optional<DeviceModel> device_model() const { return m_device_model; }
|
Optional<DeviceModel> device_model() const { return m_device_model; }
|
||||||
|
@ -233,6 +243,7 @@ private:
|
||||||
ColorSpace m_data_color_space;
|
ColorSpace m_data_color_space;
|
||||||
ColorSpace m_connection_space;
|
ColorSpace m_connection_space;
|
||||||
time_t m_creation_timestamp;
|
time_t m_creation_timestamp;
|
||||||
|
PrimaryPlatform m_primary_platform;
|
||||||
Flags m_flags;
|
Flags m_flags;
|
||||||
Optional<DeviceManufacturer> m_device_manufacturer;
|
Optional<DeviceManufacturer> m_device_manufacturer;
|
||||||
Optional<DeviceModel> m_device_model;
|
Optional<DeviceModel> m_device_model;
|
||||||
|
|
|
@ -37,6 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
outln("data color space: {}", Gfx::ICC::data_color_space_name(profile->data_color_space()));
|
outln("data color space: {}", Gfx::ICC::data_color_space_name(profile->data_color_space()));
|
||||||
outln("connection space: {}", Gfx::ICC::profile_connection_space_name(profile->connection_space()));
|
outln("connection space: {}", Gfx::ICC::profile_connection_space_name(profile->connection_space()));
|
||||||
outln("creation date and time: {}", Core::DateTime::from_timestamp(profile->creation_timestamp()).to_deprecated_string());
|
outln("creation date and time: {}", Core::DateTime::from_timestamp(profile->creation_timestamp()).to_deprecated_string());
|
||||||
|
outln("primary platform: {}", Gfx::ICC::primary_platform_name(profile->primary_platform()));
|
||||||
|
|
||||||
auto flags = profile->flags();
|
auto flags = profile->flags();
|
||||||
outln("flags: 0x{:08x}", flags.bits());
|
outln("flags: 0x{:08x}", flags.bits());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue