mirror of
https://github.com/brl/mutter.git
synced 2025-01-22 09:29:25 +00:00
wayland/surface: Intersect buffer damage with buffer rect
Before processing the buffer damage region, intersect it with the buffer rectangle to avoid trying to damage content outside the surface. This fixes the runtime warning "GL error (1281): Invalid value" happening when a client posts too large buffer damage larger.
This commit is contained in:
parent
7226c5c7bf
commit
da5a2d3cb8
@ -291,6 +291,7 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
{
|
||||
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
|
||||
cairo_rectangle_int_t surface_rect;
|
||||
cairo_rectangle_int_t buffer_rect;
|
||||
cairo_region_t *scaled_region;
|
||||
cairo_region_t *transformed_region;
|
||||
int i, n_rectangles;
|
||||
@ -302,6 +303,12 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
buffer_rect = (cairo_rectangle_int_t) {
|
||||
.width = get_buffer_width (surface),
|
||||
.height = get_buffer_height (surface),
|
||||
};
|
||||
cairo_region_intersect_rectangle (buffer_region, &buffer_rect);
|
||||
|
||||
/* Intersect the damage region with the surface region before scaling in
|
||||
* order to avoid integer overflow when scaling a damage region is too large
|
||||
* (for example INT32_MAX which mesa passes). */
|
||||
@ -316,8 +323,8 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
scaled_region = meta_region_scale (surface_region, surface->scale);
|
||||
transformed_region = meta_region_transform (scaled_region,
|
||||
surface->buffer_transform,
|
||||
get_buffer_width (surface),
|
||||
get_buffer_height (surface));
|
||||
buffer_rect.width,
|
||||
buffer_rect.height);
|
||||
|
||||
/* Now add the buffer damage on top of the scaled damage region, as buffer
|
||||
* damage is already in that scale. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user