aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/egl.c50
-rw-r--r--render/gles2/renderer.c7
-rw-r--r--render/meson.build2
3 files changed, 44 insertions, 15 deletions
diff --git a/render/egl.c b/render/egl.c
index fe20973c..9ac0b307 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -127,18 +127,23 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
}
eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl->context);
- egl->egl_exts = eglQueryString(egl->display, EGL_EXTENSIONS);
- if (strstr(egl->egl_exts, "EGL_WL_bind_wayland_display") == NULL ||
- strstr(egl->egl_exts, "EGL_KHR_image_base") == NULL) {
+ egl->egl_exts_str = eglQueryString(egl->display, EGL_EXTENSIONS);
+ egl->gl_exts_str = (const char*) glGetString(GL_EXTENSIONS);
+
+ wlr_log(L_INFO, "Using EGL %d.%d", (int)major, (int)minor);
+ wlr_log(L_INFO, "Supported EGL extensions: %s", egl->egl_exts_str);
+ wlr_log(L_INFO, "Using %s", glGetString(GL_VERSION));
+ wlr_log(L_INFO, "Supported OpenGL ES extensions: %s", egl->gl_exts_str);
+
+ if (strstr(egl->egl_exts_str, "EGL_WL_bind_wayland_display") == NULL ||
+ strstr(egl->egl_exts_str, "EGL_KHR_image_base") == NULL) {
wlr_log(L_ERROR, "Required egl extensions not supported");
goto error;
}
- egl->gl_exts = (const char*) glGetString(GL_EXTENSIONS);
- wlr_log(L_INFO, "Using EGL %d.%d", (int)major, (int)minor);
- wlr_log(L_INFO, "Supported EGL extensions: %s", egl->egl_exts);
- wlr_log(L_INFO, "Using %s", glGetString(GL_VERSION));
- wlr_log(L_INFO, "Supported OpenGL ES extensions: %s", egl->gl_exts);
+ egl->egl_exts.buffer_age =
+ strstr(egl->egl_exts_str, "EGL_EXT_buffer_age") != NULL;
+
return true;
error:
@@ -208,3 +213,32 @@ EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) {
}
return surf;
}
+
+int wlr_egl_get_buffer_age(struct wlr_egl *egl, EGLSurface surface) {
+ if (!egl->egl_exts.buffer_age) {
+ return -1;
+ }
+
+ EGLint buffer_age;
+ EGLBoolean ok = eglQuerySurface(egl->display, surface,
+ EGL_BUFFER_AGE_EXT, &buffer_age);
+ if (!ok) {
+ wlr_log(L_ERROR, "Failed to get EGL surface buffer age: %s", egl_error());
+ return -1;
+ }
+
+ return buffer_age;
+}
+
+bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface,
+ int *buffer_age) {
+ if (!eglMakeCurrent(egl->display, surface, surface, egl->context)) {
+ wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
+ return false;
+ }
+
+ if (buffer_age != NULL) {
+ *buffer_age = wlr_egl_get_buffer_age(egl, surface);
+ }
+ return true;
+}
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 89cc4ffb..32f2eb02 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -107,12 +107,7 @@ static void init_globals() {
static void wlr_gles2_begin(struct wlr_renderer *_renderer,
struct wlr_output *output) {
- // TODO: let users customize the clear color?
- GL_CALL(glClearColor(0.25f, 0.25f, 0.25f, 1));
- GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
- int32_t width = output->width;
- int32_t height = output->height;
- GL_CALL(glViewport(0, 0, width, height));
+ GL_CALL(glViewport(0, 0, output->width, output->height));
// enable transparency
GL_CALL(glEnable(GL_BLEND));
diff --git a/render/meson.build b/render/meson.build
index 1eea9a83..309e83cd 100644
--- a/render/meson.build
+++ b/render/meson.build
@@ -22,7 +22,7 @@ lib_wlr_render = static_library(
glapi[0],
glapi[1],
include_directories: wlr_inc,
- dependencies: [glesv2, egl],
+ dependencies: [glesv2, egl, pixman],
)
wlr_render = declare_dependency(