internal/ui: refactoring: integrate Run except for mobiles

This commit is contained in:
Hajime Hoshi 2023-11-05 00:49:53 +09:00
parent 563bbda615
commit 3df2ffebd1
5 changed files with 8 additions and 25 deletions

View File

@ -18,6 +18,7 @@ package ui
import (
stdcontext "context"
"runtime"
"golang.org/x/sync/errgroup"
@ -25,6 +26,13 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/thread"
)
func (u *UserInterface) Run(game Game, options *RunOptions) error {
if options.SingleThread || buildTagSingleThread || runtime.GOOS == "js" {
return u.runSingleThread(game, options)
}
return u.runMultiThread(game, options)
}
func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error {
u.mainThread = thread.NewOSThread()
u.renderThread = thread.NewOSThread()

View File

@ -120,13 +120,6 @@ func init() {
runtime.LockOSThread()
}
func (u *UserInterface) Run(game Game, options *RunOptions) error {
if options.SingleThread || buildTagSingleThread {
return u.runSingleThread(game, options)
}
return u.runMultiThread(game, options)
}
func (u *UserInterface) init() error {
u.userInterfaceImpl = userInterfaceImpl{
runnableOnUnfocused: true,

View File

@ -740,10 +740,6 @@ func (u *UserInterface) forceUpdateOnMinimumFPSMode() {
}()
}
func (u *UserInterface) Run(game Game, options *RunOptions) error {
return u.runSingleThread(game, options)
}
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
if !options.InitUnfocused && window.Truthy() {
// Do not focus the canvas when the current document is in an iframe.

View File

@ -75,13 +75,6 @@ func (u *UserInterface) init() error {
return nil
}
func (u *UserInterface) Run(game Game, options *RunOptions) error {
if options.SingleThread || buildTagSingleThread {
return u.runSingleThread(game, options)
}
return u.runMultiThread(game, options)
}
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
g, lib, err := newGraphicsDriver(&graphicsDriverCreatorImpl{}, options.GraphicsLibrary)
if err != nil {

View File

@ -69,13 +69,6 @@ func (u *UserInterface) init() error {
return nil
}
func (u *UserInterface) Run(game Game, options *RunOptions) error {
if options.SingleThread || buildTagSingleThread {
return u.runSingleThread(game, options)
}
return u.runMultiThread(game, options)
}
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
g, lib, err := newGraphicsDriver(&graphicsDriverCreatorImpl{}, options.GraphicsLibrary)
if err != nil {