/** Load a cursor theme to memory shared with the compositor * * \param name The name of the cursor theme to load. If %NULL, the default * theme will be loaded. * \param size Desired size of the cursor images. * \param shm The compositor's shm interface. * * \return An object representing the theme that should be destroyed with * wl_cursor_theme_destroy() or %NULL on error. If no theme with the given * name exists, a default theme will be loaded. */ WL_EXPORT struct wl_cursor_theme * wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm) { struct wl_cursor_theme *theme; theme = malloc(sizeof *theme); if (!theme) return NULL; if (!name) name = "default"; theme->name = strdup(name); theme->size = size; theme->cursor_count = 0; theme->cursors = NULL; theme->pool = shm_pool_create(shm, size * size * 4); if (!theme->pool) { free(theme->name); free(theme); return NULL; } xcursor_load_theme(name, size, load_callback, theme); if (theme->cursor_count == 0) load_default_theme(theme); return theme; }
static GstWlMeta * gst_buffer_add_wayland_meta (GstBuffer * buffer, GstWaylandBufferPool * wpool) { GstWlMeta *wmeta; GstWaylandSink *sink; void *data; gint offset; guint stride = 0; guint size = 0; sink = wpool->sink; stride = wpool->width * 4; size = stride * wpool->height; wmeta = (GstWlMeta *) gst_buffer_add_meta (buffer, GST_WL_META_INFO, NULL); wmeta->sink = gst_object_ref (sink); /*Fixme: size calculation should be more grcefull, have to consider the padding */ if (!sink->shm_pool) { sink->shm_pool = shm_pool_create (sink->display, size * 15); shm_pool_reset (sink->shm_pool); } if (!sink->shm_pool) { GST_ERROR ("Failed to create shm_pool"); return NULL; } data = shm_pool_allocate (sink->shm_pool, size, &offset); if (!data) return NULL; wmeta->wbuffer = wl_shm_pool_create_buffer (sink->shm_pool->pool, offset, sink->video_width, sink->video_height, stride, sink->format); wmeta->data = data; wmeta->size = size; gst_buffer_append_memory (buffer, gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, data, size, 0, size, NULL, NULL)); return wmeta; }