gl renderer: Keep track of color matrix op state

This commit is contained in:
Timm Bäder 2017-12-03 19:15:33 +01:00
parent b33d85b594
commit 9479bb6bfc
3 changed files with 54 additions and 23 deletions

View File

@ -1102,16 +1102,15 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
{
int texture_id;
gboolean is_offscreen;
RenderOp op;
add_offscreen_ops (self, builder, min_x, max_x, min_y, max_y,
gsk_color_matrix_node_get_child (node),
&texture_id, &is_offscreen);
ops_set_program (builder, &self->color_matrix_program);
op.op = OP_CHANGE_COLOR_MATRIX;
op.color_matrix.matrix = *gsk_color_matrix_node_peek_color_matrix (node);
op.color_matrix.offset = *gsk_color_matrix_node_peek_color_offset (node);
ops_add (builder, &op);
ops_set_color_matrix (builder,
gsk_color_matrix_node_peek_color_matrix (node),
gsk_color_matrix_node_peek_color_offset (node));
ops_set_texture (builder, texture_id);

View File

@ -247,6 +247,30 @@ ops_set_color (RenderOpBuilder *builder,
g_array_append_val (builder->render_ops, op);
}
void
ops_set_color_matrix (RenderOpBuilder *builder,
const graphene_matrix_t *matrix,
const graphene_vec4_t *offset)
{
RenderOp op;
if (memcmp (matrix,
&builder->program_state[builder->current_program->index].color_matrix.matrix,
sizeof (graphene_matrix_t)) == 0 &&
memcmp (offset,
&builder->program_state[builder->current_program->index].color_matrix.offset,
sizeof (graphene_vec4_t)) == 0)
return;
builder->program_state[builder->current_program->index].color_matrix.matrix = *matrix;
builder->program_state[builder->current_program->index].color_matrix.offset = *offset;
op.op = OP_CHANGE_COLOR_MATRIX;
op.color_matrix.matrix = *matrix;
op.color_matrix.offset = *offset;
g_array_append_val (builder->render_ops, op);
}
void
ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES])

View File

@ -175,6 +175,10 @@ typedef struct
/* Per-program state */
union {
GdkRGBA color;
struct {
graphene_matrix_t matrix;
graphene_vec4_t offset;
} color_matrix;
};
} program_state[GL_N_PROGRAMS];
@ -197,31 +201,35 @@ typedef struct
void ops_set_program (RenderOpBuilder *builder,
const Program *program);
void ops_set_program (RenderOpBuilder *builder,
const Program *program);
GskRoundedRect ops_set_clip (RenderOpBuilder *builder,
const GskRoundedRect *clip);
GskRoundedRect ops_set_clip (RenderOpBuilder *builder,
const GskRoundedRect *clip);
graphene_matrix_t ops_set_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *modelview);
graphene_matrix_t ops_set_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *modelview);
graphene_matrix_t ops_set_projection (RenderOpBuilder *builder,
const graphene_matrix_t *projection);
graphene_matrix_t ops_set_projection (RenderOpBuilder *builder,
const graphene_matrix_t *projection);
graphene_rect_t ops_set_viewport (RenderOpBuilder *builder,
const graphene_rect_t *viewport);
graphene_rect_t ops_set_viewport (RenderOpBuilder *builder,
const graphene_rect_t *viewport);
void ops_set_texture (RenderOpBuilder *builder,
int texture_id);
void ops_set_texture (RenderOpBuilder *builder,
int texture_id);
int ops_set_render_target (RenderOpBuilder *builder,
int render_target_id);
int ops_set_render_target (RenderOpBuilder *builder,
int render_target_id);
float ops_set_opacity (RenderOpBuilder *builder,
float opacity);
void ops_set_color (RenderOpBuilder *builder,
const GdkRGBA *color);
float ops_set_opacity (RenderOpBuilder *builder,
float opacity);
void ops_set_color (RenderOpBuilder *builder,
const GdkRGBA *color);
void ops_set_color_matrix (RenderOpBuilder *builder,
const graphene_matrix_t *matrix,
const graphene_vec4_t *offset);
void ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES]);