mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 13:22:15 +00:00
wayland/surface: Do not uncoditionally process surface damage
Most clients nowadays switched to buffer damage, most notably Mesa and Xwayland. Thus lets avoid the extra cost of allocating three `cairo_region_t`s and doing some calculations. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
This commit is contained in:
parent
c166811695
commit
c498ae337f
@ -323,12 +323,7 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
cairo_region_t *buffer_region)
|
||||
{
|
||||
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;
|
||||
cairo_region_t *viewport_region;
|
||||
graphene_rect_t src_rect;
|
||||
MetaSurfaceActor *actor;
|
||||
|
||||
/* If the client destroyed the buffer it attached before committing, but
|
||||
@ -343,9 +338,17 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
.height = get_buffer_height (surface),
|
||||
};
|
||||
|
||||
if (!cairo_region_is_empty (surface_region))
|
||||
{
|
||||
cairo_rectangle_int_t surface_rect;
|
||||
cairo_region_t *scaled_region;
|
||||
cairo_region_t *transformed_region;
|
||||
cairo_region_t *viewport_region;
|
||||
graphene_rect_t src_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). */
|
||||
* order to avoid integer overflow when scaling a damage region is too
|
||||
* large (for example INT32_MAX which mesa passes). */
|
||||
surface_rect = (cairo_rectangle_int_t) {
|
||||
.width = meta_wayland_surface_get_width (surface),
|
||||
.height = meta_wayland_surface_get_height (surface),
|
||||
@ -394,9 +397,15 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
buffer_rect.height);
|
||||
|
||||
/* Now add the scaled, cropped and transformed damage region to the
|
||||
* buffer damage. Buffer damage is already in the correct coordinate space. */
|
||||
* buffer damage. Buffer damage is already in the correct coordinate
|
||||
* space. */
|
||||
cairo_region_union (buffer_region, transformed_region);
|
||||
|
||||
cairo_region_destroy (viewport_region);
|
||||
cairo_region_destroy (scaled_region);
|
||||
cairo_region_destroy (transformed_region);
|
||||
}
|
||||
|
||||
cairo_region_intersect_rectangle (buffer_region, &buffer_rect);
|
||||
|
||||
meta_wayland_buffer_process_damage (buffer, surface->texture, buffer_region);
|
||||
@ -417,10 +426,6 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
}
|
||||
|
||||
cairo_region_destroy (viewport_region);
|
||||
cairo_region_destroy (scaled_region);
|
||||
cairo_region_destroy (transformed_region);
|
||||
}
|
||||
|
||||
MetaWaylandBuffer *
|
||||
|
Loading…
Reference in New Issue
Block a user