color management

This commit is contained in:
Devin Bayer 2020-07-14 17:01:25 +00:00
parent 842df2bd6c
commit 10bf68b928
13 changed files with 401 additions and 59 deletions

View file

@ -33,6 +33,7 @@ struct wlr_gles2_pixel_format {
};
struct wlr_gles2_tex_shader {
// attribute locations
GLuint program;
GLint proj;
GLint invert_y;
@ -40,6 +41,11 @@ struct wlr_gles2_tex_shader {
GLint alpha;
GLint pos_attrib;
GLint tex_attrib;
GLuint color_table;
GLint color_enable;
// source components
const GLchar *head, *util, *main;
};
struct wlr_gles2_renderer {
@ -110,4 +116,20 @@ void pop_gles2_marker(void);
#define PUSH_GLES2_DEBUG push_gles2_marker(_WLR_FILENAME, __func__)
#define POP_GLES2_DEBUG pop_gles2_marker()
// color engine
void color_engine_setup(void);
GLuint color_build_lut(struct wlr_color_config *input, struct wlr_color_config *output);
void color_convert(struct wlr_color_config *ic, struct wlr_color_config *oc, const float input[static 4], float output[static 4]);
#define COLOR_LUT_SIZE 64
/**
* Ignore half a texel near every edge because those
* areas are not interpolated. See GPU Gems 2, Ch. 24 for details.
*
* offset = (0.5 / COLOR_LUT_SIZE)
*/
#define COLOR_OFFSET "0.007813"
#endif

View file

@ -0,0 +1,19 @@
#ifndef _WLR_COLOR_H
#define _WLR_COLOR_H
struct wlr_color_config {
char *icc_profile_path; // not null
};
/**
* Create a color config.
*
* icc_profile_path should not be NULL.
* It will be copied into the config.
*/
struct wlr_color_config *wlr_color_config_load(const char *icc_profile_path);
struct wlr_color_config *wlr_color_config_copy(struct wlr_color_config *value);
void wlr_color_config_free(struct wlr_color_config *config);
#endif

View file

@ -24,6 +24,7 @@ struct wlr_drm_format_set;
struct wlr_renderer {
const struct wlr_renderer_impl *impl;
struct wlr_color_config *color;
bool rendering;

View file

@ -12,12 +12,16 @@
#include <stdint.h>
#include <wayland-server-protocol.h>
#include <wlr/render/dmabuf.h>
#include <wlr/render/color.h>
struct wlr_renderer;
struct wlr_texture_impl;
struct wlr_texture {
const struct wlr_texture_impl *impl;
struct wlr_color_config *color;
struct wlr_texture *colored;
uint32_t width, height;
};

View file

@ -128,6 +128,8 @@ struct wlr_surface {
struct wl_listener renderer_destroy;
struct wlr_color_config *color;
void *data;
};