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 <philipp.zabel@gmail.com>
This commit is contained in:
parent
195dadeb2a
commit
70decd5b2b
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue