uidriver/glfw: Avoid (*thread).Call when possible at (*UserInterface).loop

Updates #1367
This commit is contained in:
Hajime Hoshi 2020-10-17 06:08:13 +09:00
parent cbb70d045c
commit 33fd7c935a

View File

@ -874,10 +874,16 @@ func (u *UserInterface) loop() error {
if err := u.context.Update(); err != nil { if err := u.context.Update(); err != nil {
return err return err
} }
_ = u.t.Call(func() error {
u.swapBuffers() // swapBuffers also checks IsGL, so this condition is redundant.
return nil // However, (*thread).Call is not good for performance due to channels.
}) // Let's avoid this whenever possible (#1367).
if u.Graphics().IsGL() {
_ = u.t.Call(func() error {
u.swapBuffers()
return nil
})
}
if unfocused { if unfocused {
t2 = time.Now() t2 = time.Now()