[PATCH weston 03/13] compositor: Implement stereoscopy as a noop.
Emmanuel Gil Peyrot
linkmauve at linkmauve.fr
Tue Nov 14 15:05:50 UTC 2017
Signed-off-by: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
---
libweston/compositor.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++
libweston/compositor.h | 11 ++++
2 files changed, 151 insertions(+)
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 71a9b38c..dc2b563a 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -56,6 +56,7 @@
#include "compositor.h"
#include "viewporter-server-protocol.h"
#include "presentation-time-server-protocol.h"
+#include "stereoscopy-unstable-v1-server-protocol.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "shared/string-helpers.h"
@@ -411,6 +412,8 @@ weston_surface_state_init(struct weston_surface_state *state)
state->buffer_viewport.buffer.scale = 1;
state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
state->buffer_viewport.surface.width = -1;
+ state->buffer_viewport.buffer.stereoscopy_layout = ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+ state->buffer_viewport.surface.default_side = ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
state->buffer_viewport.changed = 0;
}
@@ -469,6 +472,8 @@ weston_surface_create(struct weston_compositor *compositor)
surface->buffer_viewport.buffer.scale = 1;
surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
surface->buffer_viewport.surface.width = -1;
+ surface->buffer_viewport.buffer.stereoscopy_layout = ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+ surface->buffer_viewport.surface.default_side = ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
weston_surface_state_init(&surface->pending);
@@ -3070,6 +3075,8 @@ weston_surface_commit_state(struct weston_surface *surface,
/* wl_surface.set_buffer_scale */
/* wp_viewport.set_source */
/* wp_viewport.set_destination */
+ /* wp_stereoscopy_description.set_layout */
+ /* wp_stereoscopy_description.set_default_side */
surface->buffer_viewport = state->buffer_viewport;
/* wl_surface.attach */
@@ -5123,6 +5130,135 @@ bind_viewporter(struct wl_client *client,
NULL, NULL);
}
+static void
+destroy_stereoscopy_description(struct wl_resource *resource)
+{
+ struct weston_surface *surface =
+ wl_resource_get_user_data(resource);
+
+ surface->stereoscopy_description_resource = NULL;
+ surface->pending.buffer_viewport.buffer.stereoscopy_layout = ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+ surface->pending.buffer_viewport.surface.default_side = ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
+ surface->pending.buffer_viewport.changed = 1;
+}
+
+static void
+stereoscopy_description_destroy(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ wl_resource_destroy(resource);
+}
+
+static void
+stereoscopy_description_set_layout(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t layout)
+{
+ struct weston_surface *surface =
+ wl_resource_get_user_data(resource);
+
+ assert(surface->stereoscopy_description_resource != NULL);
+
+ if (layout > ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE) {
+ wl_resource_post_error(resource,
+ ZWP_STEREOSCOPY_DESCRIPTION_V1_ERROR_INVALID_LAYOUT,
+ "wrong stereoscopy layout %u",
+ layout);
+ return;
+ }
+
+ surface->pending.buffer_viewport.buffer.stereoscopy_layout = layout;
+ surface->pending.buffer_viewport.changed = 1;
+}
+
+static void
+stereoscopy_description_set_default_side(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t default_side)
+{
+ struct weston_surface *surface =
+ wl_resource_get_user_data(resource);
+
+ assert(surface->stereoscopy_description_resource != NULL);
+
+ if (default_side > ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_RIGHT) {
+ wl_resource_post_error(resource,
+ ZWP_STEREOSCOPY_DESCRIPTION_V1_ERROR_INVALID_DEFAULT_SIDE,
+ "default side can only be default, left or right, not %u",
+ default_side);
+ return;
+ }
+
+ surface->pending.buffer_viewport.surface.default_side = default_side;
+ surface->pending.buffer_viewport.changed = 1;
+}
+
+static const struct zwp_stereoscopy_description_v1_interface stereoscopy_description_interface = {
+ stereoscopy_description_destroy,
+ stereoscopy_description_set_layout,
+ stereoscopy_description_set_default_side
+};
+
+static void
+stereoscopy_destroy(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ wl_resource_destroy(resource);
+}
+
+static void
+stereoscopy_create_description(struct wl_client *client,
+ struct wl_resource *stereoscopy,
+ struct wl_resource *surface_resource,
+ uint32_t id)
+{
+ int version = wl_resource_get_version(stereoscopy);
+ struct weston_surface *surface =
+ wl_resource_get_user_data(surface_resource);
+ struct wl_resource *resource;
+
+ if (surface->stereoscopy_description_resource) {
+ wl_resource_post_error(stereoscopy,
+ ZWP_STEREOSCOPY_V1_ERROR_STEREOSCOPY_DESCRIPTION_EXISTS,
+ "a stereoscopy_description for that surface already exists");
+ return;
+ }
+
+ resource = wl_resource_create(client, &zwp_stereoscopy_description_v1_interface,
+ version, id);
+ if (resource == NULL) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ wl_resource_set_implementation(resource, &stereoscopy_description_interface,
+ surface, destroy_stereoscopy_description);
+
+ surface->stereoscopy_description_resource = resource;
+}
+
+static const struct zwp_stereoscopy_v1_interface stereoscopy_interface = {
+ stereoscopy_destroy,
+ stereoscopy_create_description
+};
+
+static void
+bind_stereoscopy(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct wl_resource *resource;
+
+ resource = wl_resource_create(client, &zwp_stereoscopy_v1_interface,
+ version, id);
+ if (resource == NULL) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ wl_resource_set_implementation(resource, &stereoscopy_interface,
+ NULL, NULL);
+}
+
static void
destroy_presentation_feedback(struct wl_resource *feedback_resource)
{
@@ -5310,6 +5446,10 @@ weston_compositor_create(struct wl_display *display, void *user_data)
ec, bind_presentation))
goto fail;
+ if (!wl_global_create(ec->wl_display, &zwp_stereoscopy_v1_interface, 1,
+ ec, bind_stereoscopy))
+ goto fail;
+
if (weston_input_init(ec) != 0)
goto fail;
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 8b2d2b06..fd4fb2ed 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -979,6 +979,9 @@ struct weston_buffer_viewport {
*/
wl_fixed_t src_x, src_y;
wl_fixed_t src_width, src_height;
+
+ /* wp_stereoscopy_description.set_layout */
+ uint32_t stereoscopy_layout;
} buffer;
struct {
@@ -986,6 +989,9 @@ struct weston_buffer_viewport {
* If width == -1, the size is inferred from the buffer.
*/
int32_t width, height;
+
+ /* wp_stereoscopy_description.set_default_side */
+ uint32_t default_side;
} surface;
int changed;
@@ -1139,6 +1145,8 @@ struct weston_surface_state {
/* wl_surface.set_scaling_factor */
/* wp_viewport.set_source */
/* wp_viewport.set_destination */
+ /* wp_stereoscopy_description.set_layout */
+ /* wp_stereoscopy_description.set_default_side */
struct weston_buffer_viewport buffer_viewport;
};
@@ -1222,6 +1230,9 @@ struct weston_surface {
/* wp_viewport resource for this surface */
struct wl_resource *viewport_resource;
+ /* wp_stereoscopy_description resource for this surface */
+ struct wl_resource *stereoscopy_description_resource;
+
/* All the pending state, that wl_surface.commit will apply. */
struct weston_surface_state pending;
--
2.15.0
More information about the wayland-devel
mailing list