monitor: Add API to set GAMMA LUT
It's effectively a for-each for every active CRTC of the monitor. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
This commit is contained in:
parent
c6c3f340ec
commit
f8dbea27f8
@ -466,4 +466,11 @@ void meta_monitor_manager_get_crtc_gamma (MetaMonitorManager *manager,
|
||||
unsigned short **green,
|
||||
unsigned short **blue);
|
||||
|
||||
void meta_monitor_manager_set_crtc_gamma (MetaMonitorManager *manager,
|
||||
MetaCrtc *crtc,
|
||||
size_t size,
|
||||
unsigned short *red,
|
||||
unsigned short *green,
|
||||
unsigned short *blue);
|
||||
|
||||
#endif /* META_MONITOR_MANAGER_PRIVATE_H */
|
||||
|
@ -3971,3 +3971,17 @@ meta_monitor_manager_get_virtual_monitors (MetaMonitorManager *manager)
|
||||
|
||||
return priv->virtual_monitors;
|
||||
}
|
||||
|
||||
void
|
||||
meta_monitor_manager_set_crtc_gamma (MetaMonitorManager *manager,
|
||||
MetaCrtc *crtc,
|
||||
size_t size,
|
||||
unsigned short *red,
|
||||
unsigned short *green,
|
||||
unsigned short *blue)
|
||||
{
|
||||
MetaMonitorManagerClass *manager_class =
|
||||
META_MONITOR_MANAGER_GET_CLASS (manager);
|
||||
|
||||
manager_class->set_crtc_gamma (manager, crtc, size, red, green, blue);
|
||||
}
|
||||
|
@ -648,6 +648,69 @@ meta_monitor_get_gamma_lut_size (MetaMonitor *monitor)
|
||||
return size;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t *red;
|
||||
uint16_t *green;
|
||||
uint16_t *blue;
|
||||
size_t size;
|
||||
} LutData;
|
||||
|
||||
static gboolean
|
||||
set_gamma_lut (MetaMonitor *monitor,
|
||||
MetaMonitorMode *mode,
|
||||
MetaMonitorCrtcMode *monitor_crtc_mode,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
LutData *lut_data = user_data;
|
||||
MetaBackend *backend = meta_monitor_get_backend (monitor);
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaCrtc *crtc;
|
||||
|
||||
crtc = meta_output_get_assigned_crtc (monitor_crtc_mode->output);
|
||||
|
||||
meta_monitor_manager_set_crtc_gamma (monitor_manager,
|
||||
crtc,
|
||||
lut_data->size,
|
||||
lut_data->red,
|
||||
lut_data->green,
|
||||
lut_data->blue);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_monitor_set_gamma_lut:
|
||||
*
|
||||
* Set a new gamma look-up table (LUT) for the given monitor's CRTCs.
|
||||
*/
|
||||
void
|
||||
meta_monitor_set_gamma_lut (MetaMonitor *monitor,
|
||||
uint16_t *red,
|
||||
uint16_t *green,
|
||||
uint16_t *blue,
|
||||
size_t size)
|
||||
{
|
||||
MetaMonitorMode *current_mode;
|
||||
LutData lut_data;
|
||||
|
||||
current_mode = meta_monitor_get_current_mode (monitor);
|
||||
g_return_if_fail (current_mode);
|
||||
|
||||
lut_data = (LutData) {
|
||||
.red = red,
|
||||
.green = green,
|
||||
.blue = blue,
|
||||
.size = size,
|
||||
};
|
||||
meta_monitor_mode_foreach_crtc (monitor,
|
||||
current_mode,
|
||||
set_gamma_lut,
|
||||
&lut_data,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
|
||||
{
|
||||
|
@ -297,4 +297,10 @@ gboolean meta_monitor_set_privacy_screen_enabled (MetaMonitor *monitor,
|
||||
|
||||
size_t meta_monitor_get_gamma_lut_size (MetaMonitor *monitor);
|
||||
|
||||
void meta_monitor_set_gamma_lut (MetaMonitor *monitor,
|
||||
uint16_t *red,
|
||||
uint16_t *green,
|
||||
uint16_t *blue,
|
||||
size_t size);
|
||||
|
||||
#endif /* META_MONITOR_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user