aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/renderer.c23
-rw-r--r--render/gles2/texture.c35
2 files changed, 37 insertions, 21 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 0de777cc..237dc67b 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -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;
}
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 2a2073c6..f2c88af5 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -5,12 +5,12 @@
#include <GLES2/gl2ext.h>
#include <wayland-util.h>
#include <wayland-server-protocol.h>
+#include <wlr/egl.h>
#include <wlr/render.h>
#include <wlr/render/interface.h>
#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
#include "render/gles2.h"
-#include "backend/egl.h"
static struct pixel_format external_pixel_format = {
.wl_format = 0,
@@ -139,23 +139,25 @@ static bool gles2_texture_update_shm(struct wlr_texture_state *texture,
return true;
}
-static bool gles2_texture_upload_drm(struct wlr_texture_state *texture,
- struct wl_resource* buf) {
+static bool gles2_texture_upload_drm(struct wlr_texture_state *tex,
+ struct wl_resource *buf) {
if (!glEGLImageTargetTexture2DOES) {
return false;
}
EGLint format;
- if (!wlr_egl_query_buffer(buf, EGL_TEXTURE_FORMAT, &format)) {
+ if (!wlr_egl_query_buffer(tex->egl, buf, EGL_TEXTURE_FORMAT, &format)) {
wlr_log(L_INFO, "upload_drm called with no drm buffer");
return false;
}
- wlr_egl_query_buffer(buf, EGL_WIDTH, (EGLint*) &texture->wlr_texture->width);
- wlr_egl_query_buffer(buf, EGL_HEIGHT, (EGLint*) &texture->wlr_texture->height);
+ wlr_egl_query_buffer(tex->egl, buf, EGL_WIDTH,
+ (EGLint*)&tex->wlr_texture->width);
+ wlr_egl_query_buffer(tex->egl, buf, EGL_HEIGHT,
+ (EGLint*)&tex->wlr_texture->height);
EGLint inverted_y;
- wlr_egl_query_buffer(buf, EGL_WAYLAND_Y_INVERTED_WL, &inverted_y);
+ wlr_egl_query_buffer(tex->egl, buf, EGL_WAYLAND_Y_INVERTED_WL, &inverted_y);
GLenum target;
const struct pixel_format *pf;
@@ -174,22 +176,22 @@ static bool gles2_texture_upload_drm(struct wlr_texture_state *texture,
return false;
}
- gles2_texture_gen_texture(texture);
- GL_CALL(glBindTexture(GL_TEXTURE_2D, texture->tex_id));
+ gles2_texture_gen_texture(tex);
+ GL_CALL(glBindTexture(GL_TEXTURE_2D, tex->tex_id));
EGLint attribs[] = { EGL_WAYLAND_PLANE_WL, 0, EGL_NONE };
- texture->image = wlr_egl_create_image(EGL_WAYLAND_BUFFER_WL,
+ tex->image = wlr_egl_create_image(tex->egl, EGL_WAYLAND_BUFFER_WL,
(EGLClientBuffer*) buf, attribs);
- if (!texture->image) {
+ if (!tex->image) {
wlr_log(L_ERROR, "failed to create egl image: %s", egl_error());
return false;
}
GL_CALL(glActiveTexture(GL_TEXTURE0));
- GL_CALL(glBindTexture(target, texture->tex_id));
- GL_CALL(glEGLImageTargetTexture2DOES(target, texture->image));
- texture->wlr_texture->valid = true;
- texture->pixel_format = pf;
+ GL_CALL(glBindTexture(target, tex->tex_id));
+ GL_CALL(glEGLImageTargetTexture2DOES(target, tex->image));
+ tex->wlr_texture->valid = true;
+ tex->pixel_format = pf;
return true;
}
@@ -230,10 +232,11 @@ static struct wlr_texture_impl wlr_texture_impl = {
.destroy = gles2_texture_destroy,
};
-struct wlr_texture *gles2_texture_init() {
+struct wlr_texture *gles2_texture_init(struct wlr_egl *egl) {
struct wlr_texture_state *state = calloc(sizeof(struct wlr_texture_state), 1);
struct wlr_texture *texture = wlr_texture_init(state, &wlr_texture_impl);
state->wlr_texture = texture;
+ state->egl = egl;
wl_signal_init(&texture->destroy_signal);
return texture;
}