diff --git a/src/backends/meta-color-device.c b/src/backends/meta-color-device.c index a935723ff..5192a7b1f 100644 --- a/src/backends/meta-color-device.c +++ b/src/backends/meta-color-device.c @@ -1085,3 +1085,36 @@ meta_color_device_get_assigned_profile (MetaColorDevice *color_device) { return color_device->assigned_profile; } + +void +meta_color_device_update_gamma (MetaColorDevice *color_device, + unsigned int temperature) +{ + MetaColorProfile *color_profile; + MetaMonitor *monitor; + size_t lut_size; + g_autoptr (MetaGammaLut) lut = NULL; + + color_profile = meta_color_device_get_assigned_profile (color_device); + if (!color_profile) + return; + + monitor = color_device->monitor; + if (!meta_monitor_is_active (monitor)) + return; + + meta_topic (META_DEBUG_COLOR, + "Updating device '%s' (%s) using color profile '%s' " + "and temperature %uK", + meta_color_device_get_id (color_device), + meta_monitor_get_connector (monitor), + meta_color_profile_get_id (color_profile), + temperature); + + lut_size = meta_monitor_get_gamma_lut_size (monitor); + lut = meta_color_profile_generate_gamma_lut (color_profile, + temperature, + lut_size); + + meta_monitor_set_gamma_lut (monitor, lut); +} diff --git a/src/backends/meta-color-device.h b/src/backends/meta-color-device.h index 6f03750ff..450513e51 100644 --- a/src/backends/meta-color-device.h +++ b/src/backends/meta-color-device.h @@ -62,4 +62,7 @@ MetaColorProfile * meta_color_device_generate_profile_finish (MetaColorDevice * META_EXPORT_TEST gboolean meta_color_device_is_ready (MetaColorDevice *color_device); +void meta_color_device_update_gamma (MetaColorDevice *color_device, + unsigned int temperature); + #endif /* META_COLOR_DEVICE_H */