[gtk/wip/chergert/opbuffer: 31/31] gl: avoid calculating vertex_data until necessary
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/opbuffer: 31/31] gl: avoid calculating vertex_data until necessary
- Date: Tue, 15 Oct 2019 01:42:27 +0000 (UTC)
commit 8dd6459c95146d22a68e0fd08f1cf71725058d4b
Author: Christian Hergert <chergert redhat com>
Date: Sun Oct 13 16:39:54 2019 -0700
gl: avoid calculating vertex_data until necessary
In many cases of the switch, we do not need the vertex data. This moves
the creation of the vertex_data array into a secondary function and only
calculates it the cases for which it is required.
gsk/gl/gskglrenderer.c | 68 +++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 53 insertions(+), 15 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 970e4efafb..7f36dd7e31 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -2706,26 +2706,53 @@ gsk_gl_renderer_setup_render_mode (GskGLRenderer *self)
}
}
-
static void
-gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
- GskRenderNode *node,
- RenderOpBuilder *builder)
+load_vertex_data (GskQuadVertex vertex_data[GL_N_VERTICES],
+ GskRenderNode *node,
+ RenderOpBuilder *builder)
{
const float min_x = builder->dx + node->bounds.origin.x;
const float min_y = builder->dy + node->bounds.origin.y;
const float max_x = min_x + node->bounds.size.width;
const float max_y = min_y + node->bounds.size.height;
- /* Default vertex data */
- const GskQuadVertex vertex_data[GL_N_VERTICES] = {
- { { min_x, min_y }, { 0, 0 }, },
- { { min_x, max_y }, { 0, 1 }, },
- { { max_x, min_y }, { 1, 0 }, },
- { { max_x, max_y }, { 1, 1 }, },
- { { min_x, max_y }, { 0, 1 }, },
- { { max_x, min_y }, { 1, 0 }, },
- };
+ vertex_data[0].position[0] = min_x;
+ vertex_data[0].position[1] = min_y;
+ vertex_data[0].uv[0] = 0;
+ vertex_data[0].uv[1] = 0;
+
+ vertex_data[1].position[0] = min_x;
+ vertex_data[1].position[1] = max_y;
+ vertex_data[1].uv[0] = 0;
+ vertex_data[1].uv[1] = 0;
+
+ vertex_data[2].position[0] = max_x;
+ vertex_data[2].position[1] = min_y;
+ vertex_data[2].uv[0] = 0;
+ vertex_data[2].uv[1] = 0;
+
+ vertex_data[3].position[0] = max_x;
+ vertex_data[3].position[1] = max_y;
+ vertex_data[3].uv[0] = 0;
+ vertex_data[3].uv[1] = 0;
+
+ vertex_data[4].position[0] = min_x;
+ vertex_data[4].position[1] = max_y;
+ vertex_data[4].uv[0] = 0;
+ vertex_data[4].uv[1] = 0;
+
+ vertex_data[5].position[0] = max_x;
+ vertex_data[5].position[1] = min_y;
+ vertex_data[5].uv[0] = 0;
+ vertex_data[5].uv[1] = 0;
+}
+
+static void
+gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
+ GskRenderNode *node,
+ RenderOpBuilder *builder)
+{
+ GskQuadVertex vertex_data[GL_N_VERTICES];
/* This can still happen, even if the render nodes are created using
* GtkSnapshot, so let's juse be safe. */
@@ -2779,6 +2806,7 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
break;
case GSK_COLOR_NODE:
+ load_vertex_data (vertex_data, node, builder);
render_color_node (self, node, builder, vertex_data);
break;
@@ -2795,6 +2823,7 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
break;
case GSK_LINEAR_GRADIENT_NODE:
+ load_vertex_data (vertex_data, node, builder);
render_linear_gradient_node (self, node, builder, vertex_data);
break;
@@ -2812,25 +2841,34 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
break;
case GSK_COLOR_MATRIX_NODE:
+ load_vertex_data (vertex_data, node, builder);
render_color_matrix_node (self, node, builder, vertex_data);
break;
case GSK_BLUR_NODE:
+ load_vertex_data (vertex_data, node, builder);
render_blur_node (self, node, builder, vertex_data);
break;
case GSK_INSET_SHADOW_NODE:
+ load_vertex_data (vertex_data, node, builder);
render_inset_shadow_node (self, node, builder, vertex_data);
break;
case GSK_OUTSET_SHADOW_NODE:
if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
- render_outset_shadow_node (self, node, builder);
+ {
+ render_outset_shadow_node (self, node, builder);
+ }
else
- render_unblurred_outset_shadow_node (self, node, builder, vertex_data);
+ {
+ load_vertex_data (vertex_data, node, builder);
+ render_unblurred_outset_shadow_node (self, node, builder, vertex_data);
+ }
break;
case GSK_SHADOW_NODE:
+ load_vertex_data (vertex_data, node, builder);
render_shadow_node (self, node, builder, vertex_data);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]