summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-01-07 15:22:15 -0500
committerSam Atkins <atkinssj@gmail.com>2023-01-08 09:56:07 +0000
commitaee7c44064b4ad24709e3b5c5b5bb63b3b2d7354 (patch)
tree0784666dadd81a360aad211c2c65ca2b80592d6b /Userland
parent6d70b6a3a77d28e93ccc02d4a3c4026560a15fee (diff)
downloadserenity-aee7c44064b4ad24709e3b5c5b5bb63b3b2d7354.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGfx/ICCProfile.cpp31
-rw-r--r--Userland/Libraries/LibGfx/ICCProfile.h11
-rw-r--r--Userland/Utilities/icc.cpp1
3 files changed, 42 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/ICCProfile.cpp b/Userland/Libraries/LibGfx/ICCProfile.cpp
index 6406492965..89327360b3 100644
--- a/Userland/Libraries/LibGfx/ICCProfile.cpp
+++ b/Userland/Libraries/LibGfx/ICCProfile.cpp
@@ -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);
diff --git a/Userland/Libraries/LibGfx/ICCProfile.h b/Userland/Libraries/LibGfx/ICCProfile.h
index 162ad260d0..8bb97204ad 100644
--- a/Userland/Libraries/LibGfx/ICCProfile.h
+++ b/Userland/Libraries/LibGfx/ICCProfile.h
@@ -104,6 +104,15 @@ enum class ColorSpace : u32 {
StringView data_color_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
enum class RenderingIntent {
Perceptual,
@@ -215,6 +224,7 @@ public:
ColorSpace connection_space() const { return m_connection_space; }
time_t creation_timestamp() const { return m_creation_timestamp; }
+ PrimaryPlatform primary_platform() const { return m_primary_platform; }
Flags flags() const { return m_flags; }
Optional<DeviceManufacturer> device_manufacturer() const { return m_device_manufacturer; }
Optional<DeviceModel> device_model() const { return m_device_model; }
@@ -233,6 +243,7 @@ private:
ColorSpace m_data_color_space;
ColorSpace m_connection_space;
time_t m_creation_timestamp;
+ PrimaryPlatform m_primary_platform;
Flags m_flags;
Optional<DeviceManufacturer> m_device_manufacturer;
Optional<DeviceModel> m_device_model;
diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp
index 708068c28d..ac786a87fe 100644
--- a/Userland/Utilities/icc.cpp
+++ b/Userland/Utilities/icc.cpp
@@ -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("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("primary platform: {}", Gfx::ICC::primary_platform_name(profile->primary_platform()));
auto flags = profile->flags();
outln("flags: 0x{:08x}", flags.bits());