[weston RFC 2/5] compositor: let renderers register the wl_shm global
Tomeu Vizoso
tomeu at tomeuvizoso.net
Fri Jul 5 02:41:12 PDT 2013
So in the future each can announce the formats it supports.
TODO: properly fix the naming conflict with wl_shm_create_pool_xxx
---
src/compositor.c | 2 --
src/gl-renderer.c | 20 ++++++++++++++++++++
src/pixman-renderer.c | 22 ++++++++++++++++++++++
src/rpi-renderer.c | 20 ++++++++++++++++++++
4 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 8e74dbc..e2e5ada 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2865,8 +2865,6 @@ weston_compositor_init(struct weston_compositor *ec,
wl_data_device_manager_init(ec->wl_display);
- wl_display_init_shm(display);
-
loop = wl_display_get_event_loop(ec->wl_display);
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
wl_event_source_timer_update(ec->idle_source, ec->idle_time * 1000);
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d13781c..bfccd7b 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1863,6 +1863,23 @@ WL_EXPORT const EGLint gl_renderer_alpha_attribs[] = {
EGL_NONE
};
+static const struct wl_shm_interface shm_interface = {
+ wl_shm_create_pool_xxx
+};
+
+static void
+bind_shm(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct wl_resource *resource;
+
+ resource = wl_client_add_object(client, &wl_shm_interface,
+ &shm_interface, id, data);
+
+ wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
+ wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
+}
+
WL_EXPORT int
gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
const EGLint *attribs, const EGLint *visual_id)
@@ -1904,6 +1921,9 @@ gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
ec->capabilities |= WESTON_CAP_ROTATION_ANY;
ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
+ if (!wl_display_add_global(ec->wl_display, &wl_shm_interface, NULL, bind_shm))
+ return -1;
+
return 0;
err_egl:
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 25bffbe..b17c02f 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -652,6 +652,23 @@ debug_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
}
}
+static const struct wl_shm_interface shm_interface = {
+ wl_shm_create_pool_xxx
+};
+
+static void
+bind_shm(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct wl_resource *resource;
+
+ resource = wl_client_add_object(client, &wl_shm_interface,
+ &shm_interface, id, data);
+
+ wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
+ wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
+}
+
WL_EXPORT int
pixman_renderer_init(struct weston_compositor *ec)
{
@@ -677,6 +694,11 @@ pixman_renderer_init(struct weston_compositor *ec)
weston_compositor_add_debug_binding(ec, KEY_R,
debug_binding, ec);
+
+ if (!wl_display_add_global(ec->wl_display, &wl_shm_interface, NULL,
+ bind_shm))
+ return -1;
+
return 0;
}
diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
index 919ecc5..eb64675 100644
--- a/src/rpi-renderer.c
+++ b/src/rpi-renderer.c
@@ -1258,6 +1258,23 @@ rpi_renderer_destroy(struct weston_compositor *compositor)
compositor->renderer = NULL;
}
+static const struct wl_shm_interface shm_interface = {
+ wl_shm_create_pool_xxx
+};
+
+static void
+bind_shm(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct wl_resource *resource;
+
+ resource = wl_client_add_object(client, &wl_shm_interface,
+ &shm_interface, id, data);
+
+ wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
+ wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
+}
+
WL_EXPORT int
rpi_renderer_create(struct weston_compositor *compositor,
const struct rpi_renderer_parameters *params)
@@ -1285,6 +1302,9 @@ rpi_renderer_create(struct weston_compositor *compositor,
compositor->read_format = PIXMAN_a8r8g8b8;
/* WESTON_CAP_ROTATION_ANY not supported */
+ if (!wl_display_add_global(compositor->wl_display, &wl_shm_interface, NULL, bind_shm))
+ return -1;
+
return 0;
}
--
1.8.3.1
More information about the wayland-devel
mailing list