diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2021-12-06 11:56:08 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2022-09-01 18:40:47 +0200 |
commit | 336a97ff1f55d9b42810d087a3af5ba4f1c8cf3f (patch) | |
tree | 103f8fa3c5f753cf97beb6586cf441c0c52150f0 /plugins | |
parent | c1ee6ea004f61bacdc81536218544def93ea5ffd (diff) | |
download | gnome-settings-daemon-336a97ff1f55d9b42810d087a3af5ba4f1c8cf3f.tar.gz |
color: Stop applying color profiles
This is now handled by mutter.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/color/gsd-color-state.c | 256 |
1 files changed, 0 insertions, 256 deletions
diff --git a/plugins/color/gsd-color-state.c b/plugins/color/gsd-color-state.c index 1b153d09..75bb1ad6 100644 --- a/plugins/color/gsd-color-state.c +++ b/plugins/color/gsd-color-state.c @@ -73,12 +73,6 @@ G_DEFINE_TYPE (GsdColorState, gsd_color_state, G_TYPE_OBJECT) #define GCM_ICC_PROFILE_IN_X_VERSION_MAJOR 0 #define GCM_ICC_PROFILE_IN_X_VERSION_MINOR 3 -typedef struct { - guint32 red; - guint32 green; - guint32 blue; -} GnomeRROutputClutItem; - GQuark gsd_color_state_error_quark (void) { @@ -287,217 +281,6 @@ gcm_set_csc_matrix (GnomeRROutput *output, return gnome_rr_output_set_color_transform (output, ctm, error); } -static GPtrArray * -gcm_session_generate_vcgt (CdProfile *profile, guint color_temperature, guint size) -{ - GnomeRROutputClutItem *tmp; - GPtrArray *array = NULL; - const cmsToneCurve **vcgt; - cmsFloat32Number in; - guint i; - cmsHPROFILE lcms_profile; - CdIcc *icc = NULL; - CdColorRGB temp; - - /* invalid size */ - if (size == 0) - goto out; - - /* open file */ - icc = cd_profile_load_icc (profile, CD_ICC_LOAD_FLAGS_NONE, NULL, NULL); - if (icc == NULL) - goto out; - - /* get tone curves from profile */ - lcms_profile = cd_icc_get_handle (icc); - vcgt = cmsReadTag (lcms_profile, cmsSigVcgtTag); - if (vcgt == NULL || vcgt[0] == NULL) { - g_debug ("profile does not have any VCGT data"); - goto out; - } - - /* get the color temperature */ - if (!cd_color_get_blackbody_rgb_full (color_temperature, - &temp, - CD_COLOR_BLACKBODY_FLAG_USE_PLANCKIAN)) { - g_warning ("failed to get blackbody for %uK", color_temperature); - cd_color_rgb_set (&temp, 1.0, 1.0, 1.0); - } else { - g_debug ("using VCGT gamma of %uK = %.1f,%.1f,%.1f", - color_temperature, temp.R, temp.G, temp.B); - } - - /* create array */ - array = g_ptr_array_new_with_free_func (g_free); - for (i = 0; i < size; i++) { - in = (gdouble) i / (gdouble) (size - 1); - tmp = g_new0 (GnomeRROutputClutItem, 1); - tmp->red = cmsEvalToneCurveFloat(vcgt[0], in) * temp.R * (gdouble) 0xffff; - tmp->green = cmsEvalToneCurveFloat(vcgt[1], in) * temp.G * (gdouble) 0xffff; - tmp->blue = cmsEvalToneCurveFloat(vcgt[2], in) * temp.B * (gdouble) 0xffff; - g_ptr_array_add (array, tmp); - } -out: - if (icc != NULL) - g_object_unref (icc); - return array; -} - -static guint -gnome_rr_output_get_gamma_size (GnomeRROutput *output) -{ - GnomeRRCrtc *crtc; - gint len = 0; - - crtc = gnome_rr_output_get_crtc (output); - if (crtc == NULL) - return 0; - gnome_rr_crtc_get_gamma (crtc, - &len, - NULL, NULL, NULL); - return (guint) len; -} - -static gboolean -gcm_session_output_set_gamma (GnomeRROutput *output, - GPtrArray *array, - GError **error) -{ - gboolean ret = TRUE; - guint16 *red = NULL; - guint16 *green = NULL; - guint16 *blue = NULL; - guint i; - GnomeRROutputClutItem *data; - GnomeRRCrtc *crtc; - - /* no length? */ - if (array->len == 0) { - ret = FALSE; - g_set_error_literal (error, - GSD_COLOR_MANAGER_ERROR, - GSD_COLOR_MANAGER_ERROR_FAILED, - "no data in the CLUT array"); - goto out; - } - - /* convert to a type X understands */ - red = g_new (guint16, array->len); - green = g_new (guint16, array->len); - blue = g_new (guint16, array->len); - for (i = 0; i < array->len; i++) { - data = g_ptr_array_index (array, i); - red[i] = data->red; - green[i] = data->green; - blue[i] = data->blue; - } - - /* send to LUT */ - crtc = gnome_rr_output_get_crtc (output); - if (crtc == NULL) { - ret = FALSE; - g_set_error (error, - GSD_COLOR_MANAGER_ERROR, - GSD_COLOR_MANAGER_ERROR_FAILED, - "failed to get ctrc for %s", - gnome_rr_output_get_name (output)); - goto out; - } - gnome_rr_crtc_set_gamma (crtc, array->len, - red, green, blue); -out: - g_free (red); - g_free (green); - g_free (blue); - return ret; -} - -static gboolean -gcm_session_device_set_gamma (GnomeRROutput *output, - CdProfile *profile, - guint color_temperature, - GError **error) -{ - gboolean ret = FALSE; - guint size; - GPtrArray *clut = NULL; - - /* create a lookup table */ - size = gnome_rr_output_get_gamma_size (output); - if (size == 0) { - ret = TRUE; - goto out; - } - clut = gcm_session_generate_vcgt (profile, color_temperature, size); - if (clut == NULL) { - g_set_error_literal (error, - GSD_COLOR_MANAGER_ERROR, - GSD_COLOR_MANAGER_ERROR_FAILED, - "failed to generate vcgt"); - goto out; - } - - /* apply the vcgt to this output */ - ret = gcm_session_output_set_gamma (output, clut, error); - if (!ret) - goto out; -out: - if (clut != NULL) - g_ptr_array_unref (clut); - return ret; -} - -static gboolean -gcm_session_device_reset_gamma (GnomeRROutput *output, - guint color_temperature, - GError **error) -{ - gboolean ret; - guint i; - guint size; - guint32 value; - GPtrArray *clut; - GnomeRROutputClutItem *data; - CdColorRGB temp; - - /* create a linear ramp */ - g_debug ("falling back to dummy ramp"); - clut = g_ptr_array_new_with_free_func (g_free); - size = gnome_rr_output_get_gamma_size (output); - if (size == 0) { - ret = TRUE; - goto out; - } - - /* get the color temperature */ - if (!cd_color_get_blackbody_rgb_full (color_temperature, - &temp, - CD_COLOR_BLACKBODY_FLAG_USE_PLANCKIAN)) { - g_warning ("failed to get blackbody for %uK", color_temperature); - cd_color_rgb_set (&temp, 1.0, 1.0, 1.0); - } else { - g_debug ("using reset gamma of %uK = %.1f,%.1f,%.1f", - color_temperature, temp.R, temp.G, temp.B); - } - - for (i = 0; i < size; i++) { - value = (i * 0xffff) / (size - 1); - data = g_new0 (GnomeRROutputClutItem, 1); - data->red = value * temp.R; - data->green = value * temp.G; - data->blue = value * temp.B; - g_ptr_array_add (clut, data); - } - - /* apply the vcgt to this output */ - ret = gcm_session_output_set_gamma (output, clut, error); - if (!ret) - goto out; -out: - g_ptr_array_unref (clut); - return ret; -} - static GnomeRROutput * gcm_session_get_state_output_by_device (GsdColorState *state, CdDevice *device, @@ -688,33 +471,6 @@ gcm_session_device_assign_profile_connect_cb (GObject *object, } } - /* create a vcgt for this icc file */ - ret = cd_profile_get_has_vcgt (profile); - if (ret) { - ret = gcm_session_device_set_gamma (output, - profile, - state->color_temperature, - &error); - if (!ret) { - g_warning ("failed to set %s gamma tables: %s", - cd_device_get_id (helper->device), - error->message); - g_error_free (error); - goto out; - } - } else { - ret = gcm_session_device_reset_gamma (output, - state->color_temperature, - &error); - if (!ret) { - g_warning ("failed to reset %s gamma tables: %s", - cd_device_get_id (helper->device), - error->message); - g_error_free (error); - goto out; - } - } - if (gnome_rr_output_supports_color_transform (output)) { ret = gcm_set_csc_matrix (output, profile, @@ -793,18 +549,6 @@ gcm_session_device_assign_connect_cb (GObject *object, gdk_property_delete (state->gdk_window, gdk_atom_intern_static_string ("_ICC_PROFILE_IN_X_VERSION")); } - - /* reset, as we want linear profiles for profiling */ - ret = gcm_session_device_reset_gamma (output, - state->color_temperature, - &error); - if (!ret) { - g_warning ("failed to reset %s gamma tables: %s", - cd_device_get_id (device), - error->message); - g_error_free (error); - goto out; - } goto out; } |