app: ensure the previous frame is complete before accepting another

It matters for end-to-end tests that rely on the window contents.

Before this change, tests had to wait for 2 extra frames. This change
ensures that the first completed FrameEvent.Frame call guarantees
the previous frame is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-30 00:49:48 +01:00
parent d31a129bf9
commit 2e605f2dcb
+7 -7
View File
@@ -261,13 +261,6 @@ func (w *Window) run(opts *window.Options) {
w.hasNextFrame = false
e2.Frame = w.update
w.out <- e2.FrameEvent
var frame *op.Ops
// Wait for either a frame or the ack event,
// which meant that the client didn't draw.
select {
case frame = <-w.frames:
case w.out <- ackEvent:
}
if w.gpu != nil {
if e2.Sync {
w.gpu.Refresh()
@@ -290,6 +283,13 @@ func (w *Window) run(opts *window.Options) {
return
}
}
var frame *op.Ops
// Wait for either a frame or the ack event,
// which meant that the client didn't draw.
select {
case frame = <-w.frames:
case w.out <- ackEvent:
}
w.draw(e2.Size, frame)
if e2.Sync {
if err := w.gpu.Flush(); err != nil {