From: Benjamin Otte Date: Thu, 18 May 2023 01:03:10 +0000 (+0200) Subject: vulkan: Don't draw fully clipped nodes X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~185^2~18 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0fee26252ce4b7361f0d64ed2013d2b687df7776;p=gtk4.git vulkan: Don't draw fully clipped nodes ... if they are container nodes. Other nodes will get culled by the vertex shader. --- diff --git a/gsk/vulkan/gskvulkanclip.c b/gsk/vulkan/gskvulkanclip.c index 674c5011f1..dcc42c5183 100644 --- a/gsk/vulkan/gskvulkanclip.c +++ b/gsk/vulkan/gskvulkanclip.c @@ -240,6 +240,34 @@ 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) +{ + graphene_rect_t r = *rect; + r.origin.x += offset->x; + r.origin.y += offset->y; + + switch (self->type) + { + default: + g_assert_not_reached(); + case GSK_VULKAN_CLIP_ALL_CLIPPED: + return FALSE; + + case GSK_VULKAN_CLIP_NONE: + return TRUE; + + case GSK_VULKAN_CLIP_RECT: + return graphene_rect_intersection (&self->rect.bounds, &r, NULL); + + case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR: + case GSK_VULKAN_CLIP_ROUNDED: + return gsk_rounded_rect_intersects_rect (&self->rect, &r); + } +} + gboolean gsk_vulkan_clip_contains_rect (const GskVulkanClip *self, const graphene_point_t *offset, diff --git a/gsk/vulkan/gskvulkanclipprivate.h b/gsk/vulkan/gskvulkanclipprivate.h index b311c07623..303cbf0cb8 100644 --- a/gsk/vulkan/gskvulkanclipprivate.h +++ b/gsk/vulkan/gskvulkanclipprivate.h @@ -57,6 +57,9 @@ 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, + const graphene_point_t *offset, + const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 8bbdc9ed2c..4b2fe0699d 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -331,6 +331,9 @@ gsk_vulkan_render_pass_add_container_node (GskVulkanRenderPass *self, const GskVulkanParseState *state, GskRenderNode *node) { + if (!gsk_vulkan_clip_intersects_rect (&state->clip, &state->offset, &node->bounds)) + return TRUE; + for (guint i = 0; i < gsk_container_node_get_n_children (node); i++) gsk_vulkan_render_pass_add_node (self, render, state, gsk_container_node_get_child (node, i));