compositor: use bounding box for damage regions
Change weston_surface_damage*() functions to use the full surface
bounding box or call surface_compute_bbox() to find the bounding box for
an arbitrary rectangle.
This should fix all rendering artifacts for non-opaque (i.e. ARGB)
transformed surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/src/compositor.c b/src/compositor.c
index b8ccf6d..9f94abf 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -384,25 +384,36 @@
WL_EXPORT void
weston_surface_damage_rectangle(struct weston_surface *surface,
- int32_t x, int32_t y,
- int32_t width, int32_t height)
+ int32_t sx, int32_t sy,
+ int32_t width, int32_t height)
{
- struct weston_compositor *compositor = surface->compositor;
+ weston_surface_update_transform(surface);
- pixman_region32_union_rect(&surface->damage,
- &surface->damage,
- surface->geometry.x + x,
- surface->geometry.y + y,
- width, height);
- weston_compositor_schedule_repaint(compositor);
+ if (surface->transform.enabled) {
+ pixman_region32_t box;
+ surface_compute_bbox(surface, sx, sy, width, height, &box);
+ pixman_region32_union(&surface->damage, &surface->damage,
+ &box);
+ pixman_region32_fini(&box);
+ } else {
+ int32_t x, y;
+ weston_surface_to_global(surface, sx, sy, &x, &y);
+ pixman_region32_union_rect(&surface->damage, &surface->damage,
+ x, y, width, height);
+ }
+
+ weston_compositor_schedule_repaint(surface->compositor);
}
WL_EXPORT void
weston_surface_damage(struct weston_surface *surface)
{
- weston_surface_damage_rectangle(surface, 0, 0,
- surface->geometry.width,
- surface->geometry.height);
+ weston_surface_update_transform(surface);
+
+ pixman_region32_union(&surface->damage, &surface->damage,
+ &surface->transform.boundingbox);
+
+ weston_compositor_schedule_repaint(surface->compositor);
}
WL_EXPORT void
@@ -418,11 +429,10 @@
below = container_of(surface->link.next, struct weston_surface, link);
- pixman_region32_union_rect(&below->damage,
- &below->damage,
- surface->geometry.x, surface->geometry.y,
- surface->geometry.width,
- surface->geometry.height);
+ weston_surface_update_transform(surface);
+ pixman_region32_union(&below->damage, &below->damage,
+ &surface->transform.boundingbox);
+
weston_compositor_schedule_repaint(surface->compositor);
}