[client] x11: make use of eglSwapBuffersWithDamage if it's available

This commit is contained in:
Geoffrey McRae 2021-07-12 20:57:34 +10:00
parent 092ce61908
commit 03c247a9ff

View file

@ -943,7 +943,40 @@ static EGLNativeWindowType x11GetEGLNativeWindow(void)
static void x11EGLSwapBuffers(EGLDisplay display, EGLSurface surface,
const struct Rect * damage, int count)
{
eglSwapBuffers(display, surface);
static bool detectDone = false;
static eglSwapBuffersWithDamageKHR_t swapWithDamage = NULL;
if (!detectDone)
{
const char *exts = eglQueryString(display, EGL_EXTENSIONS);
DEBUG_INFO("%s", exts);
if (util_hasGLExt(exts, "EGL_KHR_swap_buffers_with_damage"))
swapWithDamage = g_egl_dynProcs.eglSwapBuffersWithDamageKHR;
else if (util_hasGLExt(exts, "EGL_EXT_swap_buffers_with_damage"))
swapWithDamage = g_egl_dynProcs.eglSwapBuffersWithDamageEXT;
if (swapWithDamage)
DEBUG_INFO("Using eglSwapBuffersWithDamage");
detectDone = true;
}
if (swapWithDamage && count)
{
EGLint rects[count*4];
EGLint *p = rects;
for(int i = 0; i < count; ++i, p += 4)
{
p[0] = damage[i].x;
p[1] = damage[i].y;
p[2] = damage[i].w;
p[3] = damage[i].h;
}
swapWithDamage(display, surface, rects, count);
}
else
eglSwapBuffers(display, surface);
}
#endif