mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-25 06:47:03 -04:00
color mgmt: bug fixes
This commit is contained in:
parent
10bf68b928
commit
1c0643d800
8 changed files with 30 additions and 11 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include <wlr/render/egl.h>
|
#include <wlr/render/egl.h>
|
||||||
#include <wlr/render/gles2.h>
|
#include <wlr/render/gles2.h>
|
||||||
#include <wlr/render/interface.h>
|
#include <wlr/render/interface.h>
|
||||||
|
#include <wlr/render/color.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/render/wlr_texture.h>
|
#include <wlr/render/wlr_texture.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
@ -81,6 +82,7 @@ struct wlr_gles2_renderer {
|
||||||
} shaders;
|
} shaders;
|
||||||
|
|
||||||
uint32_t viewport_width, viewport_height;
|
uint32_t viewport_width, viewport_height;
|
||||||
|
struct wlr_color_config *color;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_gles2_texture {
|
struct wlr_gles2_texture {
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ struct wlr_renderer_impl {
|
||||||
void (*end)(struct wlr_renderer *renderer);
|
void (*end)(struct wlr_renderer *renderer);
|
||||||
void (*clear)(struct wlr_renderer *renderer, const float color[static 4]);
|
void (*clear)(struct wlr_renderer *renderer, const float color[static 4]);
|
||||||
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
|
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
|
||||||
|
void (*color_config)(struct wlr_renderer *renderer, struct wlr_color_config *color);
|
||||||
bool (*render_subtexture_with_matrix)(struct wlr_renderer *renderer,
|
bool (*render_subtexture_with_matrix)(struct wlr_renderer *renderer,
|
||||||
struct wlr_texture *texture, const struct wlr_fbox *box,
|
struct wlr_texture *texture, const struct wlr_fbox *box,
|
||||||
const float matrix[static 9], float alpha);
|
const float matrix[static 9], float alpha);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ struct wlr_drm_format_set;
|
||||||
|
|
||||||
struct wlr_renderer {
|
struct wlr_renderer {
|
||||||
const struct wlr_renderer_impl *impl;
|
const struct wlr_renderer_impl *impl;
|
||||||
struct wlr_color_config *color;
|
|
||||||
|
|
||||||
bool rendering;
|
bool rendering;
|
||||||
|
|
||||||
|
|
@ -45,6 +44,10 @@ void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
|
||||||
* box.
|
* box.
|
||||||
*/
|
*/
|
||||||
void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box);
|
void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box);
|
||||||
|
/**
|
||||||
|
* Define an output color config for future renderering functions.
|
||||||
|
*/
|
||||||
|
void wlr_renderer_color_config(struct wlr_renderer *r, struct wlr_color_config *color);
|
||||||
/**
|
/**
|
||||||
* Renders the requested texture.
|
* Renders the requested texture.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,8 @@ struct wlr_output {
|
||||||
|
|
||||||
struct wl_listener display_destroy;
|
struct wl_listener display_destroy;
|
||||||
|
|
||||||
|
struct wlr_color_config *color;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,6 @@ static const char *color_describe(struct wlr_color_config *color) {
|
||||||
struct wlr_color_config *wlr_color_config_load(const char *icc_profile_path) {
|
struct wlr_color_config *wlr_color_config_load(const char *icc_profile_path) {
|
||||||
assert(icc_profile_path);
|
assert(icc_profile_path);
|
||||||
|
|
||||||
if(0 == strlen(icc_profile_path)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool can_access = access(icc_profile_path, F_OK) != -1;
|
bool can_access = access(icc_profile_path, F_OK) != -1;
|
||||||
if (!can_access) {
|
if (!can_access) {
|
||||||
wlr_log(WLR_ERROR, "Unable to access color profile '%s'", icc_profile_path);
|
wlr_log(WLR_ERROR, "Unable to access color profile '%s'", icc_profile_path);
|
||||||
|
|
@ -235,6 +231,7 @@ static void lcms_error_handler(cmsContext ctx, cmsUInt32Number code, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
void color_engine_setup(void) {
|
void color_engine_setup(void) {
|
||||||
|
if(luts.capacity == 0)
|
||||||
wlr_list_init(&luts);
|
wlr_list_init(&luts);
|
||||||
cmsSetLogErrorHandler(lcms_error_handler);
|
cmsSetLogErrorHandler(lcms_error_handler);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
|
||||||
renderer->viewport_width = width;
|
renderer->viewport_width = width;
|
||||||
renderer->viewport_height = height;
|
renderer->viewport_height = height;
|
||||||
|
|
||||||
|
renderer->color = NULL;
|
||||||
|
|
||||||
// enable transparency
|
// enable transparency
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
@ -93,6 +95,13 @@ static void gles2_scissor(struct wlr_renderer *wlr_renderer,
|
||||||
POP_GLES2_DEBUG;
|
POP_GLES2_DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gles2_color_config(struct wlr_renderer *wlr_renderer, struct wlr_color_config *color) {
|
||||||
|
struct wlr_gles2_renderer *renderer =
|
||||||
|
gles2_get_renderer_in_context(wlr_renderer);
|
||||||
|
|
||||||
|
renderer->color = color;
|
||||||
|
}
|
||||||
|
|
||||||
static bool gles2_render_subtexture_with_matrix(
|
static bool gles2_render_subtexture_with_matrix(
|
||||||
struct wlr_renderer *wlr_renderer, struct wlr_texture *wlr_texture,
|
struct wlr_renderer *wlr_renderer, struct wlr_texture *wlr_texture,
|
||||||
const struct wlr_fbox *box, const float matrix[static 9],
|
const struct wlr_fbox *box, const float matrix[static 9],
|
||||||
|
|
@ -164,7 +173,7 @@ static bool gles2_render_subtexture_with_matrix(
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
GLuint color_table = color_build_lut(wlr_texture->color, wlr_renderer->color);
|
GLuint color_table = color_build_lut(wlr_texture->color, renderer->color);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_3D, color_table);
|
glBindTexture(GL_TEXTURE_3D, color_table);
|
||||||
glUniform1i(shader->color_table, 1);
|
glUniform1i(shader->color_table, 1);
|
||||||
|
|
@ -192,7 +201,7 @@ static void gles2_render_quad_with_matrix(struct wlr_renderer *wlr_renderer,
|
||||||
wlr_matrix_transpose(transposition, matrix);
|
wlr_matrix_transpose(transposition, matrix);
|
||||||
|
|
||||||
float converted[4];
|
float converted[4];
|
||||||
color_convert(NULL, wlr_renderer->color, color, converted);
|
color_convert(NULL, renderer->color, color, converted);
|
||||||
|
|
||||||
PUSH_GLES2_DEBUG;
|
PUSH_GLES2_DEBUG;
|
||||||
glUseProgram(renderer->shaders.quad.program);
|
glUseProgram(renderer->shaders.quad.program);
|
||||||
|
|
@ -230,7 +239,7 @@ static void gles2_render_ellipse_with_matrix(struct wlr_renderer *wlr_renderer,
|
||||||
};
|
};
|
||||||
|
|
||||||
float converted[4];
|
float converted[4];
|
||||||
color_convert(NULL, wlr_renderer->color, color, converted);
|
color_convert(NULL, renderer->color, color, converted);
|
||||||
|
|
||||||
PUSH_GLES2_DEBUG;
|
PUSH_GLES2_DEBUG;
|
||||||
glUseProgram(renderer->shaders.ellipse.program);
|
glUseProgram(renderer->shaders.ellipse.program);
|
||||||
|
|
@ -538,6 +547,7 @@ static const struct wlr_renderer_impl renderer_impl = {
|
||||||
.end = gles2_end,
|
.end = gles2_end,
|
||||||
.clear = gles2_clear,
|
.clear = gles2_clear,
|
||||||
.scissor = gles2_scissor,
|
.scissor = gles2_scissor,
|
||||||
|
.color_config = gles2_color_config,
|
||||||
.render_subtexture_with_matrix = gles2_render_subtexture_with_matrix,
|
.render_subtexture_with_matrix = gles2_render_subtexture_with_matrix,
|
||||||
.render_quad_with_matrix = gles2_render_quad_with_matrix,
|
.render_quad_with_matrix = gles2_render_quad_with_matrix,
|
||||||
.render_ellipse_with_matrix = gles2_render_ellipse_with_matrix,
|
.render_ellipse_with_matrix = gles2_render_ellipse_with_matrix,
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ void wlr_renderer_destroy(struct wlr_renderer *r) {
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&r->events.destroy, r);
|
wlr_signal_emit_safe(&r->events.destroy, r);
|
||||||
|
|
||||||
wlr_color_config_free(r->color);
|
|
||||||
|
|
||||||
if (r->impl && r->impl->destroy) {
|
if (r->impl && r->impl->destroy) {
|
||||||
r->impl->destroy(r);
|
r->impl->destroy(r);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -67,6 +65,11 @@ void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) {
|
||||||
r->impl->scissor(r, box);
|
r->impl->scissor(r, box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_renderer_color_config(struct wlr_renderer *r, struct wlr_color_config *color) {
|
||||||
|
assert(r->rendering);
|
||||||
|
r->impl->color_config(r, color);
|
||||||
|
}
|
||||||
|
|
||||||
bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
|
bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
|
||||||
const float projection[static 9], int x, int y, float alpha) {
|
const float projection[static 9], int x, int y, float alpha) {
|
||||||
struct wlr_box box = { .x = x, .y = y };
|
struct wlr_box box = { .x = x, .y = y };
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,7 @@ void wlr_output_destroy(struct wlr_output *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
free(output->description);
|
free(output->description);
|
||||||
|
wlr_color_config_free(output->color);
|
||||||
|
|
||||||
pixman_region32_fini(&output->pending.damage);
|
pixman_region32_fini(&output->pending.damage);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue