mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Refactor EGL handling
This commit is contained in:
parent
4aaf76cb66
commit
c24351681f
26 changed files with 156 additions and 98 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#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>
|
||||
|
||||
|
|
@ -19,8 +21,14 @@ 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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef WLR_BACKEND_EGL_H
|
||||
#define WLR_BACKEND_EGL_H
|
||||
#ifndef WLR_EGL_H
|
||||
#define WLR_EGL_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
|
@ -10,12 +10,22 @@ struct wlr_egl {
|
|||
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.
|
||||
|
|
@ -35,15 +45,9 @@ void wlr_egl_free(struct wlr_egl *egl);
|
|||
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.
|
||||
* Refer to the eglQueryWaylandBufferWL extension function.
|
||||
*/
|
||||
bool wlr_egl_query_buffer(struct wl_resource *buf,
|
||||
bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf,
|
||||
EGLint attrib, EGLint *value);
|
||||
|
||||
/**
|
||||
|
|
@ -54,16 +58,14 @@ 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);
|
||||
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(EGLImageKHR image);
|
||||
bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image);
|
||||
|
||||
/**
|
||||
* Returns a string for the last error ocurred with egl.
|
||||
|
|
@ -43,6 +43,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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#ifndef _WLR_GLES2_RENDERER_H
|
||||
#define _WLR_GLES2_RENDERER_H
|
||||
#include <wlr/render.h>
|
||||
#include <wlr/backend.h>
|
||||
|
||||
struct wlr_egl;
|
||||
struct wlr_renderer *wlr_gles2_renderer_init();
|
||||
struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue