[gtk/ngl-less-shaders: 3/13] ngl: Some cleanups




commit f0d98673f0ba2f6b6c7196ca48a295e9b6a87996
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 13 14:29:34 2021 -0500

    ngl: Some cleanups
    
    Drop gsk_ngl_render_job_set_color, since colors are
    not state that we carry across draw ops. Instead pass
    the color to the various draw calls. Add a few new
    ones for that purpose. Also, shorten the names of
    some by going from 'load_vertices_from_offscreen'
    to 'draw_offscreen'.

 gsk/ngl/gsknglrenderjob.c | 417 +++++++++++++++++++++++-----------------------
 1 file changed, 207 insertions(+), 210 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 94f56f63de..6b28515d66 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -142,9 +142,6 @@ struct _GskNglRenderJob
   /* Our current alpha state as we process nodes */
   float alpha;
 
-  /* Our current color state as we process nodes */
-  GdkRGBA color;
-
   /* Offset (delta x,y) as we process nodes. Occasionally this is merged into
    * a transform that is referenced from child transform nodes.
    */
@@ -398,13 +395,6 @@ gsk_ngl_render_job_set_alpha (GskNglRenderJob *job,
   return alpha;
 }
 
-static inline void
-gsk_ngl_render_job_set_color (GskNglRenderJob *job,
-                              const GdkRGBA   *color)
-{
-  job->color = *color;
-}
-
 static void
 extract_matrix_metadata (GskNglRenderModelview *modelview)
 {
@@ -894,70 +884,25 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
                                 float            min_u,
                                 float            min_v,
                                 float            max_u,
-                                float            max_v)
+                                float            max_v,
+                                const GdkRGBA   *color)
 {
   GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
 
-  vertices[0].position[0] = min_x;
-  vertices[0].position[1] = min_y;
-  vertices[0].uv[0] = min_u;
-  vertices[0].uv[1] = min_v;
-  vertices[0].color[0] = job->color.red;
-  vertices[0].color[1] = job->color.green;
-  vertices[0].color[2] = job->color.blue;
-  vertices[0].color[3] = job->color.alpha;
-
-  vertices[1].position[0] = min_x;
-  vertices[1].position[1] = max_y;
-  vertices[1].uv[0] = min_u;
-  vertices[1].uv[1] = max_v;
-  vertices[1].color[0] = job->color.red;
-  vertices[1].color[1] = job->color.green;
-  vertices[1].color[2] = job->color.blue;
-  vertices[1].color[3] = job->color.alpha;
-
-  vertices[2].position[0] = max_x;
-  vertices[2].position[1] = min_y;
-  vertices[2].uv[0] = max_u;
-  vertices[2].uv[1] = min_v;
-  vertices[2].color[0] = job->color.red;
-  vertices[2].color[1] = job->color.green;
-  vertices[2].color[2] = job->color.blue;
-  vertices[2].color[3] = job->color.alpha;
-
-  vertices[3].position[0] = max_x;
-  vertices[3].position[1] = max_y;
-  vertices[3].uv[0] = max_u;
-  vertices[3].uv[1] = max_v;
-  vertices[3].color[0] = job->color.red;
-  vertices[3].color[1] = job->color.green;
-  vertices[3].color[2] = job->color.blue;
-  vertices[3].color[3] = job->color.alpha;
-
-  vertices[4].position[0] = min_x;
-  vertices[4].position[1] = max_y;
-  vertices[4].uv[0] = min_u;
-  vertices[4].uv[1] = max_v;
-  vertices[4].color[0] = job->color.red;
-  vertices[4].color[1] = job->color.green;
-  vertices[4].color[2] = job->color.blue;
-  vertices[4].color[3] = job->color.alpha;
-
-  vertices[5].position[0] = max_x;
-  vertices[5].position[1] = min_y;
-  vertices[5].uv[0] = max_u;
-  vertices[5].uv[1] = min_v;
-  vertices[5].color[0] = job->color.red;
-  vertices[5].color[1] = job->color.green;
-  vertices[5].color[2] = job->color.blue;
-  vertices[5].color[3] = job->color.alpha;
+  vertices[0] = (GskNglDrawVertex) { { min_x, min_y }, { min_u, min_v }, { color->red, color->green, 
color->blue, color->alpha } };
+  vertices[1] = (GskNglDrawVertex) { { min_x, max_y }, { min_u, max_v }, { color->red, color->green, 
color->blue, color->alpha } };
+  vertices[2] = (GskNglDrawVertex) { { max_x, min_y }, { max_u, min_v }, { color->red, color->green, 
color->blue, color->alpha } };
+  vertices[3] = (GskNglDrawVertex) { { max_x, max_y }, { max_u, max_v }, { color->red, color->green, 
color->blue, color->alpha } };
+  vertices[4] = (GskNglDrawVertex) { { min_x, max_y }, { min_u, max_v }, { color->red, color->green, 
color->blue, color->alpha } };
+  vertices[5] = (GskNglDrawVertex) { { max_x, min_y }, { max_u, min_v }, { color->red, color->green, 
color->blue, color->alpha } };
 }
 
 /* load_vertex_data_with_region */
 static inline void
-gsk_ngl_render_job_load_vertices_from_offscreen (GskNglRenderJob             *job,
-                                                 const graphene_rect_t       *bounds,
-                                                 const GskNglRenderOffscreen *offscreen)
+gsk_ngl_render_job_draw_offscreen_with_color (GskNglRenderJob             *job,
+                                              const graphene_rect_t       *bounds,
+                                              const GskNglRenderOffscreen *offscreen,
+                                              const GdkRGBA               *color)
 {
   float min_x = job->offset_x + bounds->origin.x;
   float min_y = job->offset_y + bounds->origin.y;
@@ -968,27 +913,59 @@ gsk_ngl_render_job_load_vertices_from_offscreen (GskNglRenderJob             *jo
 
   gsk_ngl_render_job_draw_coords (job,
                                   min_x, min_y, max_x, max_y,
-                                  offscreen->area.x, y1, offscreen->area.x2, y2);
+                                  offscreen->area.x, y1, offscreen->area.x2, y2,
+                                  color);
+}
+
+static inline void
+gsk_ngl_render_job_draw_offscreen (GskNglRenderJob             *job,
+                                   const graphene_rect_t       *bounds,
+                                   const GskNglRenderOffscreen *offscreen)
+{
+  gsk_ngl_render_job_draw_offscreen_with_color (job, bounds, offscreen, &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
 }
 
 /* load_float_vertex_data */
 static inline void
-gsk_ngl_render_job_draw (GskNglRenderJob *job,
-                         float            x,
-                         float            y,
-                         float            width,
-                         float            height)
+gsk_ngl_render_job_draw_with_color (GskNglRenderJob *job,
+                                    float            x,
+                                    float            y,
+                                    float            width,
+                                    float            height,
+                                    const GdkRGBA   *color)
 {
   float min_x = job->offset_x + x;
   float min_y = job->offset_y + y;
   float max_x = min_x + width;
   float max_y = min_y + height;
 
-  gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 0, 1, 1);
+  gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 0, 1, 1, color);
+}
+
+static inline void
+gsk_ngl_render_job_draw (GskNglRenderJob *job,
+                         float            x,
+                         float            y,
+                         float            width,
+                         float            height)
+{
+  gsk_ngl_render_job_draw_with_color (job, x, y, width, height, &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
 }
 
 /* load_vertex_data */
 static inline void
+gsk_ngl_render_job_draw_rect_with_color (GskNglRenderJob       *job,
+                                         const graphene_rect_t *bounds,
+                                         const GdkRGBA         *color)
+{
+  gsk_ngl_render_job_draw_with_color (job,
+                                      bounds->origin.x,
+                                      bounds->origin.y,
+                                      bounds->size.width,
+                                      bounds->size.height,
+                                      color);
+}
+static inline void
 gsk_ngl_render_job_draw_rect (GskNglRenderJob       *job,
                               const graphene_rect_t *bounds)
 {
@@ -1009,7 +986,10 @@ gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob       *job,
   float max_x = min_x + bounds->size.width;
   float max_y = min_y + bounds->size.height;
 
-  gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 1, 1, 0);
+  gsk_ngl_render_job_draw_coords (job,
+                                  min_x, min_y, max_x, max_y,
+                                  0, 1, 1, 0,
+                                  &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f } );
 }
 
 static inline void
@@ -1265,7 +1245,10 @@ blur_offscreen (GskNglRenderJob       *job,
   gsk_ngl_program_set_uniform2f (job->current_program,
                                  UNIFORM_BLUR_DIR, 0,
                                  1, 0);
-  gsk_ngl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height, 0, 1, 1, 0);
+  gsk_ngl_render_job_draw_coords (job,
+                                  0, 0, texture_to_blur_width, texture_to_blur_height,
+                                  0, 1, 1, 0,
+                                  &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
   gsk_ngl_render_job_end_draw (job);
 
   /* Bind second pass framebuffer and clear it */
@@ -1289,7 +1272,10 @@ blur_offscreen (GskNglRenderJob       *job,
   gsk_ngl_program_set_uniform2f (job->current_program,
                                  UNIFORM_BLUR_DIR, 0,
                                  0, 1);
-  gsk_ngl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height, 0, 1, 1, 0);
+  gsk_ngl_render_job_draw_coords (job,
+                                  0, 0, texture_to_blur_width, texture_to_blur_height,
+                                  0, 1, 1, 0,
+                                  &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
   gsk_ngl_render_job_end_draw (job);
 
   gsk_ngl_render_job_pop_modelview (job);
@@ -1363,8 +1349,9 @@ gsk_ngl_render_job_visit_color_node (GskNglRenderJob     *job,
                                      const GskRenderNode *node)
 {
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
-  gsk_ngl_render_job_set_color (job, gsk_color_node_get_color (node));
-  gsk_ngl_render_job_draw_rect (job, &node->bounds);
+  gsk_ngl_render_job_draw_rect_with_color (job,
+                                           &node->bounds,
+                                           gsk_color_node_get_color (node));
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -1627,7 +1614,7 @@ gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob     *job,
                                            GL_TEXTURE_2D,
                                            GL_TEXTURE0,
                                            offscreen.texture_id);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
+      gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
       gsk_ngl_render_job_end_draw (job);
     }
 }
@@ -1674,31 +1661,25 @@ gsk_ngl_render_job_visit_rect_border_node (GskNglRenderJob     *job,
 
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
 
-  gsk_ngl_render_job_set_color (job, &colors[0]);
-
-  gsk_ngl_render_job_draw_rect (job,
-      &GRAPHENE_RECT_INIT (origin->x,
-                           origin->y,
-                           size->width - widths[1],
-                           widths[0]));
+  if (widths[0] > 0)
+    gsk_ngl_render_job_draw_rect_with_color (job,
+                                             &GRAPHENE_RECT_INIT (origin->x, origin->y, size->width - 
widths[1], widths[0]),
+                                             &colors[0]);
 
-  gsk_ngl_render_job_draw_rect (job,
-      &GRAPHENE_RECT_INIT (origin->x + size->width - widths[1],
-                           origin->y,
-                           widths[1],
-                           size->height - widths[2]));
+  if (widths[1] > 0)
+    gsk_ngl_render_job_draw_rect_with_color (job,
+                                             &GRAPHENE_RECT_INIT (origin->x + size->width - widths[1], 
origin->y, widths[1], size->height - widths[2]),
+                                             &colors[0]);
 
-  gsk_ngl_render_job_draw_rect (job,
-      &GRAPHENE_RECT_INIT (origin->x + widths[3],
-                           origin->y + size->height - widths[2],
-                           size->width - widths[1],
-                           widths[2]));
+  if (widths[2] > 0)
+    gsk_ngl_render_job_draw_rect_with_color (job,
+                                             &GRAPHENE_RECT_INIT (origin->x + widths[3], origin->y + 
size->height - widths[2], size->width - widths[1], widths[2]),
+                                             &colors[0]);
 
-  gsk_ngl_render_job_draw_rect (job,
-      &GRAPHENE_RECT_INIT (origin->x,
-                           origin->y + widths[0],
-                           widths[3],
-                           size->height - widths[0]));
+  if (widths[3] > 0)
+    gsk_ngl_render_job_draw_rect_with_color (job,
+                                             &GRAPHENE_RECT_INIT (origin->x, origin->y + widths[0], 
widths[3], size->height - widths[0]),
+                                             &colors[0]);
 
   gsk_ngl_render_job_end_draw (job);
 }
@@ -1715,7 +1696,6 @@ gsk_ngl_render_job_visit_uniform_border_node (GskNglRenderJob     *job,
   gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
 
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
-  gsk_ngl_render_job_set_color (job, &colors[0]);
   gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
                                             UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
                                             &outline);
@@ -1725,7 +1705,7 @@ gsk_ngl_render_job_visit_uniform_border_node (GskNglRenderJob     *job,
   gsk_ngl_program_set_uniform2f (job->current_program,
                                  UNIFORM_INSET_SHADOW_OFFSET, 0,
                                  0, 0);
-  gsk_ngl_render_job_draw_rect (job, &node->bounds);
+  gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, &colors[0]);
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -1939,7 +1919,7 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob     *job,
                                                    GL_TEXTURE_2D,
                                                    GL_TEXTURE0,
                                                    offscreen.texture_id);
-              gsk_ngl_render_job_load_vertices_from_offscreen (job, &child->bounds, &offscreen);
+              gsk_ngl_render_job_draw_offscreen (job, &child->bounds, &offscreen);
               gsk_ngl_render_job_end_draw (job);
 
               gsk_ngl_render_job_pop_modelview (job);
@@ -1962,7 +1942,6 @@ gsk_ngl_render_job_visit_unblurred_inset_shadow_node (GskNglRenderJob     *job,
   gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
 
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
-  gsk_ngl_render_job_set_color (job, gsk_inset_shadow_node_get_color (node));
   gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
                                             UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
                                             &transformed_outline);
@@ -1973,7 +1952,7 @@ gsk_ngl_render_job_visit_unblurred_inset_shadow_node (GskNglRenderJob     *job,
                                  UNIFORM_INSET_SHADOW_OFFSET, 0,
                                  gsk_inset_shadow_node_get_dx (node),
                                  gsk_inset_shadow_node_get_dy (node));
-  gsk_ngl_render_job_draw_rect (job, &node->bounds);
+  gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, gsk_inset_shadow_node_get_color (node));
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -2063,7 +2042,6 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob     *job,
 
       /* Actual inset shadow outline drawing */
       gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
-      gsk_ngl_render_job_set_color (job, gsk_inset_shadow_node_get_color (node));
       gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
                                                 UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
                                                 &transformed_outline);
@@ -2074,7 +2052,9 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob     *job,
                                      UNIFORM_INSET_SHADOW_OFFSET, 0,
                                      offset_x * scale_x,
                                      offset_y * scale_y);
-      gsk_ngl_render_job_draw (job, 0, 0, texture_width, texture_height);
+      gsk_ngl_render_job_draw_with_color (job,
+                                          0, 0, texture_width, texture_height,
+                                          gsk_inset_shadow_node_get_color (node));
       gsk_ngl_render_job_end_draw (job);
 
       gsk_ngl_render_job_pop_modelview (job);
@@ -2136,7 +2116,7 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob     *job,
                                          GL_TEXTURE_2D,
                                          GL_TEXTURE0,
                                          blurred_texture_id);
-    gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
+    gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
     gsk_ngl_render_job_end_draw (job);
 
     if (needs_clip)
@@ -2157,6 +2137,7 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob     *job,
   float spread = gsk_outset_shadow_node_get_spread (node);
   float dx = gsk_outset_shadow_node_get_dx (node);
   float dy = gsk_outset_shadow_node_get_dy (node);
+  const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
   const float edge_sizes[] = { // Top, right, bottom, left
     spread - dy, spread + dx, spread + dy, spread - dx
   };
@@ -2170,7 +2151,6 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob     *job,
   gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
 
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow));
-  gsk_ngl_render_job_set_color (job, gsk_outset_shadow_node_get_color (node));
   gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
                                             UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, 0,
                                             &transformed_outline);
@@ -2183,38 +2163,45 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob     *job,
 
   /* Corners... */
   if (corner_sizes[0][0] > 0 && corner_sizes[0][1] > 0) /* Top left */
-    gsk_ngl_render_job_draw (job,
-                             x, y,
-                             corner_sizes[0][0], corner_sizes[0][1]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x, y, corner_sizes[0][0], corner_sizes[0][1],
+                                        color);
   if (corner_sizes[1][0] > 0 && corner_sizes[1][1] > 0) /* Top right */
-    gsk_ngl_render_job_draw (job,
-                             x + w - corner_sizes[1][0], y,
-                             corner_sizes[1][0], corner_sizes[1][1]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x + w - corner_sizes[1][0], y,
+                                        corner_sizes[1][0], corner_sizes[1][1],
+                                        color);
   if (corner_sizes[2][0] > 0 && corner_sizes[2][1] > 0) /* Bottom right */
-    gsk_ngl_render_job_draw (job,
-                             x + w - corner_sizes[2][0], y + h - corner_sizes[2][1],
-                             corner_sizes[2][0], corner_sizes[2][1]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x + w - corner_sizes[2][0], y + h - corner_sizes[2][1],
+                                        corner_sizes[2][0], corner_sizes[2][1],
+                                        color);
   if (corner_sizes[3][0] > 0 && corner_sizes[3][1] > 0) /* Bottom left */
-    gsk_ngl_render_job_draw (job,
-                             x, y + h - corner_sizes[3][1],
-                             corner_sizes[3][0], corner_sizes[3][1]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x, y + h - corner_sizes[3][1],
+                                        corner_sizes[3][0], corner_sizes[3][1],
+                                        color);
   /* Edges... */;
   if (edge_sizes[0] > 0) /* Top */
-    gsk_ngl_render_job_draw (job,
-                             x + corner_sizes[0][0], y,
-                             w - corner_sizes[0][0] - corner_sizes[1][0], edge_sizes[0]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x + corner_sizes[0][0], y,
+                                        w - corner_sizes[0][0] - corner_sizes[1][0], edge_sizes[0],
+                                        color);
   if (edge_sizes[1] > 0) /* Right */
-    gsk_ngl_render_job_draw (job,
-                             x + w - edge_sizes[1], y + corner_sizes[1][1],
-                             edge_sizes[1], h - corner_sizes[1][1] - corner_sizes[2][1]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x + w - edge_sizes[1], y + corner_sizes[1][1],
+                                        edge_sizes[1], h - corner_sizes[1][1] - corner_sizes[2][1],
+                                        color);
   if (edge_sizes[2] > 0) /* Bottom */
-    gsk_ngl_render_job_draw (job,
-                             x + corner_sizes[3][0], y + h - edge_sizes[2],
-                             w - corner_sizes[3][0] - corner_sizes[2][0], edge_sizes[2]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x + corner_sizes[3][0], y + h - edge_sizes[2],
+                                        w - corner_sizes[3][0] - corner_sizes[2][0], edge_sizes[2],
+                                        color);
   if (edge_sizes[3] > 0) /* Left */
-    gsk_ngl_render_job_draw (job,
-                             x, y + corner_sizes[0][1],
-                             edge_sizes[3], h - corner_sizes[0][1] - corner_sizes[3][1]);
+    gsk_ngl_render_job_draw_with_color (job,
+                                        x, y + corner_sizes[0][1],
+                                        edge_sizes[3], h - corner_sizes[0][1] - corner_sizes[3][1],
+                                        color);
 
   gsk_ngl_render_job_end_draw (job);
 }
@@ -2324,8 +2311,7 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
 
       /* Draw the outline using color program */
       gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
-      gsk_ngl_render_job_set_color (job, &white);
-      gsk_ngl_render_job_draw (job, 0, 0, texture_width, texture_height);
+      gsk_ngl_render_job_draw_with_color (job, 0, 0, texture_width, texture_height, &white);
       gsk_ngl_render_job_end_draw (job);
 
       /* Reset state from offscreen */
@@ -2368,7 +2354,6 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
       init_full_texture_region (&offscreen);
 
       gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
-      gsk_ngl_render_job_set_color (job, color);
       gsk_ngl_program_set_uniform_texture (job->current_program,
                                            UNIFORM_SHARED_SOURCE, 0,
                                            GL_TEXTURE_2D,
@@ -2377,19 +2362,19 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
       gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
                                                 UNIFORM_OUTSET_SHADOW_OUTLINE_RECT, 0,
                                                 &transformed_outline);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                       &GRAPHENE_RECT_INIT (min_x,
-                                                                            min_y,
-                                                                            texture_width / scale_x,
-                                                                            texture_height / scale_y),
-                                                       &offscreen);
+      gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                    &GRAPHENE_RECT_INIT (min_x,
+                                                                         min_y,
+                                                                         texture_width / scale_x,
+                                                                         texture_height / scale_y),
+                                                    &offscreen,
+                                                    color);
       gsk_ngl_render_job_end_draw (job);
 
       return;
     }
 
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
-  gsk_ngl_render_job_set_color (job, color);
   gsk_ngl_program_set_uniform_texture (job->current_program,
                                        UNIFORM_SHARED_SOURCE, 0,
                                        GL_TEXTURE_2D,
@@ -2421,11 +2406,12 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
     if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_LEFT]))
       {
         memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_LEFT].area, sizeof offscreen.area);
-        gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                         &GRAPHENE_RECT_INIT (min_x, min_y,
-                                                                              
slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x,
-                                                                              
slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
-                                                         &offscreen);
+        gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                      &GRAPHENE_RECT_INIT (min_x, min_y,
+                                                                           
slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x,
+                                                                           
slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
+                                                      &offscreen,
+                                                      color);
       }
 
     /* Top center */
@@ -2434,48 +2420,52 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
       memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_CENTER].area, sizeof offscreen.area);
       float width = (max_x - min_x) - (slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x +
                                        slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                       &GRAPHENE_RECT_INIT (min_x + 
(slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x),
-                                                                            min_y,
-                                                                            width,
-                                                                            
slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y),
-                                                       &offscreen);
+      gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                    &GRAPHENE_RECT_INIT (min_x + 
(slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x),
+                                                                         min_y,
+                                                                         width,
+                                                                         
slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y),
+                                                    &offscreen,
+                                                    color);
     }
 
     /* Top right */
     if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_RIGHT]))
     {
       memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_RIGHT].area, sizeof offscreen.area);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                       &GRAPHENE_RECT_INIT (max_x - 
(slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x),
-                                                                            min_y,
-                                                                            
slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x,
-                                                                            
slices[NINE_SLICE_TOP_RIGHT].rect.height / scale_y),
-                                                       &offscreen);
+      gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                    &GRAPHENE_RECT_INIT (max_x - 
(slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x),
+                                                                         min_y,
+                                                                         
slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x,
+                                                                         
slices[NINE_SLICE_TOP_RIGHT].rect.height / scale_y),
+                                                    &offscreen,
+                                                    color);
     }
 
     /* Bottom right */
     if (nine_slice_is_visible (&slices[NINE_SLICE_BOTTOM_RIGHT]))
     {
       memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_RIGHT].area, sizeof offscreen.area);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                       &GRAPHENE_RECT_INIT (max_x - 
(slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x),
-                                                                            max_y - 
(slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y),
-                                                                            
slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x,
-                                                                            
slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y),
-                                                       &offscreen);
+      gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                    &GRAPHENE_RECT_INIT (max_x - 
(slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x),
+                                                                         max_y - 
(slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y),
+                                                                         
slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x,
+                                                                         
slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y),
+                                                    &offscreen,
+                                                    color);
     }
 
     /* Bottom left */
     if (nine_slice_is_visible (&slices[NINE_SLICE_BOTTOM_LEFT]))
       {
         memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_LEFT].area, sizeof offscreen.area);
-        gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                         &GRAPHENE_RECT_INIT (min_x,
-                                                                              max_y - 
(slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y),
-                                                                              
slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x,
-                                                                              
slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y),
-                                                         &offscreen);
+        gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                      &GRAPHENE_RECT_INIT (min_x,
+                                                                           max_y - 
(slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y),
+                                                                           
slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x,
+                                                                           
slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y),
+                                                      &offscreen,
+                                                      color);
       }
 
     /* Left side */
@@ -2484,12 +2474,13 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
         memcpy (&offscreen.area, &slices[NINE_SLICE_LEFT_CENTER].area, sizeof offscreen.area);
         float height = (max_y - min_y) - (slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y +
                                                 slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y);
-        gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                         &GRAPHENE_RECT_INIT (min_x,
-                                                                              min_y + 
(slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
-                                                                              
slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x,
-                                                                              height),
-                                                         &offscreen);
+        gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                      &GRAPHENE_RECT_INIT (min_x,
+                                                                           min_y + 
(slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
+                                                                           
slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x,
+                                                                           height),
+                                                      &offscreen,
+                                                      color);
       }
 
     /* Right side */
@@ -2498,12 +2489,13 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
         memcpy (&offscreen.area, &slices[NINE_SLICE_RIGHT_CENTER].area, sizeof offscreen.area);
         float height = (max_y - min_y) - (slices[NINE_SLICE_TOP_RIGHT].rect.height / scale_y +
                                           slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y);
-        gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                         &GRAPHENE_RECT_INIT (max_x - 
(slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x),
-                                                                              min_y + 
(slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
-                                                                              
slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x,
-                                                                              height),
-                                                         &offscreen);
+        gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                      &GRAPHENE_RECT_INIT (max_x - 
(slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x),
+                                                                           min_y + 
(slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
+                                                                           
slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x,
+                                                                           height),
+                                                      &offscreen,
+                                                      color);
       }
 
     /* Bottom side */
@@ -2512,12 +2504,13 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
         memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_CENTER].area, sizeof offscreen.area);
         float width = (max_x - min_x) - (slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x +
                                          slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x);
-        gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                         &GRAPHENE_RECT_INIT (min_x + 
(slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x),
-                                                                              max_y - 
(slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y),
-                                                                              width,
-                                                                              
slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y),
-                                                         &offscreen);
+        gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                      &GRAPHENE_RECT_INIT (min_x + 
(slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x),
+                                                                           max_y - 
(slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y),
+                                                                           width,
+                                                                           
slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y),
+                                                      &offscreen,
+                                                      color);
       }
 
     /* Middle */
@@ -2528,11 +2521,12 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob     *job,
                                          slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x);
         float height = (max_y - min_y) - (slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y +
                                           slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y);
-        gsk_ngl_render_job_load_vertices_from_offscreen (job,
-                                                         &GRAPHENE_RECT_INIT (min_x + 
(slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x),
-                                                                              min_y + 
(slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y),
-                                                                              width, height),
-                                                         &offscreen);
+        gsk_ngl_render_job_draw_offscreen_with_color (job,
+                                                      &GRAPHENE_RECT_INIT (min_x + 
(slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x),
+                                                                           min_y + 
(slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y),
+                                                                           width, height),
+                                                      &offscreen,
+                                                      color);
       }
   }
 
@@ -2607,7 +2601,7 @@ gsk_ngl_render_job_visit_cross_fade_node (GskNglRenderJob     *job,
   gsk_ngl_program_set_uniform1f (job->current_program,
                                  UNIFORM_CROSS_FADE_PROGRESS, 0,
                                  progress);
-  gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen_end);
+  gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen_end);
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -2645,7 +2639,7 @@ gsk_ngl_render_job_visit_opacity_node (GskNglRenderJob     *job,
                                                GL_TEXTURE_2D,
                                                GL_TEXTURE0,
                                                offscreen.texture_id);
-          gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
+          gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
           gsk_ngl_render_job_end_draw (job);
         }
       else
@@ -2907,13 +2901,12 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob     *job,
 
       gsk_ngl_render_job_offset (job, dx, dy);
       gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
-      gsk_ngl_render_job_set_color (job, &shadow->color);
       gsk_ngl_program_set_uniform_texture (job->current_program,
                                            UNIFORM_SHARED_SOURCE, 0,
                                            GL_TEXTURE_2D,
                                            GL_TEXTURE0,
                                            offscreen.texture_id);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job, &bounds, &offscreen);
+      gsk_ngl_render_job_draw_offscreen_with_color (job, &bounds, &offscreen, &shadow->color);
       gsk_ngl_render_job_end_draw (job);
       gsk_ngl_render_job_offset (job, -dx, -dy);
     }
@@ -2967,7 +2960,10 @@ gsk_ngl_render_job_visit_blur_node (GskNglRenderJob     *job,
                                        GL_TEXTURE_2D,
                                        GL_TEXTURE0,
                                        offscreen.texture_id);
-  gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 1, 1, 0);
+  gsk_ngl_render_job_draw_coords (job,
+                                  min_x, min_y, max_x, max_y,
+                                  0, 1, 1, 0,
+                                  &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f } );
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -3006,7 +3002,7 @@ gsk_ngl_render_job_visit_blend_node (GskNglRenderJob     *job,
                                            GL_TEXTURE_2D,
                                            GL_TEXTURE0,
                                            bottom_offscreen.texture_id);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &bottom_offscreen);
+      gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &bottom_offscreen);
       gsk_ngl_render_job_end_draw (job);
       return;
     }
@@ -3065,7 +3061,7 @@ gsk_ngl_render_job_visit_color_matrix_node (GskNglRenderJob     *job,
                                   UNIFORM_COLOR_MATRIX_COLOR_OFFSET, 0,
                                   1,
                                   offset);
-  gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
+  gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -3076,8 +3072,7 @@ gsk_ngl_render_job_visit_gl_shader_node_fallback (GskNglRenderJob     *job,
   static const GdkRGBA pink = { 255 / 255., 105 / 255., 180 / 255., 1.0 };
 
   gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
-  gsk_ngl_render_job_set_color (job, &pink);
-  gsk_ngl_render_job_draw_rect (job, &node->bounds);
+  gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, &pink);
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -3245,7 +3240,7 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob     *job,
                                            GL_TEXTURE_2D,
                                            GL_TEXTURE0,
                                            offscreen.texture_id);
-      gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
+      gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
       gsk_ngl_render_job_end_draw (job);
     }
   else
@@ -3284,7 +3279,10 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob     *job,
                                                GL_TEXTURE0,
                                                slice->texture_id);
 
-          gsk_ngl_render_job_draw_coords (job, x1, y1, x2, y2, 0, 0, 1, 1);
+          gsk_ngl_render_job_draw_coords (job,
+                                          x1, y1, x2, y2,
+                                          0, 0, 1, 1,
+                                          &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
         }
 
       gsk_ngl_render_job_end_draw (job);
@@ -3342,7 +3340,7 @@ gsk_ngl_render_job_visit_repeat_node (GskNglRenderJob     *job,
                                  offscreen.was_offscreen ? offscreen.area.y2 : offscreen.area.y,
                                  offscreen.area.x2,
                                  offscreen.was_offscreen ? offscreen.area.y : offscreen.area.y2);
-  gsk_ngl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
+  gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
   gsk_ngl_render_job_end_draw (job);
 }
 
@@ -3821,7 +3819,6 @@ gsk_ngl_render_job_new (GskNglDriver          *driver,
   job->viewport = *viewport;
 
   gsk_ngl_render_job_set_alpha (job, 1.0);
-  gsk_ngl_render_job_set_color (job, &(GdkRGBA){ 0.f, 0.f, 0.f, 0.f });
   gsk_ngl_render_job_set_projection_from_rect (job, viewport, NULL);
   gsk_ngl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_factor, scale_factor));
 


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