compositor: add weston_view_set_mask() API and state
Add API for setting a clip ('scissor' in the code) rectangle per view,
in surface coordinates. Ivi-shell requires this feature to be able to
implement the IVI Layer Manager API, which includes clipping of
surfaces.
The names weston_view_set_mask() and weston_view_set_mask_infinite()
mirror the existing weston_layer_set_mask*() functions.
This view clipping complements the weston_layer clipping, because view
clipping is defined in surface local coordinates, while layer
mask/clipping is defined in global coordinates.
View clipping requires explicit support from the renderers. Therefore a
new Weston capability bit is added: WESTON_CAP_VIEW_CLIP_MASK. Shells
(and all users) of this new API are required to check the capability bit
is set before using the API. Otherwise the rendering will not be what
they expect.
View clips are inherited through the transformation inheritance
mechanism. However, there are restrictions. The clip rectangle can be
set only on the root view of a transformation inheritance tree. The
additional transformations in child views must not rotate the coordinate
axes. These restrictions avoid corner cases in clip inheritance, and
keep the renderer implementations as simple as they are right now.
Renderers only need to do an additional intersection with the clip
rectangle which is always aligned to the surface coordinate system.
For more details, see the API documentation in the patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Tested-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
diff --git a/src/compositor.h b/src/compositor.h
index 099d187..f4ba7a5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -599,6 +599,9 @@
/* backend supports setting arbitrary resolutions */
WESTON_CAP_ARBITRARY_MODES = 0x0008,
+
+ /* renderer supports weston_view_set_mask() clipping */
+ WESTON_CAP_VIEW_CLIP_MASK = 0x0010,
};
struct weston_compositor {
@@ -797,6 +800,10 @@
struct wl_listener parent_destroy_listener;
struct wl_list child_list; /* geometry.parent_link */
struct wl_list parent_link;
+
+ /* managed by weston_view_set_mask() */
+ bool scissor_enabled;
+ pixman_region32_t scissor; /* always a simple rect */
} geometry;
/* State derived from geometry state, read-only.
@@ -1244,6 +1251,13 @@
weston_view_set_transform_parent(struct weston_view *view,
struct weston_view *parent);
+void
+weston_view_set_mask(struct weston_view *view,
+ int x, int y, int width, int height);
+
+void
+weston_view_set_mask_infinite(struct weston_view *view);
+
bool
weston_view_is_mapped(struct weston_view *view);