gl renderer: Render simple border nodes in a simple way
authorTimm Bäder <mail@baedert.org>
Tue, 14 Jan 2020 14:43:53 +0000 (15:43 +0100)
committerTimm Bäder <mail@baedert.org>
Sat, 18 Jan 2020 07:49:52 +0000 (08:49 +0100)
Roughly 80% of the border nodes are just one color and have the same
width on all sides, so we can draw them by uploading just one rect and
not four.

gsk/gl/gskglrenderer.c

index 91de970cac6ea8a8ce942ad382903fec73d8b91d..7928da30962e67dca2648ff19fbfc1ea40966a46 100644 (file)
@@ -761,6 +761,26 @@ render_border_node (GskGLRenderer   *self,
     float h;
   } sizes[4];
 
+  if (og_widths[0] == og_widths[1] &&
+      og_widths[0] == og_widths[2] &&
+      og_widths[0] == og_widths[3] &&
+      gdk_rgba_equal (&colors[0], &colors[1]) &&
+      gdk_rgba_equal (&colors[0], &colors[2]) &&
+      gdk_rgba_equal (&colors[0], &colors[3]))
+    {
+      OpShadow *op;
+
+      ops_set_program (builder, &self->inset_shadow_program);
+      op = ops_begin (builder, OP_CHANGE_INSET_SHADOW);
+      op->color = &colors[0];
+      op->outline = transform_rect (self, builder, rounded_outline);
+      op->spread = og_widths[0] * scale;
+      op->offset[0] = 0;
+      op->offset[1] = 0;
+
+      load_vertex_data (ops_draw (builder, NULL), node, builder);
+      return;
+    }
 
   for (i = 0; i < 4; i ++)
     widths[i] = og_widths[i];