[PATCH weston 01/18] compositor: add capability flag for arbitrary surface rotation

ppaalanen at gmail.com ppaalanen at gmail.com
Wed May 22 08:03:04 PDT 2013


From: Pekka Paalanen <ppaalanen at gmail.com>

The upcoming rpi-renderer cannot handle arbitrary rotations. Introduce
Weston capability bits, and add a bit for arbitrary rotation. GL and
Pixman renderers support it.

Shell or any other module must not produce surface transformations with
rotation, if the capability bit is not set. Do not register the surface
rotation binding in desktop shell, if arbitary rotation is not
supported.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 src/compositor.c      | 24 ++++++++++++++++++++++++
 src/compositor.h      |  6 ++++++
 src/gl-renderer.c     |  1 +
 src/pixman-renderer.c |  1 +
 src/shell.c           |  7 +++++--
 5 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index f67028e..657e134 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2820,6 +2820,28 @@ weston_version(int *major, int *minor, int *micro)
 	*micro = WESTON_VERSION_MICRO;
 }
 
+static const struct {
+	uint32_t bit;
+	const char *desc;
+} capability_strings[] = {
+	{ WESTON_CAP_ROTATION_ANY, "arbitrary surface rotation:" },
+};
+
+static void
+weston_compositor_log_capabilities(struct weston_compositor *compositor)
+{
+	unsigned i;
+	int yes;
+
+	weston_log("Compositor capabilities:\n");
+	for (i = 0; i < ARRAY_LENGTH(capability_strings); i++) {
+		yes = compositor->capabilities & capability_strings[i].bit;
+		weston_log_continue(STAMP_SPACE "%s %s\n",
+				    capability_strings[i].desc,
+				    yes ? "yes" : "no");
+	}
+}
+
 static int on_term_signal(int signal_number, void *data)
 {
 	struct wl_display *display = data;
@@ -3214,6 +3236,8 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
+	weston_compositor_log_capabilities(ec);
+
 	if (wl_display_add_socket(display, socket_name)) {
 		weston_log("fatal: failed to add socket: %m\n");
 		ret = EXIT_FAILURE;
diff --git a/src/compositor.h b/src/compositor.h
index 318fc0d..e7d19b0 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -484,6 +484,11 @@ struct weston_renderer {
 	void (*destroy)(struct weston_compositor *ec);
 };
 
+enum weston_capability {
+	/* backend/renderer supports arbitrary rotation */
+	WESTON_CAP_ROTATION_ANY			= 0x0001,
+};
+
 struct weston_compositor {
 	struct wl_signal destroy_signal;
 
@@ -525,6 +530,7 @@ struct weston_compositor {
 
 	/* Repaint state. */
 	struct weston_plane primary_plane;
+	uint32_t capabilities; /* combination of enum weston_capability */
 
 	uint32_t focus;
 
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index be74eba..87b3be0 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1837,6 +1837,7 @@ gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
 	}
 
 	ec->renderer = &gr->base;
+	ec->capabilities |= WESTON_CAP_ROTATION_ANY;
 
 	return 0;
 
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 60800bc..ad79c95 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -496,6 +496,7 @@ pixman_renderer_init(struct weston_compositor *ec)
 	renderer->base.destroy_surface = pixman_renderer_destroy_surface;
 	renderer->base.destroy = pixman_renderer_destroy;
 	ec->renderer = &renderer->base;
+	ec->capabilities |= WESTON_CAP_ROTATION_ANY;
 
 	weston_compositor_add_debug_binding(ec, KEY_R,
 					    debug_binding, ec);
diff --git a/src/shell.c b/src/shell.c
index 7261570..e23c09b 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -4247,8 +4247,11 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
 					     shell);
 	weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod,
 					     resize_binding, shell);
-	weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
-					     rotate_binding, NULL);
+
+	if (ec->capabilities & WESTON_CAP_ROTATION_ANY)
+		weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
+						     rotate_binding, NULL);
+
 	weston_compositor_add_key_binding(ec, KEY_TAB, mod, switcher_binding,
 					  shell);
 	weston_compositor_add_key_binding(ec, KEY_F9, mod, backlight_binding,
-- 
1.8.1.5



More information about the wayland-devel mailing list