From 6940435c0322a93d3ebaee2583509e123ad496d3 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 14 Sep 2024 01:15:15 +0900 Subject: [PATCH] ebiten: retract RunGameOptions.StrictContextRestoration Closes #3098 --- run.go | 61 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/run.go b/run.go index 4a4a6336b..800e9e5d0 100644 --- a/run.go +++ b/run.go @@ -297,25 +297,6 @@ type RunGameOptions struct { // X11InstanceName is an instance name in the ICCCM WM_CLASS window property. X11InstanceName string - - // StrictContextRestration indicates whether the context lost should be restored strictly by Ebitengine or not. - // - // StrictContextRestration is available only on Android. Otherwise, StrictContextRestration is ignored. - // Thus, StrictContextRestration should be used with mobile.SetGameWithOptions, rather than RunGameWithOptions. - // - // In Android, Ebitengien uses `GLSurfaceView`'s `setPreserveEGLContextOnPause(true)`. - // This works in most cases, but it is still possible that the context is lost in some minor cases. - // - // When StrictContextRestration is true, Ebitengine tries to restore the context more strictly - // for such minor cases. - // However, this might cause a performance issue since Ebitengine tries to keep all the information - // to restore the context. - // - // When StrictContextRestration is false, Ebitengine does nothing special to restore the context and - // relies on the OS's behavior. - // - // The default (zero) value is false. - StrictContextRestration bool } // RunGameWithOptions starts the main loop and runs the game with the specified options. @@ -734,17 +715,39 @@ func toUIRunOptions(options *RunGameOptions) *ui.RunOptions { if options.X11InstanceName == "" { options.X11InstanceName = defaultX11InstanceName } + + // ui.RunOptions.StrictContextRestoration is not used so far (#3098). + // This might be reused in the future. + // The original comment for StrictContextRestration is as follows: + // + // StrictContextRestration indicates whether the context lost should be restored strictly by Ebitengine or not. + // + // StrictContextRestration is available only on Android. Otherwise, StrictContextRestration is ignored. + // Thus, StrictContextRestration should be used with mobile.SetGameWithOptions, rather than RunGameWithOptions. + // + // In Android, Ebitengien uses `GLSurfaceView`'s `setPreserveEGLContextOnPause(true)`. + // This works in most cases, but it is still possible that the context is lost in some minor cases. + // + // When StrictContextRestration is true, Ebitengine tries to restore the context more strictly + // for such minor cases. + // However, this might cause a performance issue since Ebitengine tries to keep all the information + // to restore the context. + // + // When StrictContextRestration is false, Ebitengine does nothing special to restore the context and + // relies on the OS's behavior. + // + // The default (zero) value is false. + return &ui.RunOptions{ - GraphicsLibrary: ui.GraphicsLibrary(options.GraphicsLibrary), - InitUnfocused: options.InitUnfocused, - ScreenTransparent: options.ScreenTransparent, - SkipTaskbar: options.SkipTaskbar, - SingleThread: options.SingleThread, - DisableHiDPI: options.DisableHiDPI, - ColorSpace: graphicsdriver.ColorSpace(options.ColorSpace), - X11ClassName: options.X11ClassName, - X11InstanceName: options.X11InstanceName, - StrictContextRestoration: options.StrictContextRestration, + GraphicsLibrary: ui.GraphicsLibrary(options.GraphicsLibrary), + InitUnfocused: options.InitUnfocused, + ScreenTransparent: options.ScreenTransparent, + SkipTaskbar: options.SkipTaskbar, + SingleThread: options.SingleThread, + DisableHiDPI: options.DisableHiDPI, + ColorSpace: graphicsdriver.ColorSpace(options.ColorSpace), + X11ClassName: options.X11ClassName, + X11InstanceName: options.X11InstanceName, } }