color: Generate and store ICC profiles from EDID or EFI

Just as gsd-color does, generate color profiles. This can either be done
from EFI, if available and the color device is associated with a built
in panel, or from the EDID. If no source for a profile is found, none is
created.

The ICC profiles are also stored on disk so that they can be read by
e.g. colord. The on disk stored profiles will only be used for storing,
not reading the profiles, as the autogenerated ones will no matter what
always be loaded to verify the on disk profiles are up to date. If a on
disk profile is not, it will be replaced. This is so that fixes or
improvements to the profile generation will be made available despite
having run an older version earlier.

After generating, add some metadata about the generated file itself
needed by colord, i.e. file MD5 checksum and the file path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
This commit is contained in:
Jonas Ådahl
2021-11-29 20:44:56 +01:00
parent 7a242ff1a1
commit 062abe01b3
11 changed files with 1101 additions and 1 deletions

View File

@ -22,11 +22,14 @@
#include "backends/meta-color-device.h"
#include "backends/meta-color-manager-private.h"
#include "backends/meta-color-profile.h"
#include "meta-test/meta-context-test.h"
#include "tests/meta-monitor-test-utils.h"
static MetaContext *test_context;
#define PRIMARY_EPSILON 0.000015
static MonitorTestCaseSetup base_monitor_setup = {
.modes = {
{
@ -205,6 +208,67 @@ meta_test_color_management_device_basic (void)
}
}
static void
meta_test_color_management_profile_device (void)
{
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
META_MONITOR_MANAGER_TEST (monitor_manager);
MetaColorManager *color_manager =
meta_backend_get_color_manager (backend);
MetaEdidInfo edid_info;
MonitorTestCaseSetup test_case_setup = base_monitor_setup;
MetaMonitorTestSetup *test_setup;
MetaMonitor *monitor;
MetaColorDevice *color_device;
MetaColorProfile *color_profile;
CdIcc *cd_icc;
const CdColorXYZ *red;
const CdColorXYZ *green;
const CdColorXYZ *blue;
const CdColorXYZ *white;
edid_info = CALTECH_MONITOR_EDID;
test_case_setup.outputs[0].edid_info = edid_info;
test_case_setup.outputs[0].has_edid_info = TRUE;
test_setup = meta_create_monitor_test_setup (backend, &test_case_setup,
MONITOR_TEST_FLAG_NO_STORED);
meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
monitor = meta_monitor_manager_get_monitors (monitor_manager)->data;
color_device = meta_color_manager_get_color_device (color_manager, monitor);
g_assert_nonnull (color_device);
while (!meta_color_device_is_ready (color_device))
g_main_context_iteration (NULL, TRUE);
color_profile = meta_color_device_get_device_profile (color_device);
g_assert_nonnull (color_profile);
cd_icc = meta_color_profile_get_cd_icc (color_profile);
g_assert_nonnull (cd_icc);
red = cd_icc_get_red (cd_icc);
green = cd_icc_get_green (cd_icc);
blue = cd_icc_get_blue (cd_icc);
white = cd_icc_get_white (cd_icc);
/* Make sure we generate the same values as gsd-color did. */
g_assert_cmpfloat_with_epsilon (red->X, 0.549637, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (red->Y, 0.250671, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (red->Z, 0.000977, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (green->X, 0.277420, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (green->Y, 0.689514, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (green->Z, 0.052185, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (blue->X, 0.137146 , PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (blue->Y, 0.059814, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (blue->Z, 0.771744, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (white->X, 0.961090088, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (white->Y, 1.0, PRIMARY_EPSILON);
g_assert_cmpfloat_with_epsilon (white->Z, 1.10479736, PRIMARY_EPSILON);
}
static MetaMonitorTestSetup *
create_stage_view_test_setup (MetaBackend *backend)
{
@ -230,6 +294,8 @@ init_tests (void)
g_test_add_func ("/color-management/device/basic",
meta_test_color_management_device_basic);
g_test_add_func ("/color-management/profile/device",
meta_test_color_management_profile_device);
}
int