app/internal/window: Do not re-create EGL surfaces when only resizing

This prevents flickering when resizing the window on X11.

Signed-off-by: Denis Bernard <db047h@gmail.com>
This commit is contained in:
Denis Bernard
2019-11-05 13:07:36 +01:00
committed by Elias Naur
parent 4719d56f86
commit 60e4cca934
+7 -4
View File
@@ -134,12 +134,13 @@ func (c *context) MakeCurrent() error {
if c.eglWin == win && width == c.width && height == c.height { if c.eglWin == win && width == c.width && height == c.height {
return nil return nil
} }
if win == nilEGLNativeWindowType { c.width, c.height = width, height
if c.srgbFBO != nil { // Do not re-create surfaces when only resizing. This prevents flickering when resizing on X11.
if c.eglWin != win {
if win == nilEGLNativeWindowType && c.srgbFBO != nil {
c.srgbFBO.Release() c.srgbFBO.Release()
c.srgbFBO = nil c.srgbFBO = nil
} }
}
if c.eglSurf != nilEGLSurface { if c.eglSurf != nilEGLSurface {
// Make sure any in-flight GL commands are complete. // Make sure any in-flight GL commands are complete.
c.c.Finish() c.c.Finish()
@@ -147,7 +148,6 @@ func (c *context) MakeCurrent() error {
eglDestroySurface(c.eglCtx.disp, c.eglSurf) eglDestroySurface(c.eglCtx.disp, c.eglSurf)
c.eglSurf = nilEGLSurface c.eglSurf = nilEGLSurface
} }
c.width, c.height = width, height
c.eglWin = win c.eglWin = win
if c.eglWin == nilEGLNativeWindowType { if c.eglWin == nilEGLNativeWindowType {
return nil return nil
@@ -166,6 +166,9 @@ func (c *context) MakeCurrent() error {
} else { } else {
eglSwapInterval(c.eglCtx.disp, 0) eglSwapInterval(c.eglCtx.disp, 0)
} }
} else if c.eglWin == nilEGLNativeWindowType {
return nil
}
if c.eglCtx.srgb { if c.eglCtx.srgb {
return nil return nil
} }