Commit c8306ed8 authored by Pierre-Loup A. Griffais's avatar Pierre-Loup A. Griffais Committed by Martin Flöser
Browse files

kwin-gles: add support for EGL_NV_post_sub_buffer

The EGL path had no support for presenting sub-regions of the screen, we can
leverage EGL_NV_post_sub_buffer for that. This wouldn't be a win if we didn't
have to opt-out of flipping.

REVIEW: 102889
parent c10419b6
......@@ -291,6 +291,7 @@ namespace KWin
// EGL
eglCreateImageKHR_func eglCreateImageKHR;
eglDestroyImageKHR_func eglDestroyImageKHR;
eglPostSubBufferNV_func eglPostSubBufferNV;
// GLES
glEGLImageTargetTexture2DOES_func glEGLImageTargetTexture2DOES;
......@@ -305,6 +306,12 @@ void eglResolveFunctions()
eglCreateImageKHR = NULL;
eglDestroyImageKHR = NULL;
}
if (hasGLExtension("EGL_NV_post_sub_buffer")) {
eglPostSubBufferNV = (eglPostSubBufferNV_func)eglGetProcAddress("eglPostSubBufferNV");
} else {
eglPostSubBufferNV = NULL;
}
}
void glResolveFunctions()
......
......@@ -392,8 +392,10 @@ void KWIN_EXPORT glResolveFunctions();
// EGL
typedef EGLImageKHR(*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*);
typedef EGLBoolean(*eglDestroyImageKHR_func)(EGLDisplay, EGLImageKHR);
typedef EGLBoolean (*eglPostSubBufferNV_func)(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
extern KWIN_EXPORT eglCreateImageKHR_func eglCreateImageKHR;
extern KWIN_EXPORT eglDestroyImageKHR_func eglDestroyImageKHR;
extern KWIN_EXPORT eglPostSubBufferNV_func eglPostSubBufferNV;
// GLES
typedef GLvoid(*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES);
......
......@@ -26,6 +26,7 @@ EGLDisplay dpy;
EGLConfig config;
EGLSurface surface;
EGLContext ctx;
int surfaceHasSubPost;
SceneOpenGL::SceneOpenGL(Workspace* ws)
: Scene(ws)
......@@ -108,6 +109,8 @@ bool SceneOpenGL::initRenderingContext()
eglSurfaceAttrib(dpy, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
eglQuerySurface(dpy, surface, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceHasSubPost);
const EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
......@@ -199,9 +202,10 @@ void SceneOpenGL::flushBuffer(int mask, QRegion damage)
{
Q_UNUSED(damage)
glFlush();
if (mask & PAINT_SCREEN_REGION) {
// TODO: implement me properly
eglSwapBuffers(dpy, surface);
if (mask & PAINT_SCREEN_REGION && surfaceHasSubPost && eglPostSubBufferNV) {
QRect damageRect = damage.boundingRect();
eglPostSubBufferNV(dpy, surface, damageRect.left(), displayHeight() - damageRect.bottom() - 1, damageRect.width(), damageRect.height());
} else {
eglSwapBuffers(dpy, surface);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment