From aa82a400dfb3eaf28da96cd106efc27eeee0c55e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 10 Jul 2023 06:18:44 +0200 Subject: [PATCH 1/4] textbtree: Remove unnecessary check Since a93614409ed79e1297469bdc1de3cb69663de71e we don't allocate the stack anymore, so this NULL check is unnecessary now - and it's flagged by compilers. --- gtk/gtktextbtree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index 4166083967..66ba20abdf 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -3769,8 +3769,7 @@ _gtk_text_line_char_index (GtkTextLine *target_line) tos--; /* Check that we have the root node on top of the stack. */ - g_assert (node_stack != NULL && - node_stack[tos] != NULL && + g_assert (node_stack[tos] != NULL && node_stack[tos]->parent == NULL); /* Add up chars in all nodes before the nodes in our stack. From 465a34e6b0ef9654423c32d389dbb8ba6af40cdb Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 10 Jul 2023 06:23:45 +0200 Subject: [PATCH 2/4] rendernode: Implement proper GSK_IS_RENDERNODE() Use G_TYPE_CHECK_INSTANCE_TYPE() instead of just checking for != NULL. After all, this is a GTypeInstance. Also fixes some gcc complaints when checking node == NULL || GSK_IS_RENDERNODE (node) which gcc was convinced would be always true. --- gsk/gskrendernode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h index b1ceec5cea..f3ae38f6e1 100644 --- a/gsk/gskrendernode.h +++ b/gsk/gskrendernode.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS #define GSK_TYPE_RENDER_NODE (gsk_render_node_get_type ()) -#define GSK_IS_RENDER_NODE(obj) ((obj) != NULL) +#define GSK_IS_RENDER_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_RENDER_NODE)) #define GSK_SERIALIZATION_ERROR (gsk_serialization_error_quark ()) From 5c601b673e3005277b5390b8af676793be2d5fe5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 8 Jul 2023 10:42:07 +0200 Subject: [PATCH 3/4] vulkan: intersect rects also for CLIP_NONE If we don't clip anything, we stil have bounds - either the framebuffer size or (more likely) the scissor rect. And we don't want to draw anything that is outside these bounds. So clip in those cases, too. Stops gtk4-demo --run=listbox from trying to render the whole listbox instead of only the visible parts. --- gsk/vulkan/gskvulkanclip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gsk/vulkan/gskvulkanclip.c b/gsk/vulkan/gskvulkanclip.c index 2b24773125..bf8a2732e1 100644 --- a/gsk/vulkan/gskvulkanclip.c +++ b/gsk/vulkan/gskvulkanclip.c @@ -252,8 +252,6 @@ gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self, return FALSE; case GSK_VULKAN_CLIP_NONE: - return r.size.width > 0 && r.size.height > 0; - case GSK_VULKAN_CLIP_RECT: return graphene_rect_intersection (&self->rect.bounds, &r, NULL); From 3523d56122d0ea94b1b0ea72ab780397129f4b9d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 11 Jul 2023 01:38:02 +0200 Subject: [PATCH 4/4] vulkan: Change the clip intersection check Intersection with a roudned clip takes too long. Instead, rename the function to may_intersect() to be clear about what it does and then just intersect with the regular rectangle. --- gsk/vulkan/gskvulkanclip.c | 10 ++++------ gsk/vulkan/gskvulkanclipprivate.h | 2 +- gsk/vulkan/gskvulkanrenderpass.c | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gsk/vulkan/gskvulkanclip.c b/gsk/vulkan/gskvulkanclip.c index bf8a2732e1..2784bdd7c2 100644 --- a/gsk/vulkan/gskvulkanclip.c +++ b/gsk/vulkan/gskvulkanclip.c @@ -236,9 +236,9 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest, } gboolean -gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self, - const graphene_point_t *offset, - const graphene_rect_t *rect) +gsk_vulkan_clip_may_intersect_rect (const GskVulkanClip *self, + const graphene_point_t *offset, + const graphene_rect_t *rect) { graphene_rect_t r = *rect; r.origin.x += offset->x; @@ -253,10 +253,8 @@ gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self, case GSK_VULKAN_CLIP_NONE: case GSK_VULKAN_CLIP_RECT: - return graphene_rect_intersection (&self->rect.bounds, &r, NULL); - case GSK_VULKAN_CLIP_ROUNDED: - return gsk_rounded_rect_intersects_rect (&self->rect, &r); + return graphene_rect_intersection (&self->rect.bounds, &r, NULL); } } diff --git a/gsk/vulkan/gskvulkanclipprivate.h b/gsk/vulkan/gskvulkanclipprivate.h index f3cadfc337..9f39250ee8 100644 --- a/gsk/vulkan/gskvulkanclipprivate.h +++ b/gsk/vulkan/gskvulkanclipprivate.h @@ -55,7 +55,7 @@ gboolean gsk_vulkan_clip_transform (GskVulk gboolean gsk_vulkan_clip_contains_rect (const GskVulkanClip *self, const graphene_point_t *offset, const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT; -gboolean gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self, +gboolean gsk_vulkan_clip_may_intersect_rect (const GskVulkanClip *self, const graphene_point_t *offset, const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT; diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 3e793e4600..66a74174af 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -1195,7 +1195,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, /* This catches the corner cases of empty nodes, so after this check * there's quaranteed to be at least 1 pixel that needs to be drawn */ - if (!gsk_vulkan_clip_intersects_rect (&state->clip, &state->offset, &node->bounds)) + if (!gsk_vulkan_clip_may_intersect_rect (&state->clip, &state->offset, &node->bounds)) return; node_type = gsk_render_node_get_node_type (node);