Refactor EGL handling

This commit is contained in:
Drew DeVault 2017-08-10 22:15:37 -04:00
parent 4aaf76cb66
commit c24351681f
26 changed files with 156 additions and 98 deletions

View file

@ -5,11 +5,12 @@
#include <GLES2/gl2ext.h>
#include <wayland-util.h>
#include <wayland-server-protocol.h>
#include <wlr/egl.h>
#include <wlr/backend.h>
#include <wlr/render.h>
#include <wlr/render/interface.h>
#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
#include "backend/egl.h"
#include "render/gles2.h"
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = NULL;
@ -123,7 +124,7 @@ static void wlr_gles2_end(struct wlr_renderer_state *state) {
}
static struct wlr_texture *wlr_gles2_texture_init(struct wlr_renderer_state *state) {
return gles2_texture_init();
return gles2_texture_init(state->egl);
}
static void draw_quad() {
@ -195,8 +196,14 @@ static const enum wl_shm_format *wlr_gles2_formats(
return formats;
}
static bool wlr_gles2_buffer_is_drm(struct wlr_renderer_state *state,
struct wl_resource *buffer) {
EGLint format;
return wlr_egl_query_buffer(state->egl, buffer, EGL_TEXTURE_FORMAT, &format);
}
static void wlr_gles2_destroy(struct wlr_renderer_state *state) {
// no-op
free(state);
}
static struct wlr_renderer_impl wlr_renderer_impl = {
@ -207,10 +214,16 @@ static struct wlr_renderer_impl wlr_renderer_impl = {
.render_quad = wlr_gles2_render_quad,
.render_ellipse = wlr_gles2_render_ellipse,
.formats = wlr_gles2_formats,
.buffer_is_drm = wlr_gles2_buffer_is_drm,
.destroy = wlr_gles2_destroy
};
struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_egl *egl) {
struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend) {
init_globals();
return wlr_renderer_init(NULL, &wlr_renderer_impl);
struct wlr_egl *egl = wlr_backend_get_egl(backend);
struct wlr_renderer_state *state = calloc(1, sizeof(struct wlr_renderer_state));
struct wlr_renderer *renderer = wlr_renderer_init(state, &wlr_renderer_impl);
state->renderer = renderer;
state->egl = egl;
return renderer;
}