mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
uidriver/glfw: Reduce (*thread).Call at (*UserInterface).updateSize
Updates #1367
This commit is contained in:
parent
d9906835ad
commit
ee50f611ee
@ -761,26 +761,16 @@ func (u *UserInterface) init() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) updateSize() {
|
func (u *UserInterface) updateSize() (float64, float64, bool) {
|
||||||
_ = u.t.Call(func() error {
|
ww, wh := u.windowWidth, u.windowHeight
|
||||||
w, h := u.windowWidth, u.windowHeight
|
u.setWindowSize(ww, wh, u.isFullscreen())
|
||||||
u.setWindowSize(w, h, u.isFullscreen())
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
sizeChanged := false
|
|
||||||
_ = u.t.Call(func() error {
|
|
||||||
if !u.toChangeSize {
|
if !u.toChangeSize {
|
||||||
return nil
|
return 0, 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
u.toChangeSize = false
|
u.toChangeSize = false
|
||||||
sizeChanged = true
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if sizeChanged {
|
|
||||||
var w, h float64
|
var w, h float64
|
||||||
_ = u.t.Call(func() error {
|
|
||||||
if u.isFullscreen() {
|
if u.isFullscreen() {
|
||||||
v := currentMonitor(u.window).GetVideoMode()
|
v := currentMonitor(u.window).GetVideoMode()
|
||||||
ww, wh := v.Width, v.Height
|
ww, wh := v.Width, v.Height
|
||||||
@ -797,10 +787,8 @@ func (u *UserInterface) updateSize() {
|
|||||||
// On Linux/UNIX, further adjusting is required (#1307).
|
// On Linux/UNIX, further adjusting is required (#1307).
|
||||||
w = u.toFramebufferPixel(w)
|
w = u.toFramebufferPixel(w)
|
||||||
h = u.toFramebufferPixel(h)
|
h = u.toFramebufferPixel(h)
|
||||||
return nil
|
|
||||||
})
|
return w, h, true
|
||||||
u.context.Layout(w, h)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) update() error {
|
func (u *UserInterface) update() error {
|
||||||
@ -836,8 +824,18 @@ func (u *UserInterface) update() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var w, h float64
|
||||||
|
var changed bool
|
||||||
|
|
||||||
// This call is needed for initialization.
|
// This call is needed for initialization.
|
||||||
u.updateSize()
|
_ = u.t.Call(func() error {
|
||||||
|
w, h, changed = u.updateSize()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if changed {
|
||||||
|
u.context.Layout(w, h)
|
||||||
|
}
|
||||||
|
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
glfw.PollEvents()
|
glfw.PollEvents()
|
||||||
@ -1103,7 +1101,15 @@ func (u *UserInterface) IsScreenTransparent() bool {
|
|||||||
|
|
||||||
func (u *UserInterface) ResetForFrame() {
|
func (u *UserInterface) ResetForFrame() {
|
||||||
// The offscreens must be updated every frame (#490).
|
// The offscreens must be updated every frame (#490).
|
||||||
u.updateSize()
|
var w, h float64
|
||||||
|
var changed bool
|
||||||
|
_ = u.t.Call(func() error {
|
||||||
|
w, h, changed = u.updateSize()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if changed {
|
||||||
|
u.context.Layout(w, h)
|
||||||
|
}
|
||||||
u.input.resetForFrame()
|
u.input.resetForFrame()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user