broadway: Don't create overlarge images

Respect that cairo won't create image surfaces larger
than 32767 x 32767.

This makes the one reftest pass that specifically checks
this condition, treeview-crash-too-wide.
This commit is contained in:
Matthias Clasen 2020-05-16 11:27:21 -04:00
parent 13f8583934
commit 5851415fca

View File

@ -756,7 +756,14 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
int height = ceil (node->bounds.origin.y + node->bounds.size.height) - y;
int scale = broadway_display->scale_factor;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);
#define MAX_IMAGE_SIZE 32767
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
MIN (width * scale, MAX_IMAGE_SIZE),
MIN (height * scale, MAX_IMAGE_SIZE));
#undef MAX_IMAGE_SIZE
cr = cairo_create (surface);
cairo_scale (cr, scale, scale);
cairo_translate (cr, -x, -y);