Merge pull request #992 from emersion/screencontent

Implement wlr_export_dmabuf_unstable_v1 protocol
This commit is contained in:
Drew DeVault 2018-06-22 05:37:07 -07:00 committed by GitHub
commit e459fe0ec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1396 additions and 29 deletions

View file

@ -52,5 +52,6 @@ struct gbm_bo *get_drm_surface_front(struct wlr_drm_surface *surf);
void post_drm_surface(struct wlr_drm_surface *surf);
struct gbm_bo *copy_drm_surface_mgpu(struct wlr_drm_surface *dest,
struct gbm_bo *src);
bool export_drm_bo(struct gbm_bo *bo, struct wlr_dmabuf_attributes *attribs);
#endif

View file

@ -45,6 +45,7 @@ struct roots_desktop {
struct wlr_xdg_shell *xdg_shell;
struct wlr_gamma_control_manager *gamma_control_manager;
struct wlr_screenshooter *screenshooter;
struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1;
struct wlr_server_decoration_manager *server_decoration_manager;
struct wlr_primary_selection_device_manager *primary_selection_device_manager;
struct wlr_idle *idle;

View file

@ -23,6 +23,8 @@ struct wlr_output_impl {
void (*set_gamma)(struct wlr_output *output,
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint32_t (*get_gamma_size)(struct wlr_output *output);
bool (*export_dmabuf)(struct wlr_output *output,
struct wlr_dmabuf_attributes *attribs);
};
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,

View file

@ -1,6 +1,8 @@
#ifndef WLR_RENDER_DMABUF_H
#define WLR_RENDER_DMABUF_H
#include <stdint.h>
// So we don't have to pull in linux specific drm headers
#ifndef DRM_FORMAT_MOD_INVALID
#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
@ -26,4 +28,9 @@ struct wlr_dmabuf_attributes {
int fd[WLR_DMABUF_MAX_PLANES];
};
/**
* Closes all file descriptors in the DMA-BUF attributes.
*/
void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs);
#endif

View file

@ -18,9 +18,10 @@ struct wlr_egl {
struct {
bool bind_wayland_display_wl;
bool buffer_age_ext;
bool image_dmabuf_import_modifiers_ext;
bool image_dmabuf_import_ext;
bool image_base_khr;
bool image_dma_buf_export_mesa;
bool image_dmabuf_import_ext;
bool image_dmabuf_import_modifiers_ext;
bool swap_buffers_with_damage_ext;
bool swap_buffers_with_damage_khr;
} exts;
@ -80,6 +81,10 @@ int wlr_egl_get_dmabuf_formats(struct wlr_egl *egl, int **formats);
int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, int format,
uint64_t **modifiers);
bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image,
int32_t width, int32_t height, uint32_t flags,
struct wlr_dmabuf_attributes *attribs);
/**
* Destroys an EGL image created with the given wlr_egl.
*/

View file

@ -60,6 +60,8 @@ struct wlr_texture_impl {
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,
uint32_t dst_y, const void *data);
bool (*to_dmabuf)(struct wlr_texture *texture,
struct wlr_dmabuf_attributes *attribs);
void (*destroy)(struct wlr_texture *texture);
};

View file

@ -48,6 +48,9 @@ bool wlr_texture_write_pixels(struct wlr_texture *texture,
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
const void *data);
bool wlr_texture_to_dmabuf(struct wlr_texture *texture,
struct wlr_dmabuf_attributes *attribs);
/**
* Destroys this wlr_texture.
*/

View file

@ -0,0 +1,37 @@
#ifndef WLR_TYPES_WLR_EXPORT_DMABUF_V1_H
#define WLR_TYPES_WLR_EXPORT_DMABUF_V1_H
#include <wayland-server.h>
#include <wlr/render/dmabuf.h>
struct wlr_export_dmabuf_manager_v1;
struct wlr_export_dmabuf_frame_v1 {
struct wl_resource *resource;
struct wlr_export_dmabuf_manager_v1 *manager;
struct wl_list link;
struct wlr_dmabuf_attributes attribs;
struct wlr_output *output;
struct wl_listener output_swap_buffers;
};
struct wlr_export_dmabuf_manager_v1 {
struct wl_global *global;
struct wl_list resources;
struct wl_list frames;
struct wl_listener display_destroy;
struct {
struct wl_signal destroy;
} events;
};
struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
struct wl_display *display);
void wlr_export_dmabuf_manager_v1_destroy(
struct wlr_export_dmabuf_manager_v1 *manager);
#endif

View file

@ -6,6 +6,7 @@
#include <time.h>
#include <wayland-server.h>
#include <wayland-util.h>
#include <wlr/types/wlr_linux_dmabuf.h>
struct wlr_output_mode {
uint32_t flags; // enum wl_output_mode
@ -81,7 +82,7 @@ struct wlr_output {
struct {
struct wl_signal frame;
struct wl_signal needs_swap;
struct wl_signal swap_buffers;
struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
struct wl_signal enable;
struct wl_signal mode;
struct wl_signal scale;
@ -107,6 +108,12 @@ struct wlr_output {
void *data;
};
struct wlr_output_event_swap_buffers {
struct wlr_output *output;
struct timespec *when;
pixman_region32_t *damage;
};
struct wlr_surface;
void wlr_output_enable(struct wlr_output *output, bool enable);
@ -162,6 +169,8 @@ void wlr_output_schedule_frame(struct wlr_output *output);
void wlr_output_set_gamma(struct wlr_output *output,
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint32_t wlr_output_get_gamma_size(struct wlr_output *output);
bool wlr_output_export_dmabuf(struct wlr_output *output,
struct wlr_dmabuf_attributes *attribs);
void wlr_output_set_fullscreen_surface(struct wlr_output *output,
struct wlr_surface *surface);
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource);