mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
internal/egl: replace glFinish with eglWaitClient
glFinish depends on package gl which is about to require a function pointer loader. eglWaitClient is in the EGL API and always available. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-8
@@ -11,12 +11,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gioui.org/gpu"
|
"gioui.org/gpu"
|
||||||
"gioui.org/internal/gl"
|
|
||||||
"gioui.org/internal/srgb"
|
"gioui.org/internal/srgb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
c *gl.Functions
|
|
||||||
disp _EGLDisplay
|
disp _EGLDisplay
|
||||||
eglCtx *eglContext
|
eglCtx *eglContext
|
||||||
eglSurf _EGLSurface
|
eglSurf _EGLSurface
|
||||||
@@ -105,14 +103,9 @@ func NewContext(disp NativeDisplayType) (*Context, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
f, err := gl.NewFunctions(nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
c := &Context{
|
c := &Context{
|
||||||
disp: eglDisp,
|
disp: eglDisp,
|
||||||
eglCtx: eglCtx,
|
eglCtx: eglCtx,
|
||||||
c: f,
|
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
@@ -126,7 +119,7 @@ func (c *Context) ReleaseSurface() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Make sure any in-flight GL commands are complete.
|
// Make sure any in-flight GL commands are complete.
|
||||||
c.c.Finish()
|
eglWaitClient()
|
||||||
c.ReleaseCurrent()
|
c.ReleaseCurrent()
|
||||||
eglDestroySurface(c.disp, c.eglSurf)
|
eglDestroySurface(c.disp, c.eglSurf)
|
||||||
c.eglSurf = nilEGLSurface
|
c.eglSurf = nilEGLSurface
|
||||||
|
|||||||
@@ -102,3 +102,7 @@ func eglCreateWindowSurface(disp _EGLDisplay, conf _EGLConfig, win NativeWindowT
|
|||||||
eglSurf := C.eglCreateWindowSurface(disp, conf, win, &attribs[0])
|
eglSurf := C.eglCreateWindowSurface(disp, conf, win, &attribs[0])
|
||||||
return eglSurf
|
return eglSurf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func eglWaitClient() bool {
|
||||||
|
return C.eglWaitClient() == C.EGL_TRUE
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ var (
|
|||||||
_eglSwapBuffers = libEGL.NewProc("eglSwapBuffers")
|
_eglSwapBuffers = libEGL.NewProc("eglSwapBuffers")
|
||||||
_eglTerminate = libEGL.NewProc("eglTerminate")
|
_eglTerminate = libEGL.NewProc("eglTerminate")
|
||||||
_eglQueryString = libEGL.NewProc("eglQueryString")
|
_eglQueryString = libEGL.NewProc("eglQueryString")
|
||||||
|
_eglWaitClient = libEGL.NewProc("eglWaitClient")
|
||||||
)
|
)
|
||||||
|
|
||||||
var loadOnce sync.Once
|
var loadOnce sync.Once
|
||||||
@@ -156,6 +157,11 @@ func eglQueryString(disp _EGLDisplay, name _EGLint) string {
|
|||||||
return syscall.BytePtrToString((*byte)(unsafe.Pointer(r)))
|
return syscall.BytePtrToString((*byte)(unsafe.Pointer(r)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func eglWaitClient() bool {
|
||||||
|
r, _, _ := _eglWaitClient.Call()
|
||||||
|
return r != 0
|
||||||
|
}
|
||||||
|
|
||||||
// issue34474KeepAlive calls runtime.KeepAlive as a
|
// issue34474KeepAlive calls runtime.KeepAlive as a
|
||||||
// workaround for golang.org/issue/34474.
|
// workaround for golang.org/issue/34474.
|
||||||
func issue34474KeepAlive(v interface{}) {
|
func issue34474KeepAlive(v interface{}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user