[wayland RFC 2/2] shm: Expose wl_shm_create_pool

Tomeu Vizoso tomeu at tomeuvizoso.net
Fri Jul 5 02:41:13 PDT 2013


So renderers can register wl_shm themselves in order to advertise
the formats that they support.

TODO: properly solve the naming conflict with wl_shm_create_pool
---
 src/wayland-server.h |  5 +++--
 src/wayland-shm.c    | 35 ++---------------------------------
 2 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 0a798f4..5520abf 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -310,8 +310,9 @@ wl_shm_buffer_get_width(struct wl_shm_buffer *buffer);
 int32_t
 wl_shm_buffer_get_height(struct wl_shm_buffer *buffer);
 
-int
-wl_display_init_shm(struct wl_display *display);
+void
+wl_shm_create_pool_xxx(struct wl_client *client, struct wl_resource *resource,
+		uint32_t id, int fd, int32_t size);
 
 struct wl_shm_buffer *
 wl_shm_buffer_create(struct wl_client *client,
diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index 4d4f3fd..8bcd71b 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -186,8 +186,8 @@ struct wl_shm_pool_interface shm_pool_interface = {
 	shm_pool_resize
 };
 
-static void
-shm_create_pool(struct wl_client *client, struct wl_resource *resource,
+WL_EXPORT void
+wl_shm_create_pool_xxx(struct wl_client *client, struct wl_resource *resource,
 		uint32_t id, int fd, int32_t size)
 {
 	struct wl_shm_pool *pool;
@@ -238,37 +238,6 @@ err_free:
 	free(pool);
 }
 
-static const struct wl_shm_interface shm_interface = {
-	shm_create_pool
-};
-
-static void
-bind_shm(struct wl_client *client,
-	 void *data, uint32_t version, uint32_t id)
-{
-	struct wl_resource *resource;
-
-	resource = wl_resource_create(client, &wl_shm_interface, 1, id);
-	if (!resource) {
-		wl_client_post_no_memory(client);
-		return;
-	}
-
-	wl_resource_set_implementation(resource, &shm_interface, data, NULL);
-
-	wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
-	wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
-}
-
-WL_EXPORT int
-wl_display_init_shm(struct wl_display *display)
-{
-	if (!wl_display_add_global(display, &wl_shm_interface, NULL, bind_shm))
-		return -1;
-
-	return 0;
-}
-
 WL_EXPORT struct wl_shm_buffer *
 wl_shm_buffer_create(struct wl_client *client,
 		     uint32_t id, int32_t width, int32_t height,
-- 
1.8.3.1



More information about the wayland-devel mailing list