diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-02-09 09:38:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-09 09:38:48 -0500 |
commit | 34489dca16ef9e7fd05c161b8b4f2fd5ce5e4ef0 (patch) | |
tree | 2a90beb98aacd85bbc5bd30df998b4e7c92ec3e7 /render/egl.c | |
parent | 09c2626e32fd0eadc4b95a4f36b34f6bde79f6f4 (diff) | |
parent | cdd55b5d19470981ad71f8e6d31bd8152e44364b (diff) |
Merge pull request #571 from emersion/output-damage
Output damage tracking
Diffstat (limited to 'render/egl.c')
-rw-r--r-- | render/egl.c | 50 |
1 files changed, 42 insertions, 8 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; +} |