forked from joejulian/gio
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:
committed by
Elias Naur
parent
4719d56f86
commit
60e4cca934
+30
-27
@@ -134,38 +134,41 @@ 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()
|
eglMakeCurrent(c.eglCtx.disp, nilEGLSurface, nilEGLSurface, nilEGLContext)
|
||||||
eglMakeCurrent(c.eglCtx.disp, nilEGLSurface, nilEGLSurface, nilEGLContext)
|
eglDestroySurface(c.eglCtx.disp, c.eglSurf)
|
||||||
eglDestroySurface(c.eglCtx.disp, c.eglSurf)
|
c.eglSurf = nilEGLSurface
|
||||||
c.eglSurf = nilEGLSurface
|
}
|
||||||
}
|
c.eglWin = win
|
||||||
c.width, c.height = width, height
|
if c.eglWin == nilEGLNativeWindowType {
|
||||||
c.eglWin = win
|
return nil
|
||||||
if c.eglWin == nilEGLNativeWindowType {
|
}
|
||||||
|
eglSurf, err := createSurfaceAndMakeCurrent(c.eglCtx, win)
|
||||||
|
c.eglSurf = eglSurf
|
||||||
|
if err != nil {
|
||||||
|
c.eglWin = nilEGLNativeWindowType
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// eglSwapInterval 1 leads to erratic frame rates and unnecessary blocking.
|
||||||
|
// We rely on platform specific frame rate limiting instead, except on Windows
|
||||||
|
// and X11 where eglSwapInterval is all there is.
|
||||||
|
if c.driver.needVSync() {
|
||||||
|
eglSwapInterval(c.eglCtx.disp, 1)
|
||||||
|
} else {
|
||||||
|
eglSwapInterval(c.eglCtx.disp, 0)
|
||||||
|
}
|
||||||
|
} else if c.eglWin == nilEGLNativeWindowType {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
eglSurf, err := createSurfaceAndMakeCurrent(c.eglCtx, win)
|
|
||||||
c.eglSurf = eglSurf
|
|
||||||
if err != nil {
|
|
||||||
c.eglWin = nilEGLNativeWindowType
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// eglSwapInterval 1 leads to erratic frame rates and unnecessary blocking.
|
|
||||||
// We rely on platform specific frame rate limiting instead, except on Windows
|
|
||||||
// and X11 where eglSwapInterval is all there is.
|
|
||||||
if c.driver.needVSync() {
|
|
||||||
eglSwapInterval(c.eglCtx.disp, 1)
|
|
||||||
} else {
|
|
||||||
eglSwapInterval(c.eglCtx.disp, 0)
|
|
||||||
}
|
|
||||||
if c.eglCtx.srgb {
|
if c.eglCtx.srgb {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user