[PATCH weston v2] compositor: add a masking mechanism to weston_view
Giulio Camuffo
giuliocamuffo at gmail.com
Wed Dec 4 06:29:14 PST 2013
This adds a 'mask' pixman_region32 to weston_view::geometry and
to weston_view::transform.
A user, a shell probably, can set a view's geometry.mask to some region
in the global space (e.g. the workspace area) and the view, and all its
transform children, will be clipped to that region.
weston_view::transform.mask is the intersection of the view's geometry.mask
and of the parent's transform.mask.
---
v2: weston_view::mask -> weston_view::geometry.mask
weston_view::geometry.mask -> weston_view::transform.mask
rebased on top of master
src/compositor.c | 25 +++++++++++++++++++++++--
src/compositor.h | 2 ++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 8f4bdef..c36a566 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -366,6 +366,8 @@ weston_view_create(struct weston_surface *surface)
view->plane = NULL;
pixman_region32_init(&view->clip);
+ region_init_infinite(&view->geometry.mask);
+ pixman_region32_init(&view->transform.mask);
view->alpha = 1.0;
pixman_region32_init(&view->transform.opaque);
@@ -926,6 +928,11 @@ weston_view_update_transform(struct weston_view *view)
weston_view_damage_below(view);
+ if (parent)
+ pixman_region32_intersect(&view->transform.mask, &view->geometry.mask, &parent->transform.mask);
+ else
+ pixman_region32_copy(&view->transform.mask, &view->geometry.mask);
+
pixman_region32_fini(&view->transform.boundingbox);
pixman_region32_fini(&view->transform.opaque);
pixman_region32_init(&view->transform.opaque);
@@ -1193,10 +1200,14 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
wl_fixed_t *vx, wl_fixed_t *vy)
{
struct weston_view *view;
+ int ix = wl_fixed_to_int(x);
+ int iy = wl_fixed_to_int(y);
wl_list_for_each(view, &compositor->view_list, link) {
weston_view_from_global_fixed(view, x, y, vx, vy);
- if (pixman_region32_contains_point(&view->surface->input,
+ if (pixman_region32_contains_point(&view->transform.mask,
+ ix, iy, NULL) &&
+ pixman_region32_contains_point(&view->surface->input,
wl_fixed_to_int(*vx),
wl_fixed_to_int(*vy),
NULL))
@@ -1284,6 +1295,8 @@ weston_view_destroy(struct weston_view *view)
pixman_region32_fini(&view->clip);
pixman_region32_fini(&view->transform.boundingbox);
+ pixman_region32_fini(&view->geometry.mask);
+ pixman_region32_fini(&view->transform.mask);
weston_view_set_transform_parent(view, NULL);
@@ -1489,7 +1502,15 @@ view_accumulate_damage(struct weston_view *view,
pixman_region32_union(&view->plane->damage,
&view->plane->damage, &damage);
pixman_region32_fini(&damage);
- pixman_region32_copy(&view->clip, opaque);
+
+ /* set view->clip with the part of view->transform.boundingbox
+ * that doesn't fit into view->transform.mask, then add the opaque region
+ * to it. We don't do the opposite, adding view->clip to opaque,
+ * because opaque is then passed to the next views, which may have
+ * a different mask.
+ */
+ pixman_region32_subtract(&view->clip, &view->transform.boundingbox, &view->transform.mask);
+ pixman_region32_union(&view->clip, &view->clip, opaque);
pixman_region32_union(opaque, opaque, &view->transform.opaque);
}
diff --git a/src/compositor.h b/src/compositor.h
index 6bd637e..222f88b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -761,6 +761,7 @@ struct weston_view {
*/
struct {
float x, y; /* surface translation on display */
+ pixman_region32_t mask;
/* struct weston_transform */
struct wl_list transformation_list;
@@ -780,6 +781,7 @@ struct weston_view {
pixman_region32_t boundingbox;
pixman_region32_t opaque;
+ pixman_region32_t mask;
/* matrix and inverse are used only if enabled = 1.
* If enabled = 0, use x, y, width, height directly.
--
1.8.4.2
More information about the wayland-devel
mailing list