From 5a9b54df96c0e2c0116a210fa6d8c61989babd22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 24 Jul 2020 17:29:22 +0200 Subject: [PATCH] gl renderer: More color matrix state tracking --- gsk/gl/gskglrenderer.c | 9 ++++++--- gsk/gl/gskglrenderops.c | 21 ++++++++++++++++----- gsk/gl/opbuffer.h | 3 ++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index 78242df74f..219ea96636 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -2585,13 +2585,16 @@ apply_color_matrix_op (const Program *program, const OpColorMatrix *op) { float mat[16]; - float vec[4]; OP_PRINT (" -> Color Matrix"); graphene_matrix_to_float (op->matrix, mat); glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat); - graphene_vec4_to_float (op->offset, vec); - glUniform4fv (program->color_matrix.color_offset_location, 1, vec); + if (op->offset.send) + { + float vec[4]; + graphene_vec4_to_float (op->offset.value, vec); + glUniform4fv (program->color_matrix.color_offset_location, 1, vec); + } } static inline void diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c index f710041cef..bcee21a659 100644 --- a/gsk/gl/gskglrenderops.c +++ b/gsk/gl/gskglrenderops.c @@ -618,21 +618,32 @@ ops_set_color_matrix (RenderOpBuilder *builder, { ProgramState *current_program_state = get_current_program_state (builder); OpColorMatrix *op; + bool offset_equal; + + offset_equal = memcmp (offset, + ¤t_program_state->color_matrix.offset, + sizeof (graphene_vec4_t)) == 0; if (memcmp (matrix, ¤t_program_state->color_matrix.matrix, sizeof (graphene_matrix_t)) == 0 && - memcmp (offset, - ¤t_program_state->color_matrix.offset, - sizeof (graphene_vec4_t)) == 0) + offset_equal) return; current_program_state->color_matrix.matrix = *matrix; - current_program_state->color_matrix.offset = *offset; op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX); op->matrix = matrix; - op->offset = offset; + + if (!offset_equal) + { + op->offset.value = offset; + op->offset.send = TRUE; + + current_program_state->color_matrix.offset = *offset; + } + else + op->offset.send = FALSE; } void diff --git a/gsk/gl/opbuffer.h b/gsk/gl/opbuffer.h index 76609c82a1..8637d79657 100644 --- a/gsk/gl/opbuffer.h +++ b/gsk/gl/opbuffer.h @@ -46,6 +46,7 @@ typedef struct { float value; guint send: 1; } FloatUniformValue; typedef struct { float value[2]; guint send: 1; } Float2UniformValue; typedef struct { GskRoundedRect value; guint send: 1; guint send_corners: 1; } RRUniformValue; typedef struct { const GdkRGBA *value; guint send: 1; } RGBAUniformValue; +typedef struct { const graphene_vec4_t *value; guint send: 1; } Vec4UniformValue; /* OpNode are allocated within OpBuffer.pos, but we keep * a secondary index into the locations of that buffer @@ -137,7 +138,7 @@ typedef struct typedef struct { const graphene_matrix_t *matrix; - const graphene_vec4_t *offset; + Vec4UniformValue offset; } OpColorMatrix; typedef struct