From 2e315757b138e52f77eac762c4b59f4d975303b6 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 24 Jan 2023 15:21:20 -0500 Subject: [PATCH] LibGfx: Add names for all tag signatures in the v4 spec Also add a function to map each tag signature to its name, that is a function that maps e.g. measurementTag to "measurementTag"sv. To implement this without too much repetition, use an x-macro. I used pdftotext on the icc v4 spec to extract the list of tags, and then manually cleaned it up a bit: https://github.com/nico/hack/blob/main/icc-tags.txt I then converted that to an x-macro using vim macros. --- Userland/Libraries/LibGfx/ICCProfile.cpp | 12 +++++ Userland/Libraries/LibGfx/ICCProfile.h | 61 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/Userland/Libraries/LibGfx/ICCProfile.cpp b/Userland/Libraries/LibGfx/ICCProfile.cpp index 83885c4867..4ac1718845 100644 --- a/Userland/Libraries/LibGfx/ICCProfile.cpp +++ b/Userland/Libraries/LibGfx/ICCProfile.cpp @@ -391,6 +391,18 @@ URL device_model_url(DeviceModel device_model) device_model.c0(), device_model.c1(), device_model.c2(), device_model.c3(), device_model.value)); } +Optional tag_signature_spec_name(TagSignature tag_signature) +{ + switch (tag_signature) { +#define TAG(name, id) \ + case name: \ + return #name##sv; + ENUMERATE_TAG_SIGNATURES(TAG) +#undef TAG + } + return {}; +} + StringView device_class_name(DeviceClass device_class) { switch (device_class) { diff --git a/Userland/Libraries/LibGfx/ICCProfile.h b/Userland/Libraries/LibGfx/ICCProfile.h index 207c008228..954461e293 100644 --- a/Userland/Libraries/LibGfx/ICCProfile.h +++ b/Userland/Libraries/LibGfx/ICCProfile.h @@ -59,6 +59,67 @@ using TagTypeSignature = DistinctFourCC; // IC URL device_manufacturer_url(DeviceManufacturer); URL device_model_url(DeviceModel); +// ICC v4, 9.2 Tag listing +// FIXME: Add v2-only tags too. +#define ENUMERATE_TAG_SIGNATURES(TAG) \ + TAG(AToB0Tag, 0x41324230 /* 'A2B0' */) \ + TAG(AToB1Tag, 0x41324231 /* 'A2B1' */) \ + TAG(AToB2Tag, 0x41324232 /* 'A2B2' */) \ + TAG(blueMatrixColumnTag, 0x6258595A /* 'bXYZ' */) \ + TAG(blueTRCTag, 0x62545243 /* 'bTRC' */) \ + TAG(BToA0Tag, 0x42324130 /* 'B2A0' */) \ + TAG(BToA1Tag, 0x42324131 /* 'B2A1' */) \ + TAG(BToA2Tag, 0x42324132 /* 'B2A2' */) \ + TAG(BToD0Tag, 0x42324430 /* 'B2D0' */) \ + TAG(BToD1Tag, 0x42324431 /* 'B2D1' */) \ + TAG(BToD2Tag, 0x42324432 /* 'B2D2' */) \ + TAG(BToD3Tag, 0x42324433 /* 'B2D3' */) \ + TAG(calibrationDateTimeTag, 0x63616C74 /* 'calt' */) \ + TAG(charTargetTag, 0x74617267 /* 'targ' */) \ + TAG(chromaticAdaptationTag, 0x63686164 /* 'chad' */) \ + TAG(chromaticityTag, 0x6368726D /* 'chrm' */) \ + TAG(cicpTag, 0x63696370 /* 'cicp' */) \ + TAG(colorantOrderTag, 0x636C726F /* 'clro' */) \ + TAG(colorantTableTag, 0x636C7274 /* 'clrt' */) \ + TAG(colorantTableOutTag, 0x636C6F74 /* 'clot' */) \ + TAG(colorimetricIntentImageStateTag, 0x63696973 /* 'ciis' */) \ + TAG(copyrightTag, 0x63707274 /* 'cprt' */) \ + TAG(deviceMfgDescTag, 0x646D6E64 /* 'dmnd' */) \ + TAG(deviceModelDescTag, 0x646D6464 /* 'dmdd' */) \ + TAG(DToB0Tag, 0x44324230 /* 'D2B0' */) \ + TAG(DToB1Tag, 0x44324231 /* 'D2B1' */) \ + TAG(DToB2Tag, 0x44324232 /* 'D2B2' */) \ + TAG(DToB3Tag, 0x44324233 /* 'D2B3' */) \ + TAG(gamutTag, 0x67616D74 /* 'gamt' */) \ + TAG(grayTRCTag, 0x6B545243 /* 'kTRC' */) \ + TAG(greenMatrixColumnTag, 0x6758595A /* 'gXYZ' */) \ + TAG(greenTRCTag, 0x67545243 /* 'gTRC' */) \ + TAG(luminanceTag, 0x6C756D69 /* 'lumi' */) \ + TAG(measurementTag, 0x6D656173 /* 'meas' */) \ + TAG(metadataTag, 0x6D657461 /* 'meta' */) \ + TAG(mediaWhitePointTag, 0x77747074 /* 'wtpt' */) \ + TAG(namedColor2Tag, 0x6E636C32 /* 'ncl2' */) \ + TAG(outputResponseTag, 0x72657370 /* 'resp' */) \ + TAG(perceptualRenderingIntentGamutTag, 0x72696730 /* 'rig0' */) \ + TAG(preview0Tag, 0x70726530 /* 'pre0' */) \ + TAG(preview1Tag, 0x70726531 /* 'pre1' */) \ + TAG(preview2Tag, 0x70726532 /* 'pre2' */) \ + TAG(profileDescriptionTag, 0x64657363 /* 'desc' */) \ + TAG(profileSequenceDescTag, 0x70736571 /* 'pseq' */) \ + TAG(profileSequenceIdentifierTag, 0x70736964 /* 'psid' */) \ + TAG(redMatrixColumnTag, 0x7258595A /* 'rXYZ' */) \ + TAG(redTRCTag, 0x72545243 /* 'rTRC' */) \ + TAG(saturationRenderingIntentGamutTag, 0x72696732 /* 'rig2' */) \ + TAG(technologyTag, 0x74656368 /* 'tech' */) \ + TAG(viewingCondDescTag, 0x76756564 /* 'vued' */) \ + TAG(viewingConditionsTag, 0x76696577 /* 'view' */) + +#define TAG(name, id) constexpr TagSignature name { id }; +ENUMERATE_TAG_SIGNATURES(TAG) +#undef TAG + +Optional tag_signature_spec_name(TagSignature); + // ICC v4, 7.2.4 Profile version field class Version { public: