1
0
Fork 0

meta-wayland-surface: Clip damage to buffer dimensions

A client can send us damage that exceeds the buffer size, protect against that
by clipping the damage to the buffer's region.
This commit is contained in:
Adel Gadllah 2014-04-23 22:14:31 +02:00
parent 8c5da24401
commit c95c501a5b

View file

@ -105,7 +105,19 @@ static void
surface_process_damage (MetaWaylandSurface *surface,
cairo_region_t *region)
{
int i, n_rectangles = cairo_region_num_rectangles (region);
int i, n_rectangles;
cairo_rectangle_int_t buffer_rect;
buffer_rect.x = 0;
buffer_rect.y = 0;
buffer_rect.width = cogl_texture_get_width (surface->buffer->texture);
buffer_rect.height = cogl_texture_get_height (surface->buffer->texture);
/* The region will get destroyed after this call anyway so we can
just modify it here to avoid a copy */
cairo_region_intersect_rectangle (region, &buffer_rect);
n_rectangles = cairo_region_num_rectangles (region);
for (i = 0; i < n_rectangles; i++)
{