vulkan: Don't draw fully clipped nodes

... if they are container nodes. Other nodes will get culled by the
vertex shader.
This commit is contained in:
Benjamin Otte
2023-05-18 03:03:10 +02:00
parent d48b6b9ad5
commit 0fee26252c
3 changed files with 34 additions and 0 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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));