diff --git a/internal/egl/egl.go b/internal/egl/egl.go index ef59e8dc..61ecbfe6 100644 --- a/internal/egl/egl.go +++ b/internal/egl/egl.go @@ -11,12 +11,10 @@ import ( "strings" "gioui.org/gpu" - "gioui.org/internal/gl" "gioui.org/internal/srgb" ) type Context struct { - c *gl.Functions disp _EGLDisplay eglCtx *eglContext eglSurf _EGLSurface @@ -105,14 +103,9 @@ func NewContext(disp NativeDisplayType) (*Context, error) { if err != nil { return nil, err } - f, err := gl.NewFunctions(nil) - if err != nil { - return nil, err - } c := &Context{ disp: eglDisp, eglCtx: eglCtx, - c: f, } return c, nil } @@ -126,7 +119,7 @@ func (c *Context) ReleaseSurface() { return } // Make sure any in-flight GL commands are complete. - c.c.Finish() + eglWaitClient() c.ReleaseCurrent() eglDestroySurface(c.disp, c.eglSurf) c.eglSurf = nilEGLSurface diff --git a/internal/egl/egl_unix.go b/internal/egl/egl_unix.go index 059dd555..38a8cb65 100644 --- a/internal/egl/egl_unix.go +++ b/internal/egl/egl_unix.go @@ -102,3 +102,7 @@ func eglCreateWindowSurface(disp _EGLDisplay, conf _EGLConfig, win NativeWindowT eglSurf := C.eglCreateWindowSurface(disp, conf, win, &attribs[0]) return eglSurf } + +func eglWaitClient() bool { + return C.eglWaitClient() == C.EGL_TRUE +} diff --git a/internal/egl/egl_windows.go b/internal/egl/egl_windows.go index 102e9eb0..4433dd79 100644 --- a/internal/egl/egl_windows.go +++ b/internal/egl/egl_windows.go @@ -40,6 +40,7 @@ var ( _eglSwapBuffers = libEGL.NewProc("eglSwapBuffers") _eglTerminate = libEGL.NewProc("eglTerminate") _eglQueryString = libEGL.NewProc("eglQueryString") + _eglWaitClient = libEGL.NewProc("eglWaitClient") ) var loadOnce sync.Once @@ -156,6 +157,11 @@ func eglQueryString(disp _EGLDisplay, name _EGLint) string { return syscall.BytePtrToString((*byte)(unsafe.Pointer(r))) } +func eglWaitClient() bool { + r, _, _ := _eglWaitClient.Call() + return r != 0 +} + // issue34474KeepAlive calls runtime.KeepAlive as a // workaround for golang.org/issue/34474. func issue34474KeepAlive(v interface{}) {