color-device: Use a sRGB profile if the EDID is missing

This makes sure the ColorDevice can initialize successfully even if the
display doesn't have an EDID.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3394
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3673>
This commit is contained in:
Sebastian Wick 2024-03-27 16:51:08 +01:00
parent d214583aa2
commit 74a01e3f39

View File

@ -963,25 +963,38 @@ static void
create_device_profile_from_edid (MetaColorDevice *color_device, create_device_profile_from_edid (MetaColorDevice *color_device,
GTask *task) GTask *task)
{ {
const MetaEdidInfo *edid_info; const MetaEdidInfo *edid_info =
meta_monitor_get_edid_info (color_device->monitor);
GenerateProfileData *data = g_task_get_task_data (task);
g_autoptr (CdIcc) cd_icc = NULL;
g_autoptr (GBytes) bytes = NULL;
g_autofree char *file_md5_checksum = NULL;
g_autoptr (GError) error = NULL;
edid_info = meta_monitor_get_edid_info (color_device->monitor);
if (edid_info) if (edid_info)
{ {
g_autoptr (CdIcc) cd_icc = NULL;
GBytes *bytes;
g_autoptr (GError) error = NULL;
GenerateProfileData *data = g_task_get_task_data (task);
const char *file_path = data->file_path;
g_autofree char *file_md5_checksum = NULL;
meta_topic (META_DEBUG_COLOR, meta_topic (META_DEBUG_COLOR,
"Generating ICC profile for '%s' from EDID", "Generating ICC profile for '%s' from EDID",
meta_color_device_get_id (color_device)); meta_color_device_get_id (color_device));
cd_icc = create_icc_profile_from_edid (color_device, cd_icc = create_icc_profile_from_edid (color_device,
edid_info, file_path, edid_info, data->file_path,
&error); &error);
}
else
{
meta_topic (META_DEBUG_COLOR,
"Generating sRGB ICC profile for '%s' because EDID is missing",
meta_color_device_get_id (color_device));
cd_icc = cd_icc_new ();
if (!cd_icc_create_default_full (cd_icc,
CD_ICC_LOAD_FLAGS_PRIMARIES,
&error))
g_clear_object (&cd_icc);
}
if (!cd_icc) if (!cd_icc)
{ {
g_task_return_error (task, g_steal_pointer (&error)); g_task_return_error (task, g_steal_pointer (&error));
@ -1004,15 +1017,8 @@ create_device_profile_from_edid (MetaColorDevice *color_device,
data->color_calibration = data->color_calibration =
meta_color_calibration_new (cd_icc, NULL); meta_color_calibration_new (cd_icc, NULL);
data->cd_icc = g_steal_pointer (&cd_icc); data->cd_icc = g_steal_pointer (&cd_icc);
data->bytes = bytes; data->bytes = g_steal_pointer (&bytes);
save_icc_profile (file_path, task); save_icc_profile (data->file_path, task);
}
else
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"No EDID available");
g_object_unref (task);
}
} }
static void static void