From e2426960d479a84ad66ee865404a925d66d9a55b Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Mon, 15 Mar 2021 09:43:37 +0100 Subject: [PATCH] compositor: set transform.opaque for surfaces without alpha channel If surface->is_opaque is set then we can assume that the whole surface is opaque. In the trivial case (no transformation or translation only) this means that transform.boundingbox is exactly the view area and is fully opaque. So it can be used for transform.opaque. This is important because damage calculation uses transform.opaque. Without this, anything underneath a surface without an explicit opaque region but a pixel format without alpha channel is drawn unnecessarily. Signed-off-by: Michael Olbrich --- libweston/compositor.c | 46 +++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index 45502e18..24c6313d 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -1513,15 +1513,20 @@ weston_view_update_transform_disable(struct weston_view *view) view->geometry.x, view->geometry.y); if (view->alpha == 1.0) { - pixman_region32_copy(&view->transform.opaque, - &view->surface->opaque); - if (view->geometry.scissor_enabled) - pixman_region32_intersect(&view->transform.opaque, - &view->transform.opaque, - &view->geometry.scissor); - pixman_region32_translate(&view->transform.opaque, - view->geometry.x, - view->geometry.y); + if (view->surface->is_opaque) { + pixman_region32_copy(&view->transform.opaque, + &view->transform.boundingbox); + } else { + pixman_region32_copy(&view->transform.opaque, + &view->surface->opaque); + if (view->geometry.scissor_enabled) + pixman_region32_intersect(&view->transform.opaque, + &view->transform.opaque, + &view->geometry.scissor); + pixman_region32_translate(&view->transform.opaque, + view->geometry.x, + view->geometry.y); + } } } @@ -1568,15 +1573,20 @@ weston_view_update_transform_enable(struct weston_view *view) if (view->alpha == 1.0 && matrix->type == WESTON_MATRIX_TRANSFORM_TRANSLATE) { - pixman_region32_copy(&view->transform.opaque, - &view->surface->opaque); - if (view->geometry.scissor_enabled) - pixman_region32_intersect(&view->transform.opaque, - &view->transform.opaque, - &view->geometry.scissor); - pixman_region32_translate(&view->transform.opaque, - matrix->d[12], - matrix->d[13]); + if (view->surface->is_opaque) { + pixman_region32_copy(&view->transform.opaque, + &view->transform.boundingbox); + } else { + pixman_region32_copy(&view->transform.opaque, + &view->surface->opaque); + if (view->geometry.scissor_enabled) + pixman_region32_intersect(&view->transform.opaque, + &view->transform.opaque, + &view->geometry.scissor); + pixman_region32_translate(&view->transform.opaque, + matrix->d[12], + matrix->d[13]); + } } return 0;