[gtk+/wip/baedert/gl: 180/216] gl renderer: Keep track of color matrix op state
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/gl: 180/216] gl renderer: Keep track of color matrix op state
- Date: Mon, 18 Dec 2017 21:00:17 +0000 (UTC)
commit b9d397de323e353adc7a8985312695bb25e9331b
Author: Timm Bäder <mail baedert org>
Date: Sun Dec 3 19:15:33 2017 +0100
gl renderer: Keep track of color matrix op state
gsk/gl/gskglrenderer.c | 9 +++----
gsk/gl/gskglrenderops.c | 24 +++++++++++++++++++++
gsk/gl/gskglrenderopsprivate.h | 44 +++++++++++++++++++++++----------------
3 files changed, 54 insertions(+), 23 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 5f8fe95..313d730 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -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);
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index 3c97d94..517ce85 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -248,6 +248,30 @@ ops_set_color (RenderOpBuilder *builder,
}
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])
{
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index 087bf1d..2245fd3 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -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]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]