mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
backend/x11: implement get_dmabuf_primary_formats
This commit is contained in:
parent
44feb832f9
commit
68c4f15958
3 changed files with 39 additions and 0 deletions
|
@ -198,6 +198,8 @@ static void backend_destroy(struct wlr_backend *backend) {
|
|||
}
|
||||
wl_list_remove(&x11->display_destroy.link);
|
||||
|
||||
wlr_drm_format_set_finish(&x11->primary_dri3_formats);
|
||||
wlr_drm_format_set_finish(&x11->primary_shm_formats);
|
||||
wlr_drm_format_set_finish(&x11->dri3_formats);
|
||||
wlr_drm_format_set_finish(&x11->shm_formats);
|
||||
free(x11->drm_format);
|
||||
|
@ -658,6 +660,26 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
|||
return false;
|
||||
}
|
||||
|
||||
// Windows can only display buffers with the depth they were created with
|
||||
// TODO: look into changing the window's depth at runtime
|
||||
const struct wlr_drm_format *dri3_format =
|
||||
wlr_drm_format_set_get(&x11->dri3_formats, x11->x11_format->drm);
|
||||
if (x11->have_dri3 && dri3_format != NULL) {
|
||||
wlr_drm_format_set_add(&x11->primary_dri3_formats,
|
||||
dri3_format->format, DRM_FORMAT_MOD_INVALID);
|
||||
for (size_t i = 0; i < dri3_format->len; i++) {
|
||||
wlr_drm_format_set_add(&x11->primary_dri3_formats,
|
||||
dri3_format->format, dri3_format->modifiers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
const struct wlr_drm_format *shm_format =
|
||||
wlr_drm_format_set_get(&x11->shm_formats, x11->x11_format->drm);
|
||||
if (x11->have_shm && shm_format != NULL) {
|
||||
wlr_drm_format_set_add(&x11->primary_shm_formats,
|
||||
shm_format->format, DRM_FORMAT_MOD_INVALID);
|
||||
}
|
||||
|
||||
#if HAS_XCB_ERRORS
|
||||
if (xcb_errors_context_new(x11->xcb, &x11->errors_context) != 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to create error context");
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "backend/x11.h"
|
||||
#include "render/swapchain.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
#include "types/wlr_buffer.h"
|
||||
#include "util/signal.h"
|
||||
#include "util/time.h"
|
||||
|
||||
|
@ -514,6 +515,19 @@ static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static const struct wlr_drm_format_set *output_get_primary_formats(
|
||||
struct wlr_output *wlr_output, uint32_t buffer_caps) {
|
||||
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
|
||||
struct wlr_x11_backend *x11 = output->x11;
|
||||
|
||||
if (x11->have_dri3 && (buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
|
||||
return &output->x11->primary_dri3_formats;
|
||||
} else if (x11->have_shm && (buffer_caps & WLR_BUFFER_CAP_SHM)) {
|
||||
return &output->x11->primary_shm_formats;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct wlr_output_impl output_impl = {
|
||||
.destroy = output_destroy,
|
||||
.attach_render = output_attach_render,
|
||||
|
@ -522,6 +536,7 @@ static const struct wlr_output_impl output_impl = {
|
|||
.rollback_render = output_rollback_render,
|
||||
.set_cursor = output_set_cursor,
|
||||
.move_cursor = output_move_cursor,
|
||||
.get_primary_formats = output_get_primary_formats,
|
||||
};
|
||||
|
||||
struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||
|
|
|
@ -91,6 +91,8 @@ struct wlr_x11_backend {
|
|||
struct wlr_drm_format_set dri3_formats;
|
||||
struct wlr_drm_format_set shm_formats;
|
||||
const struct wlr_x11_format *x11_format;
|
||||
struct wlr_drm_format_set primary_dri3_formats;
|
||||
struct wlr_drm_format_set primary_shm_formats;
|
||||
struct wlr_drm_format *drm_format;
|
||||
struct wl_event_source *event_source;
|
||||
|
||||
|
|
Loading…
Reference in a new issue