From 81912dc2a69f24c8fbcb43a2bc1f7860f3085c01 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 10 Mar 2021 09:10:25 +0100 Subject: [PATCH] compositor: improve opacity handling for scaled surfaces Currently, the opaque is discarded for all transformations other than a simple translation, because correctly transforming the opaque area is not possible in general. However, there is one simple case that is probably the most common one: A fully opaque surface that is translated and scaled. In this case the opaque area is simply the new bounding box. So set the transformed opaque area accordingly. Signed-off-by: Michael Olbrich --- libweston/compositor.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index 24c6313d..128ee232 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -1569,7 +1569,6 @@ weston_view_update_transform_enable(struct weston_view *view) surfbox = pixman_region32_extents(&surfregion); view_compute_bbox(view, surfbox, &view->transform.boundingbox); - pixman_region32_fini(&surfregion); if (view->alpha == 1.0 && matrix->type == WESTON_MATRIX_TRANSFORM_TRANSLATE) { @@ -1587,7 +1586,19 @@ weston_view_update_transform_enable(struct weston_view *view) matrix->d[12], matrix->d[13]); } + } else if (view->alpha == 1.0 && + matrix->type < WESTON_MATRIX_TRANSFORM_ROTATE && + pixman_region32_n_rects(&surfregion) == 1 && + (pixman_region32_equal(&surfregion, &view->surface->opaque) || + view->surface->is_opaque)) { + /* The whole surface is opaque and it is only translated and + * scaled and after applying the scissor, the result is still + * a single rectangle. In this case the boundingbox matches the + * view exactly and can be used as opaque area. */ + pixman_region32_copy(&view->transform.opaque, + &view->transform.boundingbox); } + pixman_region32_fini(&surfregion); return 0; }