mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
backend: remove wlr_backend_get_egl
This commit is contained in:
parent
f4125220a5
commit
d2ebbd103c
16 changed files with 127 additions and 111 deletions
|
@ -47,13 +47,6 @@ void wlr_backend_destroy(struct wlr_backend *backend) {
|
|||
}
|
||||
}
|
||||
|
||||
struct wlr_egl *wlr_backend_get_egl(struct wlr_backend *backend) {
|
||||
if (backend->impl->get_egl) {
|
||||
return backend->impl->get_egl(backend);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend) {
|
||||
if (backend->impl->get_renderer) {
|
||||
return backend->impl->get_renderer(backend);
|
||||
|
|
|
@ -48,11 +48,6 @@ static void wlr_drm_backend_destroy(struct wlr_backend *backend) {
|
|||
free(drm);
|
||||
}
|
||||
|
||||
static struct wlr_egl *wlr_drm_backend_get_egl(struct wlr_backend *backend) {
|
||||
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)backend;
|
||||
return &drm->renderer.egl;
|
||||
}
|
||||
|
||||
static struct wlr_renderer *wlr_drm_backend_get_renderer(
|
||||
struct wlr_backend *backend) {
|
||||
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)backend;
|
||||
|
@ -62,7 +57,6 @@ static struct wlr_renderer *wlr_drm_backend_get_renderer(
|
|||
static struct wlr_backend_impl backend_impl = {
|
||||
.start = wlr_drm_backend_start,
|
||||
.destroy = wlr_drm_backend_destroy,
|
||||
.get_egl = wlr_drm_backend_get_egl,
|
||||
.get_renderer = wlr_drm_backend_get_renderer,
|
||||
};
|
||||
|
||||
|
|
|
@ -58,12 +58,6 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
free(backend);
|
||||
}
|
||||
|
||||
static struct wlr_egl *backend_get_egl(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_headless_backend *backend =
|
||||
(struct wlr_headless_backend *)wlr_backend;
|
||||
return &backend->egl;
|
||||
}
|
||||
|
||||
static struct wlr_renderer *backend_get_renderer(
|
||||
struct wlr_backend *wlr_backend) {
|
||||
struct wlr_headless_backend *backend =
|
||||
|
@ -74,7 +68,6 @@ static struct wlr_renderer *backend_get_renderer(
|
|||
static const struct wlr_backend_impl backend_impl = {
|
||||
.start = backend_start,
|
||||
.destroy = backend_destroy,
|
||||
.get_egl = backend_get_egl,
|
||||
.get_renderer = backend_get_renderer,
|
||||
};
|
||||
|
||||
|
|
|
@ -52,18 +52,6 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
free(backend);
|
||||
}
|
||||
|
||||
static struct wlr_egl *multi_backend_get_egl(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_multi_backend *backend = (struct wlr_multi_backend *)wlr_backend;
|
||||
struct subbackend_state *sub;
|
||||
wl_list_for_each(sub, &backend->backends, link) {
|
||||
struct wlr_egl *egl = wlr_backend_get_egl(sub->backend);
|
||||
if (egl) {
|
||||
return egl;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct wlr_renderer *multi_backend_get_renderer(
|
||||
struct wlr_backend *backend) {
|
||||
struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend;
|
||||
|
@ -80,7 +68,6 @@ static struct wlr_renderer *multi_backend_get_renderer(
|
|||
struct wlr_backend_impl backend_impl = {
|
||||
.start = multi_backend_start,
|
||||
.destroy = multi_backend_destroy,
|
||||
.get_egl = multi_backend_get_egl,
|
||||
.get_renderer = multi_backend_get_renderer,
|
||||
};
|
||||
|
||||
|
|
|
@ -110,11 +110,6 @@ static void wlr_wl_backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
free(backend);
|
||||
}
|
||||
|
||||
static struct wlr_egl *wlr_wl_backend_get_egl(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_wl_backend *backend = (struct wlr_wl_backend *)wlr_backend;
|
||||
return &backend->egl;
|
||||
}
|
||||
|
||||
static struct wlr_renderer *wlr_wl_backend_get_renderer(
|
||||
struct wlr_backend *wlr_backend) {
|
||||
struct wlr_wl_backend *backend = (struct wlr_wl_backend *)wlr_backend;
|
||||
|
@ -124,7 +119,6 @@ static struct wlr_renderer *wlr_wl_backend_get_renderer(
|
|||
static struct wlr_backend_impl backend_impl = {
|
||||
.start = wlr_wl_backend_start,
|
||||
.destroy = wlr_wl_backend_destroy,
|
||||
.get_egl = wlr_wl_backend_get_egl,
|
||||
.get_renderer = wlr_wl_backend_get_renderer,
|
||||
};
|
||||
|
||||
|
|
|
@ -257,11 +257,6 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) {
|
|||
free(x11);
|
||||
}
|
||||
|
||||
static struct wlr_egl *wlr_x11_backend_get_egl(struct wlr_backend *backend) {
|
||||
struct wlr_x11_backend *x11 = (struct wlr_x11_backend *)backend;
|
||||
return &x11->egl;
|
||||
}
|
||||
|
||||
static struct wlr_renderer *wlr_x11_backend_get_renderer(
|
||||
struct wlr_backend *backend) {
|
||||
struct wlr_x11_backend *x11 = (struct wlr_x11_backend *)backend;
|
||||
|
@ -271,7 +266,6 @@ static struct wlr_renderer *wlr_x11_backend_get_renderer(
|
|||
static const struct wlr_backend_impl backend_impl = {
|
||||
.start = wlr_x11_backend_start,
|
||||
.destroy = wlr_x11_backend_destroy,
|
||||
.get_egl = wlr_x11_backend_get_egl,
|
||||
.get_renderer = wlr_x11_backend_get_renderer,
|
||||
};
|
||||
|
||||
|
|
|
@ -37,10 +37,6 @@ bool wlr_backend_start(struct wlr_backend *backend);
|
|||
* automatically when the wl_display is destroyed.
|
||||
*/
|
||||
void wlr_backend_destroy(struct wlr_backend *backend);
|
||||
/**
|
||||
* Obtains the wlr_egl reference this backend is using.
|
||||
*/
|
||||
struct wlr_egl *wlr_backend_get_egl(struct wlr_backend *backend);
|
||||
/**
|
||||
* Obtains the wlr_renderer reference this backend is using.
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
struct wlr_backend_impl {
|
||||
bool (*start)(struct wlr_backend *backend);
|
||||
void (*destroy)(struct wlr_backend *backend);
|
||||
struct wlr_egl *(*get_egl)(struct wlr_backend *backend);
|
||||
struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend);
|
||||
};
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ struct wlr_renderer_impl {
|
|||
struct wl_resource *resource);
|
||||
void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer,
|
||||
struct wl_resource *buffer, int *width, int *height);
|
||||
bool (*check_import_dmabuf)(struct wlr_renderer *renderer,
|
||||
struct wlr_dmabuf_buffer *dmabuf);
|
||||
int (*get_dmabuf_formats)(struct wlr_renderer *renderer, int **formats);
|
||||
int (*get_dmabuf_modifiers)(struct wlr_renderer *renderer, int format,
|
||||
uint64_t **modifiers);
|
||||
bool (*read_pixels)(struct wlr_renderer *renderer, enum wl_shm_format fmt,
|
||||
uint32_t stride, uint32_t width, uint32_t height,
|
||||
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
|
||||
|
|
|
@ -64,6 +64,22 @@ bool wlr_renderer_resource_is_wl_drm_buffer(struct wlr_renderer *renderer,
|
|||
*/
|
||||
void wlr_renderer_wl_drm_buffer_get_size(struct wlr_renderer *renderer,
|
||||
struct wl_resource *buffer, int *width, int *height);
|
||||
/**
|
||||
* Get the available dmabuf formats
|
||||
*/
|
||||
int wlr_renderer_get_dmabuf_formats(struct wlr_renderer *renderer,
|
||||
int **formats);
|
||||
/**
|
||||
* Get the available dmabuf modifiers for a given format
|
||||
*/
|
||||
int wlr_renderer_get_dmabuf_modifiers(struct wlr_renderer *renderer, int format,
|
||||
uint64_t **modifiers);
|
||||
/**
|
||||
* Try to import the given dmabuf. On success return true false otherwise.
|
||||
* If this succeeds the dmabuf can be used for rendering on a texture
|
||||
*/
|
||||
bool wlr_renderer_check_import_dmabuf(struct wlr_renderer *renderer,
|
||||
struct wlr_dmabuf_buffer *dmabuf);
|
||||
/**
|
||||
* Reads out of pixels of the currently bound surface into data. `stride` is in
|
||||
* bytes.
|
||||
|
|
|
@ -32,7 +32,7 @@ struct wlr_dmabuf_buffer_attribs {
|
|||
};
|
||||
|
||||
struct wlr_dmabuf_buffer {
|
||||
struct wlr_egl *egl;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wl_resource *buffer_resource;
|
||||
struct wl_resource *params_resource;
|
||||
struct wlr_dmabuf_buffer_attribs attributes;
|
||||
|
@ -62,14 +62,14 @@ struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_params_resource(
|
|||
struct wlr_linux_dmabuf {
|
||||
struct wl_global *wl_global;
|
||||
struct wl_listener display_destroy;
|
||||
struct wlr_egl *egl;
|
||||
struct wlr_renderer *renderer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create linux-dmabuf interface
|
||||
*/
|
||||
struct wlr_linux_dmabuf *wlr_linux_dmabuf_create(struct wl_display *display,
|
||||
struct wlr_egl *egl);
|
||||
struct wlr_renderer *renderer);
|
||||
/**
|
||||
* Destroy the linux-dmabuf interface
|
||||
*/
|
||||
|
|
|
@ -222,6 +222,24 @@ static void gles2_wl_drm_buffer_get_size(struct wlr_renderer *wlr_renderer,
|
|||
eglQueryWaylandBufferWL(renderer->egl->display, buffer, EGL_HEIGHT, height);
|
||||
}
|
||||
|
||||
static int gles2_get_dmabuf_formats(struct wlr_renderer *wlr_renderer,
|
||||
int **formats) {
|
||||
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
||||
return wlr_egl_get_dmabuf_formats(renderer->egl, formats);
|
||||
}
|
||||
|
||||
static int gles2_get_dmabuf_modifiers(struct wlr_renderer *wlr_renderer,
|
||||
int format, uint64_t **modifiers) {
|
||||
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
||||
return wlr_egl_get_dmabuf_modifiers(renderer->egl, format, modifiers);
|
||||
}
|
||||
|
||||
static bool gles2_check_import_dmabuf(struct wlr_renderer *wlr_renderer,
|
||||
struct wlr_dmabuf_buffer *dmabuf) {
|
||||
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
||||
return wlr_egl_check_import_dmabuf(renderer->egl, dmabuf);
|
||||
}
|
||||
|
||||
static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer,
|
||||
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width,
|
||||
uint32_t height, uint32_t src_x, uint32_t src_y, uint32_t dst_x,
|
||||
|
@ -311,6 +329,9 @@ static const struct wlr_renderer_impl renderer_impl = {
|
|||
.formats = gles2_renderer_formats,
|
||||
.resource_is_wl_drm_buffer = gles2_resource_is_wl_drm_buffer,
|
||||
.wl_drm_buffer_get_size = gles2_wl_drm_buffer_get_size,
|
||||
.get_dmabuf_formats = gles2_get_dmabuf_formats,
|
||||
.get_dmabuf_modifiers = gles2_get_dmabuf_modifiers,
|
||||
.check_import_dmabuf = gles2_check_import_dmabuf,
|
||||
.read_pixels = gles2_read_pixels,
|
||||
.format_supported = gles2_format_supported,
|
||||
.texture_from_pixels = gles2_texture_from_pixels,
|
||||
|
|
|
@ -112,6 +112,30 @@ void wlr_renderer_wl_drm_buffer_get_size(struct wlr_renderer *r,
|
|||
return r->impl->wl_drm_buffer_get_size(r, buffer, width, height);
|
||||
}
|
||||
|
||||
int wlr_renderer_get_dmabuf_formats(struct wlr_renderer *r,
|
||||
int **formats) {
|
||||
if (!r->impl->get_dmabuf_formats) {
|
||||
return -1;
|
||||
}
|
||||
return r->impl->get_dmabuf_formats(r, formats);
|
||||
}
|
||||
|
||||
int wlr_renderer_get_dmabuf_modifiers(struct wlr_renderer *r, int format,
|
||||
uint64_t **modifiers) {
|
||||
if (!r->impl->get_dmabuf_modifiers) {
|
||||
return -1;
|
||||
}
|
||||
return r->impl->get_dmabuf_modifiers(r, format, modifiers);
|
||||
}
|
||||
|
||||
bool wlr_renderer_check_import_dmabuf(struct wlr_renderer *r,
|
||||
struct wlr_dmabuf_buffer *dmabuf) {
|
||||
if (!r->impl->check_import_dmabuf) {
|
||||
return false;
|
||||
}
|
||||
return r->impl->check_import_dmabuf(r, dmabuf);
|
||||
}
|
||||
|
||||
bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt,
|
||||
uint32_t stride, uint32_t width, uint32_t height,
|
||||
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
|
||||
|
|
|
@ -867,8 +867,8 @@ struct roots_desktop *desktop_create(struct roots_server *server,
|
|||
wl_signal_add(&desktop->input_inhibit->events.deactivate,
|
||||
&desktop->input_inhibit_deactivate);
|
||||
|
||||
struct wlr_egl *egl = wlr_backend_get_egl(server->backend);
|
||||
desktop->linux_dmabuf = wlr_linux_dmabuf_create(server->wl_display, egl);
|
||||
desktop->linux_dmabuf = wlr_linux_dmabuf_create(server->wl_display,
|
||||
server->renderer);
|
||||
return desktop;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#ifndef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "linux-dmabuf-unstable-v1-protocol.h"
|
||||
|
@ -25,7 +23,8 @@ bool wlr_dmabuf_resource_is_buffer(struct wl_resource *buffer_resource) {
|
|||
return false;
|
||||
}
|
||||
|
||||
struct wlr_dmabuf_buffer *buffer = wl_resource_get_user_data(buffer_resource);
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
wl_resource_get_user_data(buffer_resource);
|
||||
if (buffer && buffer->buffer_resource && !buffer->params_resource &&
|
||||
buffer->buffer_resource == buffer_resource) {
|
||||
return true;
|
||||
|
@ -39,7 +38,8 @@ struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_buffer_resource(
|
|||
assert(wl_resource_instance_of(buffer_resource, &wl_buffer_interface,
|
||||
&wl_buffer_impl));
|
||||
|
||||
struct wlr_dmabuf_buffer *buffer = wl_resource_get_user_data(buffer_resource);
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
wl_resource_get_user_data(buffer_resource);
|
||||
assert(buffer);
|
||||
assert(buffer->buffer_resource);
|
||||
assert(!buffer->params_resource);
|
||||
|
@ -57,7 +57,8 @@ static void linux_dmabuf_buffer_destroy(struct wlr_dmabuf_buffer *buffer) {
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
static void params_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||
static void params_destroy(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
|
@ -65,8 +66,8 @@ static void params_add(struct wl_client *client,
|
|||
struct wl_resource *params_resource, int32_t name_fd,
|
||||
uint32_t plane_idx, uint32_t offset, uint32_t stride,
|
||||
uint32_t modifier_hi, uint32_t modifier_lo) {
|
||||
struct wlr_dmabuf_buffer *buffer = wlr_dmabuf_buffer_from_params_resource(
|
||||
params_resource);
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
wlr_dmabuf_buffer_from_params_resource(params_resource);
|
||||
|
||||
if (!buffer) {
|
||||
wl_resource_post_error(params_resource,
|
||||
|
@ -97,15 +98,15 @@ static void params_add(struct wl_client *client,
|
|||
buffer->attributes.fd[plane_idx] = name_fd;
|
||||
buffer->attributes.offset[plane_idx] = offset;
|
||||
buffer->attributes.stride[plane_idx] = stride;
|
||||
buffer->attributes.modifier[plane_idx] = ((uint64_t)modifier_hi << 32) |
|
||||
modifier_lo;
|
||||
buffer->attributes.modifier[plane_idx] =
|
||||
((uint64_t)modifier_hi << 32) | modifier_lo;
|
||||
buffer->attributes.n_planes++;
|
||||
}
|
||||
|
||||
static void handle_buffer_destroy(struct wl_resource *buffer_resource)
|
||||
{
|
||||
struct wlr_dmabuf_buffer *buffer = wlr_dmabuf_buffer_from_buffer_resource(
|
||||
buffer_resource);
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
wlr_dmabuf_buffer_from_buffer_resource(buffer_resource);
|
||||
|
||||
linux_dmabuf_buffer_destroy(buffer);
|
||||
}
|
||||
|
@ -119,8 +120,8 @@ static void params_create_common(struct wl_client *client,
|
|||
"params was already used to create a wl_buffer");
|
||||
return;
|
||||
}
|
||||
struct wlr_dmabuf_buffer *buffer = wlr_dmabuf_buffer_from_params_resource(
|
||||
params_resource);
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
wlr_dmabuf_buffer_from_params_resource(params_resource);
|
||||
|
||||
/* Switch the linux_dmabuf_buffer object from params resource to
|
||||
* eventually wl_buffer resource. */
|
||||
|
@ -216,7 +217,7 @@ static void params_create_common(struct wl_client *client,
|
|||
}
|
||||
|
||||
/* Check if dmabuf is usable */
|
||||
if (!wlr_egl_check_import_dmabuf(buffer->egl, buffer)) {
|
||||
if (!wlr_renderer_check_import_dmabuf(buffer->renderer, buffer)) {
|
||||
goto err_failed;
|
||||
}
|
||||
|
||||
|
@ -254,26 +255,28 @@ err_failed:
|
|||
}
|
||||
err_out:
|
||||
linux_dmabuf_buffer_destroy(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
static void params_create(struct wl_client *client,
|
||||
struct wl_resource *params_resource,
|
||||
int32_t width, int32_t height, uint32_t format, uint32_t flags) {
|
||||
params_create_common(client, params_resource, 0, width, height, format, flags);
|
||||
params_create_common(client, params_resource, 0, width, height, format,
|
||||
flags);
|
||||
}
|
||||
|
||||
static void params_create_immed(struct wl_client *client,
|
||||
struct wl_resource *params_resource, uint32_t buffer_id,
|
||||
int32_t width, int32_t height, uint32_t format, uint32_t flags) {
|
||||
params_create_common(client, params_resource, buffer_id, width, height, format, flags);
|
||||
params_create_common(client, params_resource, buffer_id, width, height,
|
||||
format, flags);
|
||||
}
|
||||
|
||||
static const struct zwp_linux_buffer_params_v1_interface linux_buffer_params_impl = {
|
||||
params_destroy,
|
||||
params_add,
|
||||
params_create,
|
||||
params_create_immed,
|
||||
static const struct zwp_linux_buffer_params_v1_interface
|
||||
linux_buffer_params_impl = {
|
||||
.destroy = params_destroy,
|
||||
.add = params_add,
|
||||
.create = params_create,
|
||||
.create_immed = params_create_immed,
|
||||
};
|
||||
|
||||
struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_params_resource(
|
||||
|
@ -282,7 +285,8 @@ struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_params_resource(
|
|||
&zwp_linux_buffer_params_v1_interface,
|
||||
&linux_buffer_params_impl));
|
||||
|
||||
struct wlr_dmabuf_buffer *buffer = wl_resource_get_user_data(params_resource);
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
wl_resource_get_user_data(params_resource);
|
||||
assert(buffer);
|
||||
assert(buffer->params_resource);
|
||||
assert(!buffer->buffer_resource);
|
||||
|
@ -305,8 +309,8 @@ static void handle_params_destroy(struct wl_resource *params_resource) {
|
|||
static void linux_dmabuf_create_params(struct wl_client *client,
|
||||
struct wl_resource *linux_dmabuf_resource,
|
||||
uint32_t params_id) {
|
||||
struct wlr_linux_dmabuf *linux_dmabuf = wlr_linux_dmabuf_from_resource(
|
||||
linux_dmabuf_resource);
|
||||
struct wlr_linux_dmabuf *linux_dmabuf =
|
||||
wlr_linux_dmabuf_from_resource(linux_dmabuf_resource);
|
||||
|
||||
uint32_t version = wl_resource_get_version(linux_dmabuf_resource);
|
||||
struct wlr_dmabuf_buffer *buffer = calloc(1, sizeof *buffer);
|
||||
|
@ -318,7 +322,7 @@ static void linux_dmabuf_create_params(struct wl_client *client,
|
|||
buffer->attributes.fd[i] = -1;
|
||||
}
|
||||
|
||||
buffer->egl = linux_dmabuf->egl;
|
||||
buffer->renderer = linux_dmabuf->renderer;
|
||||
buffer->params_resource = wl_resource_create(client,
|
||||
&zwp_linux_buffer_params_v1_interface,
|
||||
version, params_id);
|
||||
|
@ -336,13 +340,14 @@ err:
|
|||
wl_resource_post_no_memory(linux_dmabuf_resource);
|
||||
}
|
||||
|
||||
static void linux_dmabuf_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||
static void linux_dmabuf_destroy(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_v1_interface linux_dmabuf_impl = {
|
||||
linux_dmabuf_destroy,
|
||||
linux_dmabuf_create_params
|
||||
.destroy = linux_dmabuf_destroy,
|
||||
.create_params = linux_dmabuf_create_params,
|
||||
};
|
||||
|
||||
struct wlr_linux_dmabuf *wlr_linux_dmabuf_from_resource(
|
||||
|
@ -357,25 +362,22 @@ struct wlr_linux_dmabuf *wlr_linux_dmabuf_from_resource(
|
|||
|
||||
static void linux_dmabuf_send_modifiers(struct wlr_linux_dmabuf *linux_dmabuf,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_egl *egl = linux_dmabuf->egl;
|
||||
struct wlr_renderer *renderer = linux_dmabuf->renderer;
|
||||
/*
|
||||
* Use EGL_EXT_image_dma_buf_import_modifiers to query and advertise
|
||||
* format/modifier codes.
|
||||
*/
|
||||
uint64_t modifier_invalid = DRM_FORMAT_MOD_INVALID;
|
||||
int *formats = NULL;
|
||||
int num_formats = wlr_egl_get_dmabuf_formats(egl, &formats);
|
||||
|
||||
int num_formats = wlr_renderer_get_dmabuf_formats(renderer, &formats);
|
||||
if (num_formats < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_formats; i++) {
|
||||
int num_modifiers;
|
||||
uint64_t *modifiers = NULL;
|
||||
|
||||
num_modifiers = wlr_egl_get_dmabuf_modifiers(egl, formats[i],
|
||||
&modifiers);
|
||||
int num_modifiers = wlr_renderer_get_dmabuf_modifiers(renderer,
|
||||
formats[i], &modifiers);
|
||||
if (num_modifiers < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -389,8 +391,7 @@ static void linux_dmabuf_send_modifiers(struct wlr_linux_dmabuf *linux_dmabuf,
|
|||
uint32_t modifier_lo = modifiers[j] & 0xFFFFFFFF;
|
||||
uint32_t modifier_hi = modifiers[j] >> 32;
|
||||
zwp_linux_dmabuf_v1_send_modifier(resource, formats[i],
|
||||
modifier_hi,
|
||||
modifier_lo);
|
||||
modifier_hi, modifier_lo);
|
||||
}
|
||||
if (modifiers != &modifier_invalid) {
|
||||
free(modifiers);
|
||||
|
@ -399,13 +400,12 @@ static void linux_dmabuf_send_modifiers(struct wlr_linux_dmabuf *linux_dmabuf,
|
|||
free(formats);
|
||||
}
|
||||
|
||||
static void linux_dmabuf_bind(struct wl_client *client,
|
||||
void *data, uint32_t version, uint32_t id) {
|
||||
static void linux_dmabuf_bind(struct wl_client *client, void *data,
|
||||
uint32_t version, uint32_t id) {
|
||||
struct wlr_linux_dmabuf *linux_dmabuf = data;
|
||||
struct wl_resource *resource = wl_resource_create(client,
|
||||
&zwp_linux_dmabuf_v1_interface,
|
||||
version, id);
|
||||
|
||||
struct wl_resource *resource = wl_resource_create(client,
|
||||
&zwp_linux_dmabuf_v1_interface, version, id);
|
||||
if (resource == NULL) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
|
@ -431,32 +431,32 @@ void wlr_linux_dmabuf_destroy(struct wlr_linux_dmabuf *linux_dmabuf) {
|
|||
}
|
||||
|
||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_linux_dmabuf *linux_dmabuf = wl_container_of(listener, linux_dmabuf, display_destroy);
|
||||
struct wlr_linux_dmabuf *linux_dmabuf =
|
||||
wl_container_of(listener, linux_dmabuf, display_destroy);
|
||||
wlr_linux_dmabuf_destroy(linux_dmabuf);
|
||||
}
|
||||
|
||||
struct wlr_linux_dmabuf *wlr_linux_dmabuf_create(struct wl_display *display,
|
||||
struct wlr_egl *egl) {
|
||||
struct wlr_renderer *renderer) {
|
||||
struct wlr_linux_dmabuf *linux_dmabuf =
|
||||
calloc(1, sizeof(struct wlr_linux_dmabuf));
|
||||
if (linux_dmabuf == NULL) {
|
||||
wlr_log(L_ERROR, "could not create simple dmabuf manager");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
linux_dmabuf->display_destroy.notify = handle_display_destroy;
|
||||
wl_display_add_destroy_listener(display, &linux_dmabuf->display_destroy);
|
||||
linux_dmabuf->renderer = renderer;
|
||||
|
||||
linux_dmabuf->wl_global =
|
||||
wl_global_create(display, &zwp_linux_dmabuf_v1_interface,
|
||||
3, linux_dmabuf, linux_dmabuf_bind);
|
||||
|
||||
linux_dmabuf->egl = egl;
|
||||
if (!linux_dmabuf->wl_global) {
|
||||
wlr_log(L_ERROR, "could not create linux dmabuf v1 wl global");
|
||||
free(linux_dmabuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
linux_dmabuf->display_destroy.notify = handle_display_destroy;
|
||||
wl_display_add_destroy_listener(display, &linux_dmabuf->display_destroy);
|
||||
|
||||
return linux_dmabuf;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue