aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-12 11:03:49 +0200
committerSimon Ser <contact@emersion.fr>2021-04-19 18:09:13 +0200
commitf64ed60c7b6caaea9a4331fb9481b151cd1631bb (patch)
tree2ceb61ceff4d42b985ee5863c652c3ce32807159
parentfbc2182b9fbe9437181caf23a8cb0b9ada90800f (diff)
linux-dmabuf-v1: drop some from_resource helpers
Drop wlr_dmabuf_v1_buffer_from_params_resource and wlr_linux_dmabuf_v1_from_resource. Contrary to wl_buffer, these resources are internal linux-dmabuf-v1 implementation details and should not be shared with other interfaces.
-rw-r--r--include/wlr/types/wlr_linux_dmabuf_v1.h14
-rw-r--r--types/wlr_linux_dmabuf_v1.c66
2 files changed, 35 insertions, 45 deletions
diff --git a/include/wlr/types/wlr_linux_dmabuf_v1.h b/include/wlr/types/wlr_linux_dmabuf_v1.h
index 64e2bd48..1d1a00eb 100644
--- a/include/wlr/types/wlr_linux_dmabuf_v1.h
+++ b/include/wlr/types/wlr_linux_dmabuf_v1.h
@@ -34,13 +34,6 @@ bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource);
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource(
struct wl_resource *buffer_resource);
-/**
- * Returns the wlr_dmabuf_buffer if the given resource was created
- * via the linux-dmabuf params protocol
- */
-struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_params_resource(
- struct wl_resource *params_resource);
-
/* the protocol interface */
struct wlr_linux_dmabuf_v1 {
struct wl_global *global;
@@ -60,11 +53,4 @@ struct wlr_linux_dmabuf_v1 {
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display,
struct wlr_renderer *renderer);
-/**
- * Returns the wlr_linux_dmabuf if the given resource was created
- * via the linux_dmabuf protocol
- */
-struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_from_resource(
- struct wl_resource *resource);
-
#endif
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 5fea0a79..4db80eca 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -58,6 +58,24 @@ static void linux_dmabuf_buffer_destroy(struct wlr_dmabuf_v1_buffer *buffer) {
free(buffer);
}
+static const struct zwp_linux_buffer_params_v1_interface linux_buffer_params_impl;
+
+static struct wlr_dmabuf_v1_buffer *buffer_from_params_resource(
+ struct wl_resource *params_resource) {
+ assert(wl_resource_instance_of(params_resource,
+ &zwp_linux_buffer_params_v1_interface,
+ &linux_buffer_params_impl));
+
+ struct wlr_dmabuf_v1_buffer *buffer =
+ wl_resource_get_user_data(params_resource);
+ assert(buffer);
+ assert(buffer->params_resource);
+ assert(!buffer->buffer_resource);
+ assert(buffer->params_resource == params_resource);
+
+ return buffer;
+}
+
static void params_destroy(struct wl_client *client,
struct wl_resource *resource) {
wl_resource_destroy(resource);
@@ -68,7 +86,7 @@ static void params_add(struct wl_client *client,
uint32_t plane_idx, uint32_t offset, uint32_t stride,
uint32_t modifier_hi, uint32_t modifier_lo) {
struct wlr_dmabuf_v1_buffer *buffer =
- wlr_dmabuf_v1_buffer_from_params_resource(params_resource);
+ buffer_from_params_resource(params_resource);
if (!buffer) {
wl_resource_post_error(params_resource,
@@ -144,7 +162,7 @@ static void params_create_common(struct wl_client *client,
return;
}
struct wlr_dmabuf_v1_buffer *buffer =
- wlr_dmabuf_v1_buffer_from_params_resource(params_resource);
+ buffer_from_params_resource(params_resource);
/* Switch the linux_dmabuf_buffer object from params resource to
* eventually wl_buffer resource. */
@@ -305,38 +323,34 @@ static const struct zwp_linux_buffer_params_v1_interface
.create_immed = params_create_immed,
};
-struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_params_resource(
- struct wl_resource *params_resource) {
- assert(wl_resource_instance_of(params_resource,
- &zwp_linux_buffer_params_v1_interface,
- &linux_buffer_params_impl));
-
- struct wlr_dmabuf_v1_buffer *buffer =
- wl_resource_get_user_data(params_resource);
- assert(buffer);
- assert(buffer->params_resource);
- assert(!buffer->buffer_resource);
- assert(buffer->params_resource == params_resource);
-
- return buffer;
-}
-
static void handle_params_destroy(struct wl_resource *params_resource) {
- /* Check for NULL since wlr_dmabuf_v1_buffer_from_params_resource will choke */
+ /* Check for NULL since buffer_from_params_resource will choke */
if (!wl_resource_get_user_data(params_resource)) {
return;
}
struct wlr_dmabuf_v1_buffer *buffer =
- wlr_dmabuf_v1_buffer_from_params_resource(params_resource);
+ buffer_from_params_resource(params_resource);
linux_dmabuf_buffer_destroy(buffer);
}
+static const struct zwp_linux_dmabuf_v1_interface linux_dmabuf_impl;
+
+static struct wlr_linux_dmabuf_v1 *linux_dmabuf_from_resource(
+ struct wl_resource *resource) {
+ assert(wl_resource_instance_of(resource, &zwp_linux_dmabuf_v1_interface,
+ &linux_dmabuf_impl));
+
+ struct wlr_linux_dmabuf_v1 *dmabuf = wl_resource_get_user_data(resource);
+ assert(dmabuf);
+ return dmabuf;
+}
+
static void linux_dmabuf_create_params(struct wl_client *client,
struct wl_resource *linux_dmabuf_resource,
uint32_t params_id) {
struct wlr_linux_dmabuf_v1 *linux_dmabuf =
- wlr_linux_dmabuf_v1_from_resource(linux_dmabuf_resource);
+ linux_dmabuf_from_resource(linux_dmabuf_resource);
uint32_t version = wl_resource_get_version(linux_dmabuf_resource);
struct wlr_dmabuf_v1_buffer *buffer = calloc(1, sizeof *buffer);
@@ -375,16 +389,6 @@ static const struct zwp_linux_dmabuf_v1_interface linux_dmabuf_impl = {
.create_params = linux_dmabuf_create_params,
};
-struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_from_resource(
- struct wl_resource *resource) {
- assert(wl_resource_instance_of(resource, &zwp_linux_dmabuf_v1_interface,
- &linux_dmabuf_impl));
-
- struct wlr_linux_dmabuf_v1 *dmabuf = wl_resource_get_user_data(resource);
- assert(dmabuf);
- return dmabuf;
-}
-
static void linux_dmabuf_send_modifiers(struct wl_resource *resource,
const struct wlr_drm_format *fmt) {
if (wl_resource_get_version(resource) < ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION) {