diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/backend/drm.h | 2 | ||||
-rw-r--r-- | include/backend/egl.h | 18 | ||||
-rw-r--r-- | include/backend/wayland.h | 2 | ||||
-rw-r--r-- | include/render/gles2.h | 16 | ||||
-rw-r--r-- | include/wlr/backend.h | 2 | ||||
-rw-r--r-- | include/wlr/backend/interface.h | 2 | ||||
-rw-r--r-- | include/wlr/egl.h | 75 | ||||
-rw-r--r-- | include/wlr/render.h | 18 | ||||
-rw-r--r-- | include/wlr/render/gles2.h | 4 | ||||
-rw-r--r-- | include/wlr/render/interface.h | 5 | ||||
-rw-r--r-- | include/wlr/types/wlr_surface.h | 5 |
11 files changed, 124 insertions, 25 deletions
diff --git a/include/backend/drm.h b/include/backend/drm.h index 2f724524..35265e21 100644 --- a/include/backend/drm.h +++ b/include/backend/drm.h @@ -12,9 +12,9 @@ #include <wlr/backend/session.h> #include <wlr/backend/drm.h> +#include <wlr/egl.h> #include <wlr/util/list.h> -#include <backend/egl.h> #include <backend/udev.h> #include "drm-properties.h" diff --git a/include/backend/egl.h b/include/backend/egl.h deleted file mode 100644 index 0422a52b..00000000 --- a/include/backend/egl.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef WLR_BACKEND_EGL_H -#define WLR_BACKEND_EGL_H - -#include <EGL/egl.h> -#include <stdbool.h> - -struct wlr_egl { - EGLDisplay display; - EGLConfig config; - EGLContext context; -}; - -const char *egl_error(void); -bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display); -void wlr_egl_free(struct wlr_egl *egl); -EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window); - -#endif diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 792bad37..e6339a23 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -4,10 +4,10 @@ #include <wayland-client.h> #include <wayland-server.h> #include <wayland-egl.h> +#include <wlr/egl.h> #include <wlr/backend/wayland.h> #include <wlr/types/wlr_input_device.h> #include <wlr/util/list.h> -#include "backend/egl.h" struct wlr_backend_state { /* local state */ diff --git a/include/render/gles2.h b/include/render/gles2.h index 41af0593..3006872c 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -4,9 +4,16 @@ #include <string.h> #include <stdbool.h> #include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <wlr/egl.h> +#include <wlr/backend.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; @@ -14,10 +21,17 @@ struct pixel_format { GLuint *shader; }; +struct wlr_renderer_state { + struct wlr_renderer *renderer; + struct wlr_egl *egl; +}; + struct wlr_texture_state { struct wlr_texture *wlr_texture; + struct wlr_egl *egl; GLuint tex_id; const struct pixel_format *pixel_format; + EGLImageKHR image; }; struct shaders { @@ -25,6 +39,7 @@ struct shaders { GLuint rgba, rgbx; GLuint quad; GLuint ellipse; + GLuint external; }; extern struct shaders shaders; @@ -39,6 +54,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(...) \ diff --git a/include/wlr/backend.h b/include/wlr/backend.h index 3910e406..ce5b2568 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -3,6 +3,7 @@ #include <wayland-server.h> #include <wlr/backend/session.h> +#include <wlr/egl.h> struct wlr_backend_impl; struct wlr_backend_state; @@ -22,5 +23,6 @@ struct wlr_backend { struct wlr_backend *wlr_backend_autocreate(struct wl_display *display); bool wlr_backend_init(struct wlr_backend *backend); void wlr_backend_destroy(struct wlr_backend *backend); +struct wlr_egl *wlr_backend_get_egl(struct wlr_backend *backend); #endif diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h index 15cfb6c3..e791bdcf 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -3,12 +3,14 @@ #include <stdbool.h> #include <wlr/backend.h> +#include <wlr/egl.h> struct wlr_backend_state; struct wlr_backend_impl { bool (*init)(struct wlr_backend_state *state); void (*destroy)(struct wlr_backend_state *state); + struct wlr_egl *(*get_egl)(struct wlr_backend_state *state); }; struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl, diff --git a/include/wlr/egl.h b/include/wlr/egl.h new file mode 100644 index 00000000..b37317a5 --- /dev/null +++ b/include/wlr/egl.h @@ -0,0 +1,75 @@ +#ifndef WLR_EGL_H +#define WLR_EGL_H + +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <stdbool.h> + +struct wlr_egl { + EGLDisplay display; + EGLConfig config; + EGLContext context; + + PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display; + PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window_surface; + + PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; + PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; + PFNEGLQUERYWAYLANDBUFFERWL eglQueryWaylandBufferWL; + PFNEGLBINDWAYLANDDISPLAYWL eglBindWaylandDisplayWL; + PFNEGLUNBINDWAYLANDDISPLAYWL eglUnbindWaylandDisplayWL; + + const char *egl_exts; + const char *gl_exts; + + struct wl_display *wl_display; +}; + +// TODO: Allocate and return a wlr_egl +/** + * 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); + +/** + * Refer to the eglQueryWaylandBufferWL extension function. + */ +bool wlr_egl_query_buffer(struct wlr_egl *egl, 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. + */ +EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl, + EGLenum target, EGLClientBuffer buffer, const EGLint *attribs); + +/** + * Destroys an egl image created with the given wlr_egl. + */ +bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image); + +/** + * Returns a string for the last error ocurred with egl. + */ +const char *egl_error(void); + +#endif diff --git a/include/wlr/render.h b/include/wlr/render.h index 61169333..5e9f889e 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -44,6 +44,11 @@ void wlr_render_colored_ellipse(struct wlr_renderer *r, const enum wl_shm_format *wlr_renderer_get_formats( struct wlr_renderer *r, size_t *len); /** + * Returns true if this wl_buffer is a DRM buffer. + */ +bool wlr_renderer_buffer_is_drm(struct wlr_renderer *renderer, + struct wl_resource *buffer); +/** * Destroys this wlr_renderer. Textures must be destroyed separately. */ void wlr_renderer_destroy(struct wlr_renderer *renderer); @@ -65,7 +70,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 +85,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, diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index a779ffff..b368d6e1 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -1,7 +1,9 @@ #ifndef _WLR_GLES2_RENDERER_H #define _WLR_GLES2_RENDERER_H #include <wlr/render.h> +#include <wlr/backend.h> -struct wlr_renderer *wlr_gles2_renderer_init(); +struct wlr_egl; +struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend); #endif diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index be9ffe7a..69485e21 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -25,6 +25,8 @@ struct wlr_renderer_impl { const float (*color)[4], const float (*matrix)[16]); const enum wl_shm_format *(*formats)( struct wlr_renderer_state *state, size_t *len); + bool (*buffer_is_drm)(struct wlr_renderer_state *state, + struct wl_resource *buffer); void (*destroy)(struct wlr_renderer_state *state); }; @@ -42,7 +44,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); diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index e8e747cd..94b7ff1e 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -29,6 +29,7 @@ struct wlr_surface_state { struct wlr_surface { struct wl_resource *resource; + struct wlr_renderer *renderer; struct wlr_texture *texture; struct wlr_surface_state current, pending; const char *role; // the lifetime-bound role or null @@ -37,11 +38,13 @@ struct wlr_surface { float surface_to_buffer_matrix[16]; struct { - struct wl_signal destroy; struct wl_signal commit; } signals; struct wl_list frame_callback_list; // wl_surface.frame + + struct wl_listener compositor_listener; // destroy listener used by compositor + void *compositor_data; }; struct wlr_renderer; |