mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/ui: refactoring: integrate Run except for mobiles
This commit is contained in:
parent
563bbda615
commit
3df2ffebd1
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user