From: Benjamin Otte Date: Mon, 13 Feb 2023 00:44:48 +0000 (+0100) Subject: rendernode: Respect clip when drawing scale nodes X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~6^2~2^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=22ba6b1f33dcbcab8d42d133b7f333ca6ff44679;p=gtk4.git rendernode: Respect clip when drawing scale nodes Scale nodes can use large scale factors and we don't want to create insanely huge Cairo surfaces. A subsequent commit will add the texture-scale-magnify-10000x test which fails without this fix. --- diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index d0bd24b724..5d1f19da5b 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -1635,10 +1635,19 @@ gsk_texture_scale_node_draw (GskRenderNode *node, }; cairo_t *cr2; cairo_surface_t *surface2; + graphene_rect_t clip_rect; + + /* Make sure we draw the minimum region by using the clip */ + gsk_cairo_rectangle (cr, &node->bounds); + cairo_clip (cr); + _graphene_rect_init_from_clip_extents (&clip_rect, cr); + if (clip_rect.size.width <= 0 || clip_rect.size.height <= 0) + return; surface2 = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - (int) ceilf (node->bounds.size.width), - (int) ceilf (node->bounds.size.height)); + (int) ceilf (clip_rect.size.width), + (int) ceilf (clip_rect.size.height)); + cairo_surface_set_device_offset (surface2, -clip_rect.origin.x, -clip_rect.origin.y); cr2 = cairo_create (surface2); surface = gdk_texture_download_surface (self->texture);