mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-27 06:59:46 -05:00
Implement drm (egl) buffer attaching
This commit is contained in:
parent
750d0ad458
commit
67369173aa
19 changed files with 308 additions and 23 deletions
|
|
@ -2,17 +2,72 @@
|
|||
#define WLR_BACKEND_EGL_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct wlr_egl {
|
||||
EGLDisplay display;
|
||||
EGLConfig config;
|
||||
EGLContext context;
|
||||
|
||||
const char *egl_exts;
|
||||
const char *gl_exts;
|
||||
|
||||
struct wl_display *wl_display;
|
||||
};
|
||||
|
||||
const char *egl_error(void);
|
||||
/**
|
||||
* Initializes an egl context for the given platform and remote display.
|
||||
* Will attempt to load all possibly required api functions.
|
||||
*/
|
||||
bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display);
|
||||
|
||||
/**
|
||||
* Frees all related egl resources, makes the context not-current and
|
||||
* unbinds a bound wayland display.
|
||||
*/
|
||||
void wlr_egl_free(struct wlr_egl *egl);
|
||||
|
||||
/**
|
||||
* Binds the given display to the egl instance.
|
||||
* This will allow clients to create egl surfaces from wayland ones and render to it.
|
||||
*/
|
||||
bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display);
|
||||
|
||||
/**
|
||||
* Queries information about the given (potential egl/drm) buffer, returns
|
||||
* the information in value.
|
||||
* Refer to eglQueryWaylandBufferWL for more information about attrib and value.
|
||||
* Makes only sense when a wl_display was bound to it since otherwise there
|
||||
* cannot be any egl/drm buffers.
|
||||
* Will only work after a wlr_egl objct was initialized and if the needed egl extension
|
||||
* is present.
|
||||
*/
|
||||
bool wlr_egl_query_buffer(struct wl_resource *buf,
|
||||
EGLint attrib, EGLint *value);
|
||||
|
||||
/**
|
||||
* Returns a surface for the given native window
|
||||
* The window must match the remote display the wlr_egl was created with.
|
||||
*/
|
||||
EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window);
|
||||
|
||||
/**
|
||||
* Creates an egl image from the given client buffer and attributes.
|
||||
* Will only work after a wlr_egl objct was initialized and if the needed egl extension
|
||||
* is present.
|
||||
*/
|
||||
EGLImageKHR wlr_egl_create_image(EGLenum target, EGLClientBuffer buffer,
|
||||
const EGLint *attribs);
|
||||
|
||||
/**
|
||||
* Destroys an egl image created with the given wlr_egl.
|
||||
*/
|
||||
bool wlr_egl_destroy_image(EGLImageKHR image);
|
||||
|
||||
/**
|
||||
* Returns a string for the last error ocurred with egl.
|
||||
*/
|
||||
const char *egl_error(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,9 +4,14 @@
|
|||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <wlr/render.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
|
||||
|
||||
struct pixel_format {
|
||||
uint32_t wl_format;
|
||||
GLint gl_format, gl_type;
|
||||
|
|
@ -18,6 +23,7 @@ struct wlr_texture_state {
|
|||
struct wlr_texture *wlr_texture;
|
||||
GLuint tex_id;
|
||||
const struct pixel_format *pixel_format;
|
||||
EGLImageKHR image;
|
||||
};
|
||||
|
||||
struct shaders {
|
||||
|
|
@ -25,6 +31,7 @@ struct shaders {
|
|||
GLuint rgba, rgbx;
|
||||
GLuint quad;
|
||||
GLuint ellipse;
|
||||
Gluint external;
|
||||
};
|
||||
|
||||
extern struct shaders shaders;
|
||||
|
|
@ -39,6 +46,7 @@ extern const GLchar ellipse_fragment_src[];
|
|||
extern const GLchar vertex_src[];
|
||||
extern const GLchar fragment_src_rgba[];
|
||||
extern const GLchar fragment_src_rgbx[];
|
||||
extern const GLchar fragment_src_external[];
|
||||
|
||||
bool _gles2_flush_errors(const char *file, int line);
|
||||
#define gles2_flush_errors(...) \
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ struct wlr_texture {
|
|||
* Copies pixels to this texture. The buffer is not accessed after this function
|
||||
* returns.
|
||||
*/
|
||||
bool wlr_texture_upload_pixels(struct wlr_texture *surf,
|
||||
bool wlr_texture_upload_pixels(struct wlr_texture *tex,
|
||||
enum wl_shm_format format, int stride, int width, int height,
|
||||
const unsigned char *pixels);
|
||||
/**
|
||||
|
|
@ -80,8 +80,17 @@ bool wlr_texture_update_pixels(struct wlr_texture *surf,
|
|||
* Copies pixels from a wl_shm_buffer into this texture. The buffer is not
|
||||
* accessed after this function returns.
|
||||
*/
|
||||
bool wlr_texture_upload_shm(struct wlr_texture *surf, uint32_t format,
|
||||
bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format,
|
||||
struct wl_shm_buffer *shm);
|
||||
|
||||
/**
|
||||
* Attaches the contents from the given wl_drm wl_buffer resource onto the
|
||||
* texture. The wl_resource is not used after this call.
|
||||
* Will fail (return false) if the given resource is no drm buffer.
|
||||
*/
|
||||
bool wlr_texture_upload_drm(struct wlr_texture *tex,
|
||||
struct wl_resource *drm_buffer);
|
||||
|
||||
/**
|
||||
* Copies a rectangle of pixels from a wl_shm_buffer onto the texture. The
|
||||
* buffer is not accessed after this function returns. Under some circumstances,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define _WLR_GLES2_RENDERER_H
|
||||
#include <wlr/render.h>
|
||||
|
||||
struct wlr_egl;
|
||||
struct wlr_renderer *wlr_gles2_renderer_init();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ struct wlr_texture_impl {
|
|||
struct wl_shm_buffer *shm);
|
||||
bool (*update_shm)(struct wlr_texture_state *surf, uint32_t format,
|
||||
int x, int y, int width, int height, struct wl_shm_buffer *shm);
|
||||
// TODO: egl
|
||||
bool (*upload_drm)(struct wlr_texture_state *state,
|
||||
struct wl_resource *drm_buf);
|
||||
void (*get_matrix)(struct wlr_texture_state *state,
|
||||
float (*matrix)[16], const float (*projection)[16], int x, int y);
|
||||
void (*bind)(struct wlr_texture_state *state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue