diff options
author | emersion <contact@emersion.fr> | 2018-02-09 22:54:14 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-02-09 22:54:14 +0100 |
commit | bf6d24540000339029a30715f1f72b5b95a45018 (patch) | |
tree | 89c04c0a109bce115f9a749d8e1958d666e1f02d /render | |
parent | 34489dca16ef9e7fd05c161b8b4f2fd5ce5e4ef0 (diff) |
Swap buffers with damage
Diffstat (limited to 'render')
-rw-r--r-- | render/egl.c | 39 | ||||
-rw-r--r-- | render/glapi.txt | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/render/egl.c b/render/egl.c index 9ac0b307..328726ba 100644 --- a/render/egl.c +++ b/render/egl.c @@ -1,8 +1,8 @@ #include <assert.h> +#include <stdlib.h> #include <EGL/egl.h> #include <EGL/eglext.h> #include <GLES2/gl2.h> -#include <stdlib.h> #include <wlr/util/log.h> #include <wlr/render/egl.h> #include "glapi.h" @@ -143,6 +143,9 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, egl->egl_exts.buffer_age = strstr(egl->egl_exts_str, "EGL_EXT_buffer_age") != NULL; + egl->egl_exts.swap_buffers_with_damage = + strstr(egl->egl_exts_str, "EGL_EXT_swap_buffers_with_damage") != NULL || + strstr(egl->egl_exts_str, "EGL_KHR_swap_buffers_with_damage") != NULL; return true; @@ -242,3 +245,37 @@ bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface, } return true; } + +bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, + pixman_region32_t *damage) { + EGLBoolean ret; + if (damage != NULL && egl->egl_exts.swap_buffers_with_damage) { + int nrects; + pixman_box32_t *rects = + pixman_region32_rectangles(damage, &nrects); + EGLint egl_damage[4 * nrects]; + for (int i = 0; i < nrects; ++i) { + egl_damage[4*i] = rects[i].x1; + egl_damage[4*i + 1] = rects[i].y1; + egl_damage[4*i + 2] = rects[i].x2 - rects[i].x1; + egl_damage[4*i + 3] = rects[i].y2 - rects[i].y1; + } + + assert(eglSwapBuffersWithDamageEXT || eglSwapBuffersWithDamageKHR); + if (eglSwapBuffersWithDamageEXT) { + ret = eglSwapBuffersWithDamageEXT(egl->display, surface, egl_damage, + nrects); + } else { + ret = eglSwapBuffersWithDamageKHR(egl->display, surface, egl_damage, + nrects); + } + } else { + ret = eglSwapBuffers(egl->display, surface); + } + + if (!ret) { + wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error()); + return false; + } + return true; +} diff --git a/render/glapi.txt b/render/glapi.txt index 81791204..0b0b452c 100644 --- a/render/glapi.txt +++ b/render/glapi.txt @@ -6,3 +6,5 @@ eglCreatePlatformWindowSurfaceEXT -eglBindWaylandDisplayWL -eglUnbindWaylandDisplayWL -glEGLImageTargetTexture2DOES +-eglSwapBuffersWithDamageEXT +-eglSwapBuffersWithDamageKHR |