From f7fc90daa06a5b9d6377154eecdad96d2b8b9f11 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 13 Nov 2023 08:17:40 +0100 Subject: [PATCH 1/4] Add another inline rect helper --- gsk/gskrectprivate.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gsk/gskrectprivate.h b/gsk/gskrectprivate.h index f606d5a0fc..2e6e8eedc6 100644 --- a/gsk/gskrectprivate.h +++ b/gsk/gskrectprivate.h @@ -36,3 +36,12 @@ gsk_rect_to_float (const graphene_rect_t *rect, values[3] = rect->size.height; } +static inline gboolean +gsk_rect_equal (const graphene_rect_t *r1, + const graphene_rect_t *r2) +{ + return r1->origin.x == r2->origin.x && + r1->origin.y == r2->origin.y && + r1->size.width == r2->size.width && + r1->size.height == r2->size.height; +} From 982f965ea8b0d9bb0d743b774cc84179e9e6af0d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 13 Nov 2023 22:12:58 +0100 Subject: [PATCH 2/4] gsk: Use some more inline helpers --- gsk/gl/gskglrenderjob.c | 4 ++-- gsk/gskrendernodeimpl.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c index 4e2c5aead0..9ace1777a7 100644 --- a/gsk/gl/gskglrenderjob.c +++ b/gsk/gl/gskglrenderjob.c @@ -2822,7 +2822,7 @@ equal_texture_nodes (const GskRenderNode *node1, gsk_texture_node_get_texture (node2)) return FALSE; - return graphene_rect_equal (&node1->bounds, &node2->bounds); + return gsk_rect_equal (&node1->bounds, &node2->bounds); } static inline void @@ -3949,7 +3949,7 @@ gsk_gl_render_job_visit_repeat_node (GskGLRenderJob *job, if (node_is_invisible (child)) return; - if (!graphene_rect_equal (child_bounds, &child->bounds)) + if (!gsk_rect_equal (child_bounds, &child->bounds)) { /* TODO: implement these repeat nodes. */ gsk_gl_render_job_visit_as_fallback (job, node); diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 1de4790240..ee5980871c 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -131,7 +131,7 @@ gsk_color_node_diff (GskRenderNode *node1, GskColorNode *self1 = (GskColorNode *) node1; GskColorNode *self2 = (GskColorNode *) node2; - if (graphene_rect_equal (&node1->bounds, &node2->bounds) && + if (gsk_rect_equal (&node1->bounds, &node2->bounds) && gdk_rgba_equal (&self1->color, &self2->color)) return; @@ -1685,7 +1685,7 @@ gsk_texture_node_diff (GskRenderNode *node1, GskTextureNode *self2 = (GskTextureNode *) node2; cairo_region_t *sub; - if (!graphene_rect_equal (&node1->bounds, &node2->bounds) || + if (!gsk_rect_equal (&node1->bounds, &node2->bounds) || gdk_texture_get_width (self1->texture) != gdk_texture_get_width (self2->texture) || gdk_texture_get_height (self1->texture) != gdk_texture_get_height (self2->texture)) { @@ -1872,7 +1872,7 @@ gsk_texture_scale_node_diff (GskRenderNode *node1, GskTextureScaleNode *self2 = (GskTextureScaleNode *) node2; cairo_region_t *sub; - if (!graphene_rect_equal (&node1->bounds, &node2->bounds) || + if (!gsk_rect_equal (&node1->bounds, &node2->bounds) || self1->filter != self2->filter || gdk_texture_get_width (self1->texture) != gdk_texture_get_width (self2->texture) || gdk_texture_get_height (self1->texture) != gdk_texture_get_height (self2->texture)) @@ -4145,7 +4145,7 @@ gsk_clip_node_diff (GskRenderNode *node1, GskClipNode *self1 = (GskClipNode *) node1; GskClipNode *self2 = (GskClipNode *) node2; - if (graphene_rect_equal (&self1->clip, &self2->clip)) + if (gsk_rect_equal (&self1->clip, &self2->clip)) { cairo_region_t *sub; cairo_rectangle_int_t clip_rect; @@ -6491,7 +6491,7 @@ gsk_gl_shader_node_diff (GskRenderNode *node1, GskGLShaderNode *self1 = (GskGLShaderNode *) node1; GskGLShaderNode *self2 = (GskGLShaderNode *) node2; - if (graphene_rect_equal (&node1->bounds, &node2->bounds) && + if (gsk_rect_equal (&node1->bounds, &node2->bounds) && self1->shader == self2->shader && g_bytes_compare (self1->args, self2->args) == 0 && self1->n_children == self2->n_children) From 209a1a69ccb74f0d661ad99d89c8e44b2e196b69 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 13 Nov 2023 22:13:18 +0100 Subject: [PATCH 3/4] gtk: Use some more inline helpers --- gtk/gtkrenderborder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c index c9415c4ebf..ab95e1b736 100644 --- a/gtk/gtkrenderborder.c +++ b/gtk/gtkrenderborder.c @@ -38,6 +38,7 @@ #include "gdk/gdkhslaprivate.h" #include "gsk/gskroundedrectprivate.h" +#include "gsk/gskrectprivate.h" typedef struct _GtkBorderImage GtkBorderImage; @@ -678,8 +679,8 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes, graphene_simd4f_t alpha_test_vector; /* Optimize the most common case of "This widget has no border" */ - if (graphene_rect_equal (gtk_css_boxes_get_border_rect (boxes), - gtk_css_boxes_get_padding_rect (boxes))) + if (gsk_rect_equal (gtk_css_boxes_get_border_rect (boxes), + gtk_css_boxes_get_padding_rect (boxes))) return; colors[0] = *gtk_css_color_value_get_rgba (border->border_top_color ? border->border_top_color : boxes->style->core->color); From 93959ef7df278b0b868f4fc223a535b8f3fd11e4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 13 Nov 2023 00:38:29 +0100 Subject: [PATCH 4/4] gsk: Robustness fix I was seeing empty regions being passed as scissor. --- gsk/gl/gskglcommandqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index 5c1b703fef..5ff04acc2b 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -1104,7 +1104,7 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self, (void *) G_STRUCT_OFFSET (GskGLDrawVertex, color2)); /* Setup initial scissor clip */ - if (scissor != NULL) + if (scissor != NULL && cairo_region_num_rectangles (scissor) > 0) { cairo_rectangle_int_t r;