2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
2018-03-19 23:16:29 +01:00
|
|
|
#ifndef WLR_RENDER_WLR_RENDERER_H
|
|
|
|
#define WLR_RENDER_WLR_RENDERER_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2021-02-16 20:00:52 +01:00
|
|
|
#include <wayland-server-core.h>
|
2023-08-16 19:18:05 +02:00
|
|
|
#include <wlr/render/pass.h>
|
2018-03-19 23:16:29 +01:00
|
|
|
#include <wlr/render/wlr_texture.h>
|
2022-06-21 22:39:29 +02:00
|
|
|
#include <wlr/util/box.h>
|
2018-03-19 23:16:29 +01:00
|
|
|
|
2022-11-23 14:29:58 +01:00
|
|
|
struct wlr_backend;
|
2018-04-26 01:11:36 +02:00
|
|
|
struct wlr_renderer_impl;
|
2019-04-01 18:17:23 +02:00
|
|
|
struct wlr_drm_format_set;
|
2020-07-28 16:56:18 +02:00
|
|
|
struct wlr_buffer;
|
2021-07-01 22:36:01 +02:00
|
|
|
struct wlr_box;
|
|
|
|
struct wlr_fbox;
|
2018-03-19 23:16:29 +01:00
|
|
|
|
2022-11-15 10:40:06 +01:00
|
|
|
/**
|
|
|
|
* A renderer for basic 2D operations.
|
|
|
|
*/
|
2018-04-26 01:11:36 +02:00
|
|
|
struct wlr_renderer {
|
2022-11-15 10:40:55 +01:00
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
2022-11-13 17:08:00 +01:00
|
|
|
/**
|
|
|
|
* Emitted when the GPU is lost, e.g. on GPU reset.
|
|
|
|
*
|
|
|
|
* Compositors should destroy the renderer and re-create it.
|
|
|
|
*/
|
|
|
|
struct wl_signal lost;
|
2022-11-15 10:40:55 +01:00
|
|
|
} events;
|
|
|
|
|
|
|
|
// private state
|
|
|
|
|
2018-04-26 01:11:36 +02:00
|
|
|
const struct wlr_renderer_impl *impl;
|
|
|
|
};
|
2018-03-19 23:16:29 +01:00
|
|
|
|
2022-11-15 10:40:06 +01:00
|
|
|
/**
|
|
|
|
* Automatically create a new renderer.
|
|
|
|
*
|
|
|
|
* Selects an appropriate renderer type to use depending on the backend,
|
|
|
|
* platform, environment, etc.
|
|
|
|
*/
|
2021-01-14 04:49:07 +01:00
|
|
|
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend);
|
2018-05-25 12:14:35 +02:00
|
|
|
|
2018-03-19 23:16:29 +01:00
|
|
|
/**
|
2020-11-18 13:40:08 +01:00
|
|
|
* Get the shared-memory formats supporting import usage. Buffers allocated
|
2022-05-24 18:46:59 +02:00
|
|
|
* with a format from this list may be imported via wlr_texture_from_pixels().
|
2018-03-19 23:16:29 +01:00
|
|
|
*/
|
2021-02-16 19:20:00 +01:00
|
|
|
const uint32_t *wlr_renderer_get_shm_texture_formats(
|
2020-11-18 14:57:53 +01:00
|
|
|
struct wlr_renderer *r, size_t *len);
|
2018-04-08 17:00:56 +02:00
|
|
|
/**
|
2020-11-18 13:40:08 +01:00
|
|
|
* Get the DMA-BUF formats supporting sampling usage. Buffers allocated with
|
2022-05-24 18:46:59 +02:00
|
|
|
* a format from this list may be imported via wlr_texture_from_dmabuf().
|
2018-04-08 17:00:56 +02:00
|
|
|
*/
|
2020-11-18 14:53:13 +01:00
|
|
|
const struct wlr_drm_format_set *wlr_renderer_get_dmabuf_texture_formats(
|
2019-04-01 18:17:23 +02:00
|
|
|
struct wlr_renderer *renderer);
|
2020-04-23 01:23:56 +02:00
|
|
|
|
2020-03-23 14:32:27 +01:00
|
|
|
/**
|
2021-06-07 16:31:53 +02:00
|
|
|
* Initializes wl_shm, linux-dmabuf and other buffer factory protocols.
|
2020-03-23 14:32:27 +01:00
|
|
|
*
|
|
|
|
* Returns false on failure.
|
|
|
|
*/
|
|
|
|
bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
2018-05-21 20:07:08 +02:00
|
|
|
struct wl_display *wl_display);
|
2019-11-07 19:38:45 +01:00
|
|
|
|
2021-06-07 16:31:53 +02:00
|
|
|
/**
|
2022-05-24 18:46:59 +02:00
|
|
|
* Initializes wl_shm on the provided struct wl_display.
|
2021-06-07 16:31:53 +02:00
|
|
|
*/
|
|
|
|
bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
|
|
|
|
struct wl_display *wl_display);
|
|
|
|
|
2020-06-10 14:47:12 +02:00
|
|
|
/**
|
|
|
|
* Obtains the FD of the DRM device used for rendering, or -1 if unavailable.
|
|
|
|
*
|
|
|
|
* The caller doesn't have ownership of the FD, it must not close it.
|
|
|
|
*/
|
|
|
|
int wlr_renderer_get_drm_fd(struct wlr_renderer *r);
|
|
|
|
|
2018-03-19 23:16:29 +01:00
|
|
|
/**
|
2022-05-24 18:46:59 +02:00
|
|
|
* Destroys the renderer.
|
|
|
|
*
|
|
|
|
* Textures must be destroyed separately.
|
2018-03-19 23:16:29 +01:00
|
|
|
*/
|
|
|
|
void wlr_renderer_destroy(struct wlr_renderer *renderer);
|
|
|
|
|
2023-06-02 11:25:07 +02:00
|
|
|
/**
|
|
|
|
* Allocate and initialise a new render timer.
|
|
|
|
*/
|
|
|
|
struct wlr_render_timer *wlr_render_timer_create(struct wlr_renderer *renderer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the render duration in nanoseconds from the timer.
|
|
|
|
*
|
|
|
|
* Returns -1 if the duration is unavailable.
|
|
|
|
*/
|
|
|
|
int wlr_render_timer_get_duration_ns(struct wlr_render_timer *timer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy the render timer.
|
|
|
|
*/
|
|
|
|
void wlr_render_timer_destroy(struct wlr_render_timer *timer);
|
|
|
|
|
2018-03-19 23:16:29 +01:00
|
|
|
#endif
|