From 23a530cb09b4ac65bd904787b0eafa9022e62ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 14 Jun 2021 18:01:21 +0200 Subject: [PATCH] monitor-manager/native: Get CRTC gamma from cache if available Right now gamma is set only via the D-Bus API (from gsd-color), but the actual gamma isn't right after SetCrtcGamma(), meaning if one would call GetCrtcGamma() right after setting it, one would get the old result. Avoid this by getting the "current" CRTC gamma from the cache we manage. Part-of: --- .../native/meta-monitor-manager-native.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-monitor-manager-native.c b/src/backends/native/meta-monitor-manager-native.c index 10ac0810e..0fa4b02e0 100644 --- a/src/backends/native/meta-monitor-manager-native.c +++ b/src/backends/native/meta-monitor-manager-native.c @@ -379,12 +379,28 @@ meta_monitor_manager_native_get_crtc_gamma (MetaMonitorManager *manager, unsigned short **green, unsigned short **blue) { + MetaMonitorManagerNative *manager_native = + META_MONITOR_MANAGER_NATIVE (manager); + MetaCrtcKms *crtc_kms = META_CRTC_KMS (crtc); + MetaKmsCrtcGamma *crtc_gamma; MetaKmsCrtc *kms_crtc; const MetaKmsCrtcState *crtc_state; g_return_if_fail (META_IS_CRTC_KMS (crtc)); - kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (crtc)); + crtc_gamma = + meta_monitor_manager_native_get_cached_crtc_gamma (manager_native, + crtc_kms); + if (crtc_gamma) + { + *size = crtc_gamma->size; + *red = g_memdup2 (crtc_gamma->red, *size * sizeof **red); + *green = g_memdup2 (crtc_gamma->green, *size * sizeof **green); + *blue = g_memdup2 (crtc_gamma->blue, *size * sizeof **blue); + return; + } + + kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms); crtc_state = meta_kms_crtc_get_current_state (kms_crtc); *size = crtc_state->gamma.size;