mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-13 00:45:58 +01:00
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.
This commit is contained in:
parent
fbc2182b9f
commit
f64ed60c7b
2 changed files with 35 additions and 45 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue