[gtk+/wip/baedert/gl: 43/85] gl renderer: Implement color matrix nodes again



commit c278de221a3aa9c6611aa1a5c11a4edcf70d5527
Author: Timm Bäder <mail baedert org>
Date:   Fri Nov 24 10:32:08 2017 +0100

    gl renderer: Implement color matrix nodes again

 gsk/gl/gskglrenderer.c         |   44 ++++++++++++++++++++++++++++++++++++---
 gsk/gl/gskglrenderopsprivate.h |   10 ++++++--
 2 files changed, 47 insertions(+), 7 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index ccbc659..d3b0273 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -912,6 +912,34 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer   *self,
       }
     break;
 
+    case GSK_COLOR_MATRIX_NODE:
+      {
+        int texture_id;
+        RenderOp op;
+        GskQuadVertex vertex_data[GL_N_VERTICES] = {
+          { { min_x, min_y }, { 0, 1 }, },
+          { { min_x, max_y }, { 0, 0 }, },
+          { { max_x, min_y }, { 1, 1 }, },
+
+          { { max_x, max_y }, { 1, 0 }, },
+          { { min_x, max_y }, { 0, 0 }, },
+          { { max_x, min_y }, { 1, 1 }, },
+        };
+
+        texture_id = add_offscreen_ops (self, builder, min_x, max_x, min_y, max_y,
+                                        gsk_color_matrix_node_get_child (node));
+
+        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_texture (builder, texture_id);
+        ops_draw (builder, vertex_data);
+      }
+    break;
+
     case GSK_REPEATING_LINEAR_GRADIENT_NODE:
     case GSK_BORDER_NODE:
     case GSK_INSET_SHADOW_NODE:
@@ -921,7 +949,6 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer   *self,
     case GSK_CROSS_FADE_NODE:
     case GSK_BLEND_NODE:
     case GSK_REPEAT_NODE:
-    case GSK_COLOR_MATRIX_NODE:
     default:
       {
         cairo_surface_t *surface;
@@ -1017,15 +1044,14 @@ add_offscreen_ops (GskGLRenderer   *self,
   return texture_id;
 }
 
-
-
 static void
 gsk_gl_renderer_render_ops (GskGLRenderer *self,
                             gsize          vertex_data_size)
 {
+  float mat[16];
+  float vec[4];
   guint i;
   guint n_ops = self->render_ops->len;
-  float mat[16];
   const Program *program = NULL;
   gsize buffer_index = 0;
   float *vertex_data = g_malloc (vertex_data_size);
@@ -1131,6 +1157,16 @@ gsk_gl_renderer_render_ops (GskGLRenderer *self,
           glUniform1f (program->alpha_location, op->opacity);
           break;
 
+        case OP_CHANGE_COLOR_MATRIX:
+          OP_PRINT (" -> Color Matrix");
+          g_assert (program == &self->color_matrix_program);
+          graphene_matrix_to_float (&op->color_matrix.matrix, mat);
+          glUniformMatrix4fv (program->color_matrix_location, 1, GL_FALSE, mat);
+
+          graphene_vec4_to_float (&op->color_matrix.offset, vec);
+          glUniform4fv (program->color_offset_location, 1, vec);
+          break;
+
         case OP_CHANGE_COLOR:
           OP_PRINT (" -> Color: (%f, %f, %f, %f)", op->color.red, op->color.green, op->color.blue, 
op->color.alpha);
           g_assert (program == &self->color_program || program == &self->coloring_program);
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index 12d68b2..85a19ec 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -25,8 +25,9 @@ enum {
   OP_CHANGE_SOURCE_TEXTURE  =  9,
   OP_CHANGE_VAO             =  10,
   OP_CHANGE_LINEAR_GRADIENT =  11,
-  OP_CLEAR                  =  12,
-  OP_DRAW                   =  13,
+  OP_CHANGE_COLOR_MATRIX    =  12,
+  OP_CLEAR                  =  13,
+  OP_DRAW                   =  14,
 };
 
 typedef struct
@@ -99,7 +100,10 @@ typedef struct
       gsize vao_offset;
       gsize vao_size;
     } draw;
-
+    struct {
+      graphene_matrix_t matrix;
+      graphene_vec4_t offset;
+    } color_matrix;
   };
 } RenderOp;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]