From 852ecf7c205a24e21d636acd233b8005d06b16cd Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 7 Aug 2024 19:26:23 +0200 Subject: [PATCH] gpu: Consult scissor for clip bounds When querying clip bounds, also check the scissor rect, because sometimes that one is tighter than the clip bounds, because the clip bounds need to track some larger rounded corners. Makes a few tests harder to break. --- gsk/gpu/gskgpunodeprocessor.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 71482d32bc..5a7f8635fb 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -531,14 +531,25 @@ static void gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self, graphene_rect_t *out_bounds) { - graphene_rect_offset_r (&self->clip.rect.bounds, - - self->offset.x, - - self->offset.y, - out_bounds); - - /* FIXME: We could try the scissor rect here. - * But how often is that smaller than the clip bounds? - */ + graphene_rect_t scissor; + + if (gsk_gpu_node_processor_rect_device_to_clip (self, + &GSK_RECT_INIT_CAIRO (&self->scissor), + &scissor)) + { + if (!gsk_rect_intersection (&scissor, &self->clip.rect.bounds, out_bounds)) + { + g_warning ("Clipping is broken, everything is clipped, but we didn't early-exit.\n"); + *out_bounds = self->clip.rect.bounds; + } + } + else + { + *out_bounds = self->clip.rect.bounds; + } + + out_bounds->origin.x -= self->offset.x; + out_bounds->origin.y -= self->offset.y; } static gboolean G_GNUC_WARN_UNUSED_RESULT