mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/graphicscommand: rename SetRenderingThread -> SetRenderThread
This commit is contained in:
parent
fa4916d063
commit
e1992347b7
@ -164,7 +164,7 @@ func (q *commandQueue) Enqueue(command command) {
|
|||||||
|
|
||||||
// Flush flushes the command queue.
|
// Flush flushes the command queue.
|
||||||
func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, endFrame bool) (err error) {
|
func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, endFrame bool) (err error) {
|
||||||
runOnRenderingThread(func() {
|
runOnRenderThread(func() {
|
||||||
err = q.flush(graphicsDriver, endFrame)
|
err = q.flush(graphicsDriver, endFrame)
|
||||||
})
|
})
|
||||||
if endFrame {
|
if endFrame {
|
||||||
@ -538,7 +538,7 @@ func (c *isInvalidatedCommand) Exec(graphicsDriver graphicsdriver.Graphics, inde
|
|||||||
|
|
||||||
// InitializeGraphicsDriverState initialize the current graphics driver state.
|
// InitializeGraphicsDriverState initialize the current graphics driver state.
|
||||||
func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) {
|
func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) {
|
||||||
runOnRenderingThread(func() {
|
runOnRenderThread(func() {
|
||||||
err = graphicsDriver.Initialize()
|
err = graphicsDriver.Initialize()
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -548,7 +548,7 @@ func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err
|
|||||||
// If the graphics driver doesn't have an API to reset, ResetGraphicsDriverState does nothing.
|
// If the graphics driver doesn't have an API to reset, ResetGraphicsDriverState does nothing.
|
||||||
func ResetGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) {
|
func ResetGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) {
|
||||||
if r, ok := graphicsDriver.(interface{ Reset() error }); ok {
|
if r, ok := graphicsDriver.(interface{ Reset() error }); ok {
|
||||||
runOnRenderingThread(func() {
|
runOnRenderThread(func() {
|
||||||
err = r.Reset()
|
err = r.Reset()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -558,7 +558,7 @@ func ResetGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error
|
|||||||
// MaxImageSize returns the maximum size of an image.
|
// MaxImageSize returns the maximum size of an image.
|
||||||
func MaxImageSize(graphicsDriver graphicsdriver.Graphics) int {
|
func MaxImageSize(graphicsDriver graphicsdriver.Graphics) int {
|
||||||
var size int
|
var size int
|
||||||
runOnRenderingThread(func() {
|
runOnRenderThread(func() {
|
||||||
size = graphicsDriver.MaxImageSize()
|
size = graphicsDriver.MaxImageSize()
|
||||||
})
|
})
|
||||||
return size
|
return size
|
||||||
|
@ -18,20 +18,20 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/thread"
|
"github.com/hajimehoshi/ebiten/v2/internal/thread"
|
||||||
)
|
)
|
||||||
|
|
||||||
var theThread Thread = thread.NewNoopThread()
|
var theRenderThread Thread = thread.NewNoopThread()
|
||||||
|
|
||||||
type Thread interface {
|
type Thread interface {
|
||||||
Call(f func())
|
Call(f func())
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRenderingThread must be called from the rendering thread where e.g. OpenGL works.
|
// SetRenderThread must be called from the rendering thread where e.g. OpenGL works.
|
||||||
//
|
//
|
||||||
// TODO: Create thread in this package instead of setting it externally.
|
// TODO: Create thread in this package instead of setting it externally.
|
||||||
func SetRenderingThread(thread Thread) {
|
func SetRenderThread(thread Thread) {
|
||||||
theThread = thread
|
theRenderThread = thread
|
||||||
}
|
}
|
||||||
|
|
||||||
// runOnRenderingThread calls f on the rendering thread, and returns an error if any.
|
// runOnRenderThread calls f on the rendering thread, and returns an error if any.
|
||||||
func runOnRenderingThread(f func()) {
|
func runOnRenderThread(f func()) {
|
||||||
theThread.Call(f)
|
theRenderThread.Call(f)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func (u *userInterfaceImpl) Run(game Game, options *RunOptions) error {
|
|||||||
// Initialize the main thread first so the thread is available at u.run (#809).
|
// Initialize the main thread first so the thread is available at u.run (#809).
|
||||||
u.mainThread = thread.NewOSThread()
|
u.mainThread = thread.NewOSThread()
|
||||||
|
|
||||||
graphicscommand.SetRenderingThread(u.mainThread)
|
graphicscommand.SetRenderThread(u.mainThread)
|
||||||
|
|
||||||
u.setRunning(true)
|
u.setRunning(true)
|
||||||
defer u.setRunning(false)
|
defer u.setRunning(false)
|
||||||
@ -70,11 +70,11 @@ func (u *userInterfaceImpl) runOnAnotherThreadFromMainThread(f func()) {
|
|||||||
t := u.mainThread
|
t := u.mainThread
|
||||||
defer func() {
|
defer func() {
|
||||||
u.mainThread = t
|
u.mainThread = t
|
||||||
graphicscommand.SetRenderingThread(t)
|
graphicscommand.SetRenderThread(t)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
u.mainThread = thread.NewOSThread()
|
u.mainThread = thread.NewOSThread()
|
||||||
graphicscommand.SetRenderingThread(u.mainThread)
|
graphicscommand.SetRenderThread(u.mainThread)
|
||||||
|
|
||||||
ctx, cancel := stdcontext.WithCancel(stdcontext.Background())
|
ctx, cancel := stdcontext.WithCancel(stdcontext.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
@ -26,7 +26,7 @@ func (u *userInterfaceImpl) Run(game Game, options *RunOptions) error {
|
|||||||
|
|
||||||
// Initialize the main thread first so the thread is available at u.run (#809).
|
// Initialize the main thread first so the thread is available at u.run (#809).
|
||||||
u.mainThread = thread.NewNoopThread()
|
u.mainThread = thread.NewNoopThread()
|
||||||
graphicscommand.SetRenderingThread(u.mainThread)
|
graphicscommand.SetRenderThread(u.mainThread)
|
||||||
|
|
||||||
u.setRunning(true)
|
u.setRunning(true)
|
||||||
defer u.setRunning(false)
|
defer u.setRunning(false)
|
||||||
|
Loading…
Reference in New Issue
Block a user