aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-04-08 11:21:21 -0400
committerGitHub <noreply@github.com>2018-04-08 11:21:21 -0400
commitbef5c1fd56a386745e76346ed2d9df5ba3baa40c (patch)
tree6df49a5ce9dc6c66a784e68ea1c3232035570437
parent5f48c7fddd6a28b529eb02ca156db577b76edfb6 (diff)
parentd2ebbd103cda11b36fa44aa801128b2e477d465b (diff)
Merge pull request #850 from emersion/remove-backend-egl
backend: remove wlr_backend_get_egl
-rw-r--r--backend/backend.c7
-rw-r--r--backend/drm/backend.c6
-rw-r--r--backend/headless/backend.c7
-rw-r--r--backend/multi/backend.c13
-rw-r--r--backend/wayland/backend.c6
-rw-r--r--backend/x11/backend.c6
-rw-r--r--include/wlr/backend.h4
-rw-r--r--include/wlr/backend/interface.h1
-rw-r--r--include/wlr/render/egl.h2
-rw-r--r--include/wlr/render/interface.h5
-rw-r--r--include/wlr/render/wlr_renderer.h16
-rw-r--r--include/wlr/types/wlr_linux_dmabuf.h6
-rw-r--r--render/gles2/renderer.c21
-rw-r--r--render/wlr_renderer.c24
-rw-r--r--rootston/desktop.c4
-rw-r--r--types/wlr_linux_dmabuf.c110
16 files changed, 127 insertions, 111 deletions
diff --git a/backend/backend.c b/backend/backend.c
index b583855e..20bf42b3 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -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);
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 43a8d017..66cb89d3 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -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,
};
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index 5bc48240..81b01376 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -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,
};
diff --git a/backend/multi/backend.c b/backend/multi/backend.c
index 5cb3fbc5..50563892 100644
--- a/backend/multi/backend.c
+++ b/backend/multi/backend.c
@@ -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,
};
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 0135f7c5..4bcb9360 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -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,
};
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 59b75a03..02f5ef6f 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -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,
};
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index f5482e04..2059e3b7 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -38,10 +38,6 @@ bool wlr_backend_start(struct wlr_backend *backend);
*/
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.
*/
struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend);
diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h
index f03e95d9..42b39a16 100644
--- a/include/wlr/backend/interface.h
+++ b/include/wlr/backend/interface.h
@@ -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);
};
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h
index 51f63b20..0b7f1dde 100644
--- a/include/wlr/render/egl.h
+++ b/include/wlr/render/egl.h
@@ -83,7 +83,7 @@ int wlr_egl_get_dmabuf_formats(struct wlr_egl *egl, int **formats);
* Get the available dmabuf modifiers for a given format
*/
int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, int format,
- uint64_t **modifiers);
+ uint64_t **modifiers);
/**
* Destroys an EGL image created with the given wlr_egl.
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index 597e4b39..9dbe7247 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -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,
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
index 65fc7b19..9ead7d81 100644
--- a/include/wlr/render/wlr_renderer.h
+++ b/include/wlr/render/wlr_renderer.h
@@ -65,6 +65,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.
*/
diff --git a/include/wlr/types/wlr_linux_dmabuf.h b/include/wlr/types/wlr_linux_dmabuf.h
index c06d8a87..3fe8e1fc 100644
--- a/include/wlr/types/wlr_linux_dmabuf.h
+++ b/include/wlr/types/wlr_linux_dmabuf.h
@@ -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
*/
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index b8bce98d..297ac886 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -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,
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index e33c2bed..80649b8c 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -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,
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 4f5d3394..4edcb5e3 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -869,8 +869,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;
}
diff --git a/types/wlr_linux_dmabuf.c b/types/wlr_linux_dmabuf.c
index d2a8bea9..f190be24 100644
--- a/types/wlr_linux_dmabuf.c
+++ b/types/wlr_linux_dmabuf.c
@@ -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);
+ int32_t width, int32_t height, uint32_t format, uint32_t 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);
+ int32_t width, int32_t height, uint32_t format, uint32_t 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);
@@ -327,7 +331,7 @@ static void linux_dmabuf_create_params(struct wl_client *client,
}
wl_resource_set_implementation(buffer->params_resource,
- &linux_buffer_params_impl,buffer, handle_params_destroy);
+ &linux_buffer_params_impl, buffer, handle_params_destroy);
return;
err_free:
@@ -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;
@@ -414,7 +414,7 @@ static void linux_dmabuf_bind(struct wl_client *client,
wl_resource_set_implementation(resource, &linux_dmabuf_impl,
linux_dmabuf, NULL);
if (version < ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION) {
- return;
+ return;
}
linux_dmabuf_send_modifiers(linux_dmabuf, resource);
@@ -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;
}