mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[client] ds: refactor common EGL swap with damage logic
This commit creates a new utility library, eglutil.h, which contains code to detect and use EGL_KHR_swap_buffers_with_damage or its EXT equivalent. This logic used to be duplicated between the X11 and Wayland display servers, which is not ideal.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#ifdef ENABLE_EGL
|
||||
#include <EGL/eglext.h>
|
||||
#include "egl_dynprocs.h"
|
||||
#include "eglutil.h"
|
||||
#endif
|
||||
|
||||
#include "app.h"
|
||||
@@ -943,40 +944,11 @@ static EGLNativeWindowType x11GetEGLNativeWindow(void)
|
||||
static void x11EGLSwapBuffers(EGLDisplay display, EGLSurface surface,
|
||||
const struct Rect * damage, int count)
|
||||
{
|
||||
static bool detectDone = false;
|
||||
static eglSwapBuffersWithDamageKHR_t swapWithDamage = NULL;
|
||||
static struct SwapWithDamageData data = {0};
|
||||
if (!data.init)
|
||||
swapWithDamageInit(&data, display);
|
||||
|
||||
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);
|
||||
swapWithDamage(&data, display, surface, damage, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user