From e796646abd9bf8f1f22f514c0e021218ed662b70 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 15 Oct 2022 03:36:25 +0900 Subject: [PATCH] internal/graphicscommand: rename arguments --- internal/graphicscommand/command.go | 17 +++++++++-------- internal/restorable/images.go | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index ba375635f..7d39b0cec 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -159,15 +159,15 @@ func (q *commandQueue) Enqueue(command command) { } // Flush flushes the command queue. -func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, present bool) (err error) { +func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, endFrame bool) (err error) { runOnRenderingThread(func() { - err = q.flush(graphicsDriver, present) + err = q.flush(graphicsDriver, endFrame) }) return } // flush must be called the main thread. -func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, present bool) error { +func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bool) error { if len(q.commands) == 0 { return nil } @@ -223,7 +223,8 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, present boo } cs = cs[nc:] } - if err := graphicsDriver.End(present && screenRendered); err != nil { + // TODO: Without checking screenRendered, the tests fail on Windows. Investigate this issue. + if err := graphicsDriver.End(endFrame && screenRendered); err != nil { return err } @@ -244,10 +245,10 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, present boo return nil } -// FlushCommands flushes the command queue and present the screen. -// If present is true, the current screen is used to present. -func FlushCommands(graphicsDriver graphicsdriver.Graphics, present bool) error { - return theCommandQueue.Flush(graphicsDriver, present) +// FlushCommands flushes the command queue and present the screen if needed. +// If endFrame is true, the current screen might be used to present. +func FlushCommands(graphicsDriver graphicsdriver.Graphics, endFrame bool) error { + return theCommandQueue.Flush(graphicsDriver, endFrame) } // drawTrianglesCommand represents a drawing command to draw an image on another image. diff --git a/internal/restorable/images.go b/internal/restorable/images.go index 3d07e0526..34d681de7 100644 --- a/internal/restorable/images.go +++ b/internal/restorable/images.go @@ -52,10 +52,10 @@ var theImages = &images{ } // ResolveStaleImages flushes the queued draw commands and resolves all stale images. -// If present is true, the current screen is used to present when flushing the commands. +// If endFrame is true, the current screen might be used to present when flushing the commands. // // ResolveStaleImages is intended to be called at the end of a frame. -func ResolveStaleImages(graphicsDriver graphicsdriver.Graphics, present bool) error { +func ResolveStaleImages(graphicsDriver graphicsdriver.Graphics, endFrame bool) error { if debug.IsDebug { debug.Logf("Internal image sizes:\n") imgs := make([]*graphicscommand.Image, 0, len(theImages.images)) @@ -65,7 +65,7 @@ func ResolveStaleImages(graphicsDriver graphicsdriver.Graphics, present bool) er graphicscommand.LogImagesInfo(imgs) } - if err := graphicscommand.FlushCommands(graphicsDriver, present); err != nil { + if err := graphicscommand.FlushCommands(graphicsDriver, endFrame); err != nil { return err } if !needsRestoring() {