From 600ce68210617c15c779ab9b85d24ab5c702dc76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 19 Nov 2019 10:45:02 +0100 Subject: [PATCH] gl renderer: Add a short cut for repeat nodes that don't repeat These happen and we don't even need to draw the child to a texture. --- gsk/gl/gskglrenderer.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index 357e09108d..9fd13a3480 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -1085,12 +1085,11 @@ render_linear_gradient_node (GskGLRenderer *self, } static inline void -render_clip_node (GskGLRenderer *self, - GskRenderNode *node, - RenderOpBuilder *builder) +render_clipped_child (GskGLRenderer *self, + RenderOpBuilder *builder, + const graphene_rect_t *clip, + GskRenderNode *child) { - const graphene_rect_t *clip = gsk_clip_node_peek_clip (node); - GskRenderNode *child = gsk_clip_node_get_child (node); graphene_rect_t transformed_clip; graphene_rect_t intersection; GskRoundedRect child_clip; @@ -1108,6 +1107,17 @@ render_clip_node (GskGLRenderer *self, ops_pop_clip (builder); } +static inline void +render_clip_node (GskGLRenderer *self, + GskRenderNode *node, + RenderOpBuilder *builder) +{ + const graphene_rect_t *clip = gsk_clip_node_peek_clip (node); + GskRenderNode *child = gsk_clip_node_get_child (node); + + render_clipped_child (self, builder, clip, child); +} + static inline void get_inner_rect (const GskRoundedRect *rect, graphene_rect_t *out) @@ -1962,6 +1972,15 @@ render_repeat_node (GskGLRenderer *self, return; } + /* If the size of the repeat node is smaller than the size of the + * child node, we don't repeat at all and can just draw that part + * of the child texture... */ + if (graphene_rect_contains_rect (child_bounds, &node->bounds)) + { + render_clipped_child (self, builder, &node->bounds, child); + return; + } + /* Draw the entire child on a texture */ add_offscreen_ops (self, builder, &child->bounds,