From bcd9f4c69103d766e3dcd8ffa10b5880ea5110bf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 14 Jul 2026 21:07:04 +0200 Subject: kms capture: make capture work with night lights enabled --- include/color_conversion.h | 7 +++++++ include/egl.h | 1 + include/kde_night_light.h | 13 +++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 include/kde_night_light.h (limited to 'include') diff --git a/include/color_conversion.h b/include/color_conversion.h index 7950472..251fe17 100644 --- a/include/color_conversion.h +++ b/include/color_conversion.h @@ -41,6 +41,8 @@ typedef struct { int hdr_sdr_white_pq; int hdr_sdr_white_scale; int gamma_lut_enabled; + int night_light_transfer; + int night_light_matrix; } gsr_color_graphics_uniforms; typedef struct { @@ -73,6 +75,8 @@ typedef struct { float hdr_sdr_white_scale; unsigned int gamma_lut_texture_id; bool gamma_lut_apply; + int night_light_transfer; + float night_light_matrix[9]; bool hdr_shaders_loaded; bool hdr_shaders_load_failed; } gsr_color_conversion; @@ -85,6 +89,9 @@ void gsr_color_conversion_clear(gsr_color_conversion *self); void gsr_color_conversion_set_hdr_to_sdr_tone_mapping(gsr_color_conversion *self, bool enable, float hdr_peak_luminance, float sdr_white_luminance); void gsr_color_conversion_set_gamma_lut(gsr_color_conversion *self, const float *rgb_values, int num_entries); void gsr_color_conversion_enable_gamma_lut(gsr_color_conversion *self, bool enable); +/* |inverse_matrix| is a row major 3x3 matrix that is applied to linear rgb values in the draw functions, for RGB/BGR sources. NULL to disable. + |pq_color_transfer| chooses the transfer characteristics used to decode/encode the source image around the matrix multiply (pq or gamma 2.2) */ +void gsr_color_conversion_set_night_light_matrix(gsr_color_conversion *self, const float *inverse_matrix, bool pq_color_transfer); void gsr_color_conversion_read_destination_texture(gsr_color_conversion *self, int destination_texture_index, int x, int y, int width, int height, unsigned int color_format, unsigned int data_format, void *pixels); gsr_rotation gsr_monitor_rotation_to_rotation(gsr_monitor_rotation monitor_rotation); diff --git a/include/egl.h b/include/egl.h index c9c54e5..c8dcd2b 100644 --- a/include/egl.h +++ b/include/egl.h @@ -311,6 +311,7 @@ struct gsr_egl { void (*glUniform1i)(int location, int v0); void (*glUniform2i)(int location, int v0, int v1); void (*glUniformMatrix2fv)(int location, int count, unsigned char transpose, const float *value); + void (*glUniformMatrix3fv)(int location, int count, unsigned char transpose, const float *value); void (*glDebugMessageCallback)(GLDEBUGPROC callback, const void *userParam); void (*glScissor)(int x, int y, int width, int height); void (*glCreateBuffers)(int n, unsigned int *buffers); diff --git a/include/kde_night_light.h b/include/kde_night_light.h new file mode 100644 index 0000000..ed12f1d --- /dev/null +++ b/include/kde_night_light.h @@ -0,0 +1,13 @@ +#ifndef GSR_KDE_NIGHT_LIGHT_H +#define GSR_KDE_NIGHT_LIGHT_H + +#include + +typedef struct gsr_kde_night_light gsr_kde_night_light; + +gsr_kde_night_light* gsr_kde_night_light_create(void); +void gsr_kde_night_light_destroy(gsr_kde_night_light *self); +/* Returns true when night light is active. |inverse_matrix| is filled with the row major 3x3 matrix that removes the night light tint from linear rgb values */ +bool gsr_kde_night_light_get_inverse_matrix(gsr_kde_night_light *self, float inverse_matrix[9]); + +#endif /* GSR_KDE_NIGHT_LIGHT_H */ -- cgit v1.2.3