Merge branch 'color-management' into 'master'

Draft: Add support for ICC profiles for outputs

See merge request wlroots/wlroots!3804
This commit is contained in:
Simon Ser 2023-02-02 18:28:31 +00:00
commit dadcf64584
15 changed files with 320 additions and 83 deletions

View file

@ -22,6 +22,13 @@ struct wlr_gles2_pixel_format {
bool has_alpha;
};
struct wlr_gles2_quad_shader {
GLuint program;
GLint proj;
GLint color;
GLint pos_attrib;
};
struct wlr_gles2_tex_shader {
GLuint program;
GLint proj;
@ -57,15 +64,11 @@ struct wlr_gles2_renderer {
PFNGLPUSHDEBUGGROUPKHRPROC glPushDebugGroupKHR;
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES;
PFNGLGETGRAPHICSRESETSTATUSKHRPROC glGetGraphicsResetStatusKHR;
PFNGLTEXIMAGE3DOESPROC glTexImage3DOES;
} procs;
struct {
struct {
GLuint program;
GLint proj;
GLint color;
GLint pos_attrib;
} quad;
struct wlr_gles2_quad_shader quad;
struct wlr_gles2_tex_shader tex_rgba;
struct wlr_gles2_tex_shader tex_rgbx;
struct wlr_gles2_tex_shader tex_ext;
@ -112,6 +115,22 @@ struct wlr_gles2_texture {
struct wlr_addon buffer_addon;
};
enum wlr_gles2_shader_source {
WLR_GLES2_SHADER_SOURCE_SINGLE_COLOR = 1,
WLR_GLES2_SHADER_SOURCE_TEXTURE_RGBA = 2,
WLR_GLES2_SHADER_SOURCE_TEXTURE_RGBX = 3,
WLR_GLES2_SHADER_SOURCE_TEXTURE_EXTERNAL = 4,
};
enum wlr_gles2_shader_color_transform {
WLR_GLES2_SHADER_COLOR_TRANSFORM_IDENTITY = 0,
WLR_GLES2_SHADER_COLOR_TRANSFORM_LUT_3D = 1,
};
struct wlr_gles2_shader_params {
enum wlr_gles2_shader_source source;
enum wlr_gles2_shader_color_transform color_transform;
};
bool is_gles2_pixel_format_supported(const struct wlr_gles2_renderer *renderer,
const struct wlr_gles2_pixel_format *format);

View file

@ -0,0 +1,44 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_RENDER_COLOR_H
#define WLR_RENDER_COLOR_H
#include <stdbool.h>
#include <sys/types.h>
/**
* A color transformation formula.
*
* The formula is approximated via a 3D look-up table. A 3D LUT is a
* three-dimensional array where each element is an RGB triplet. The flat lut_3d
* array has a length of dim_len³.
*
* Color channel values in the range [0.0, 1.0] are mapped linearly to
* 3D LUT indices such that 0.0 maps exactly to the first element and 1.0 maps
* exactly to the last element in each dimension.
*
* The offset of the RGB triplet given red, green and blue indices r_index,
* g_index and b_index is:
*
* offset = 3 * (r_index + dim_len * g_index + dim_len * dim_len * b_index)
*/
struct wlr_color_transform {
float *lut_3d;
size_t dim_len;
};
/**
* Initialize a color transformation to convert sRGB to an ICC profile.
*/
bool wlr_color_transform_init_srgb_to_icc(struct wlr_color_transform *tr,
const void *data, size_t size);
void wlr_color_transform_finish(struct wlr_color_transform *tr);
#endif