diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index 4af89c5258..89cc3684ce 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -2940,10 +2940,15 @@ static inline void apply_color_matrix_op (const Program *program, const OpColorMatrix *op) { - float mat[16]; - OP_PRINT (" -> Color Matrix"); - graphene_matrix_to_float (op->matrix, mat); - glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat); + OP_PRINT (" -> Color matrix. Send matrix: %d. Send offset: %d.", + op->matrix.send, op->offset.send); + + if (op->matrix.send) + { + float mat[16]; + graphene_matrix_to_float (op->matrix.value, mat); + glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat); + } if (op->offset.send) { diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c index be7eff6fba..d7639162ad 100644 --- a/gsk/gl/gskglrenderops.c +++ b/gsk/gl/gskglrenderops.c @@ -533,30 +533,30 @@ ops_set_color_matrix (RenderOpBuilder *builder, const graphene_vec4_t *offset) { ProgramState *current_program_state = get_current_program_state (builder); + const bool offset_equal = graphene_vec4_equal (offset, ¤t_program_state->color_matrix.offset); + const bool matrix_equal = graphene_matrix_equal_fast (matrix, + ¤t_program_state->color_matrix.matrix); 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 && - offset_equal) + if (offset_equal && matrix_equal) return; - current_program_state->color_matrix.matrix = *matrix; - op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX); - op->matrix = matrix; + + if (!matrix_equal) + { + current_program_state->color_matrix.matrix = *matrix; + op->matrix.value = matrix; + op->matrix.send = TRUE; + } + else + op->matrix.send = FALSE; if (!offset_equal) { + current_program_state->color_matrix.offset = *offset; op->offset.value = offset; op->offset.send = TRUE; - - current_program_state->color_matrix.offset = *offset; } else op->offset.send = FALSE; diff --git a/gsk/gl/opbuffer.h b/gsk/gl/opbuffer.h index 08f48b7c5f..db9b5c9425 100644 --- a/gsk/gl/opbuffer.h +++ b/gsk/gl/opbuffer.h @@ -53,6 +53,7 @@ typedef struct { GskRoundedRect value; guint send: 1; guint send_corners: 1; } R typedef struct { const GdkRGBA *value; guint send: 1; } RGBAUniformValue; typedef struct { const graphene_vec4_t *value; guint send: 1; } Vec4UniformValue; typedef struct { const GskColorStop *value; guint send: 1; } ColorStopUniformValue; +typedef struct { const graphene_matrix_t *value; guint send: 1; } MatrixUniformValue; /* OpNode are allocated within OpBuffer.pos, but we keep * a secondary index into the locations of that buffer @@ -167,7 +168,7 @@ typedef struct typedef struct { - const graphene_matrix_t *matrix; + MatrixUniformValue matrix; Vec4UniformValue offset; } OpColorMatrix;