diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/backend.c | 9 | ||||
-rw-r--r-- | backend/drm/drm.c | 23 | ||||
-rw-r--r-- | backend/drm/renderer.c | 52 | ||||
-rw-r--r-- | backend/meson.build | 5 | ||||
-rw-r--r-- | backend/wayland/output.c | 2 | ||||
-rw-r--r-- | backend/x11/backend.c | 4 |
6 files changed, 43 insertions, 52 deletions
diff --git a/backend/backend.c b/backend/backend.c index c67be617..52344dac 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -11,9 +11,14 @@ #include <wlr/backend/multi.h> #include <wlr/backend/session.h> #include <wlr/backend/wayland.h> -#include <wlr/backend/x11.h> +#include <wlr/config.h> #include <wlr/util/log.h> +/* WLR_HAS_X11_BACKEND needs to be after wlr/config.h */ +#ifdef WLR_HAS_X11_BACKEND +#include <wlr/backend/x11.h> +#endif + void wlr_backend_init(struct wlr_backend *backend, const struct wlr_backend_impl *impl) { assert(backend); @@ -94,6 +99,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { } } +#ifdef WLR_HAS_X11_BACKEND const char *x11_display = getenv("DISPLAY"); if (x11_display) { struct wlr_backend *x11_backend = @@ -101,6 +107,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { wlr_multi_backend_add(backend, x11_backend); return backend; } +#endif // Attempt DRM+libinput struct wlr_session *session = wlr_session_create(display); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 524e80bb..94bfbc96 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -181,9 +181,6 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) { if (plane->cursor_bo) { gbm_bo_destroy(plane->cursor_bo); } - if (plane->wlr_tex) { - wlr_texture_destroy(plane->wlr_tex); - } } free(drm->crtcs); @@ -586,12 +583,6 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, wlr_output_transform_invert(output->transform); wlr_matrix_projection(plane->matrix, plane->surf.width, plane->surf.height, transform); - - plane->wlr_tex = - wlr_render_texture_create(plane->surf.renderer->wlr_rend); - if (!plane->wlr_tex) { - return false; - } } struct wlr_box hotspot = { .x = hotspot_x, .y = hotspot_y }; @@ -637,13 +628,18 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, wlr_drm_surface_make_current(&plane->surf, NULL); - wlr_texture_upload_pixels(plane->wlr_tex, WL_SHM_FORMAT_ARGB8888, - stride, width, height, buf); - struct wlr_renderer *rend = plane->surf.renderer->wlr_rend; + + struct wlr_texture *texture = wlr_texture_from_pixels(rend, + WL_SHM_FORMAT_ARGB8888, stride, width, height, buf); + if (texture == NULL) { + wlr_log(L_ERROR, "Unable to create texture"); + return false; + } + wlr_renderer_begin(rend, plane->surf.width, plane->surf.height); wlr_renderer_clear(rend, (float[]){ 0.0, 0.0, 0.0, 0.0 }); - wlr_render_texture(rend, plane->wlr_tex, plane->matrix, 0, 0, 1.0f); + wlr_render_texture(rend, texture, plane->matrix, 0, 0, 1.0f); wlr_renderer_end(rend); wlr_renderer_read_pixels(rend, WL_SHM_FORMAT_ARGB8888, bo_stride, @@ -651,6 +647,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, wlr_drm_surface_swap_buffers(&plane->surf, NULL); + wlr_texture_destroy(texture); gbm_bo_unmap(plane->cursor_bo, bo_data); } diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index b2998b5f..c1531ce3 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -14,6 +14,10 @@ #include "backend/drm/drm.h" #include "glapi.h" +#ifndef DRM_FORMAT_MOD_LINEAR +#define DRM_FORMAT_MOD_LINEAR 0 +#endif + bool wlr_drm_renderer_init(struct wlr_drm_backend *drm, struct wlr_drm_renderer *renderer) { renderer->gbm = gbm_create_device(drm->fd); @@ -178,47 +182,33 @@ static void free_eglimage(struct gbm_bo *bo, void *data) { static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer, struct gbm_bo *bo) { struct tex *tex = gbm_bo_get_user_data(bo); - if (tex) { + if (tex != NULL) { return tex->tex; } - // TODO: use wlr_texture_upload_dmabuf instead - - tex = malloc(sizeof(*tex)); - if (!tex) { - wlr_log_errno(L_ERROR, "Allocation failed"); + tex = calloc(1, sizeof(struct tex)); + if (tex == NULL) { return NULL; } - tex->egl = &renderer->egl; - - int dmabuf_fd = gbm_bo_get_fd(bo); - uint32_t width = gbm_bo_get_width(bo); - uint32_t height = gbm_bo_get_height(bo); - - EGLint attribs[] = { - EGL_WIDTH, width, - EGL_HEIGHT, height, - EGL_LINUX_DRM_FOURCC_EXT, gbm_bo_get_format(bo), - EGL_DMA_BUF_PLANE0_FD_EXT, dmabuf_fd, - EGL_DMA_BUF_PLANE0_OFFSET_EXT, gbm_bo_get_offset(bo, 0), - EGL_DMA_BUF_PLANE0_PITCH_EXT, gbm_bo_get_stride_for_plane(bo, 0), - EGL_IMAGE_PRESERVED_KHR, EGL_FALSE, - EGL_NONE, + struct wlr_dmabuf_buffer_attribs attribs = { + .n_planes = 1, + .width = gbm_bo_get_width(bo), + .height = gbm_bo_get_height(bo), + .format = gbm_bo_get_format(bo), }; - - tex->img = eglCreateImageKHR(renderer->egl.display, EGL_NO_CONTEXT, - EGL_LINUX_DMA_BUF_EXT, NULL, attribs); - if (!tex->img) { - wlr_log(L_ERROR, "Failed to create EGL image"); - abort(); + attribs.offset[0] = 0; + attribs.stride[0] = gbm_bo_get_stride_for_plane(bo, 0); + attribs.modifier[0] = DRM_FORMAT_MOD_LINEAR; + attribs.fd[0] = gbm_bo_get_fd(bo); + + tex->tex = wlr_texture_from_dmabuf(renderer->wlr_rend, &attribs); + if (tex->tex == NULL) { + free(tex); + return NULL; } - tex->tex = wlr_render_texture_create(renderer->wlr_rend); - wlr_texture_upload_eglimage(tex->tex, tex->img, width, height); - gbm_bo_set_user_data(bo, tex, free_eglimage); - return tex->tex; } diff --git a/backend/meson.build b/backend/meson.build index c0ed76f1..a74ea024 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -24,7 +24,6 @@ backend_files = files( 'wayland/output.c', 'wayland/registry.c', 'wayland/wl_seat.c', - 'x11/backend.c', ) backend_deps = [ @@ -50,6 +49,10 @@ if conf_data.get('WLR_HAS_SYSTEMD', false) backend_deps += systemd endif +if conf_data.get('WLR_HAS_X11_BACKEND', false) + backend_files += files('x11/backend.c') +endif + if conf_data.get('WLR_HAS_ELOGIND', false) backend_files += files('session/logind.c') backend_deps += elogind diff --git a/backend/wayland/output.c b/backend/wayland/output.c index d528c888..c1fa638a 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -99,8 +99,6 @@ static bool wlr_wl_output_set_cursor(struct wlr_output *_output, return true; } - stride *= 4; // stride is given in pixels, we need it in bytes - if (!backend->shm || !backend->pointer) { wlr_log(L_INFO, "cannot set cursor, no shm or pointer"); return false; diff --git a/backend/x11/backend.c b/backend/x11/backend.c index dd2c0a6e..36d72d9e 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -326,9 +326,6 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) { wl_event_source_remove(x11->frame_timer); wlr_egl_finish(&x11->egl); - if (x11->xcb_conn) { - xcb_disconnect(x11->xcb_conn); - } if (x11->xlib_conn) { XCloseDisplay(x11->xlib_conn); } @@ -428,7 +425,6 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, error_event: wl_event_source_remove(x11->event_source); error_x11: - xcb_disconnect(x11->xcb_conn); XCloseDisplay(x11->xlib_conn); free(x11); return NULL; |