uidriver/glfw: Reduce (*thread).Call at (*UserInterface).update

Updates #1367
This commit is contained in:
Hajime Hoshi 2020-10-17 05:31:21 +09:00
parent 1864c22ad6
commit d9906835ad

View File

@ -824,6 +824,13 @@ func (u *UserInterface) update() error {
u.vsyncInited = true u.vsyncInited = true
} }
// Update the screen size when the window is resizable.
if w, h := u.reqWidth, u.reqHeight; w != 0 || h != 0 {
u.setWindowSize(w, h, u.isFullscreen())
}
u.reqWidth = 0
u.reqHeight = 0
return nil return nil
}); err != nil { }); err != nil {
return err return err
@ -845,19 +852,7 @@ func (u *UserInterface) update() error {
} }
return nil return nil
}) })
if err := u.context.Update(); err != nil {
return err
}
// Update the screen size when the window is resizable.
_ = u.t.Call(func() error {
if w, h := u.reqWidth, u.reqHeight; w != 0 || h != 0 {
u.setWindowSize(w, h, u.isFullscreen())
}
u.reqWidth = 0
u.reqHeight = 0
return nil
})
return nil return nil
} }
@ -886,11 +881,14 @@ func (u *UserInterface) loop() error {
if err := u.update(); err != nil { if err := u.update(); err != nil {
return err return err
} }
if err := u.context.Update(); err != nil {
return err
}
_ = u.t.Call(func() error { _ = u.t.Call(func() error {
u.swapBuffers() u.swapBuffers()
return nil return nil
}) })
if unfocused { if unfocused {
t2 = time.Now() t2 = time.Now()
} }