From 70decd5b2b4937390f0037c0b00b845f5a97fc62 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 3 Sep 2018 20:11:15 +0200 Subject: [PATCH] libweston: add weston_view_is_opaque() Use the weston_surface is_opaque property, the opaque region, and the view alpha value to determine whether the weston_view is opaque in a specific region. Signed-off-by: Philipp Zabel --- libweston/compositor.c | 37 +++++++++++++++++++++++++++++++++++++ libweston/compositor.h | 3 +++ 2 files changed, 40 insertions(+) diff --git a/libweston/compositor.c b/libweston/compositor.c index 0dcb1df3..e0997384 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -1681,6 +1681,43 @@ weston_view_is_mapped(struct weston_view *view) return view->is_mapped; } +/* Check if view is opaque in specified region + * + * \param view The view to check for opacity. + * \param region The region to check for opacity, in view coordinates. + * + * Returns true if the view is opaque in the specified region, because view + * alpha is 1.0 and either the opaque region set by the client contains the + * specified region, or the buffer pixel format or solid color is opaque. + */ +WL_EXPORT bool +weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region) +{ + pixman_region32_t r; + bool ret = false; + + if (ev->alpha < 1.0) + return false; + + if (ev->surface->is_opaque) + return true; + + if (ev->transform.dirty) { + weston_log("%s: transform dirty", __func__); + return false; + } + + pixman_region32_init(&r); + pixman_region32_subtract(&r, region, &ev->transform.opaque); + + if (!pixman_region32_not_empty(&r)) + ret = true; + + pixman_region32_fini(&r); + + return ret; +} + /* Check if a surface has a view assigned to it * * The indicator is set manually when mapping diff --git a/libweston/compositor.h b/libweston/compositor.h index 6a57b829..34432ba9 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -1868,6 +1868,9 @@ weston_view_set_mask_infinite(struct weston_view *view); bool weston_view_is_mapped(struct weston_view *view); +bool +weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region); + void weston_view_schedule_repaint(struct weston_view *view);