mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/graphicscommand: rename RunOnMainThread -> RunOnRenderingThread
This commit is contained in:
parent
b695cb928a
commit
ce3f83958e
@ -225,7 +225,7 @@ func (q *commandQueue) Enqueue(command command) {
|
||||
|
||||
// Flush flushes the command queue.
|
||||
func (q *commandQueue) Flush() (err error) {
|
||||
RunOnMainThread(func() {
|
||||
RunOnRenderingThread(func() {
|
||||
err = q.flush()
|
||||
})
|
||||
return
|
||||
@ -701,7 +701,7 @@ func (c *newShaderCommand) Exec(indexOffset int) error {
|
||||
|
||||
// InitializeGraphicsDriverState initialize the current graphics driver state.
|
||||
func InitializeGraphicsDriverState() (err error) {
|
||||
RunOnMainThread(func() {
|
||||
RunOnRenderingThread(func() {
|
||||
err = theGraphicsDriver.Initialize()
|
||||
})
|
||||
return
|
||||
@ -711,7 +711,7 @@ func InitializeGraphicsDriverState() (err error) {
|
||||
// If the graphics driver doesn't have an API to reset, ResetGraphicsDriverState does nothing.
|
||||
func ResetGraphicsDriverState() (err error) {
|
||||
if r, ok := theGraphicsDriver.(interface{ Reset() error }); ok {
|
||||
RunOnMainThread(func() {
|
||||
RunOnRenderingThread(func() {
|
||||
err = r.Reset()
|
||||
})
|
||||
}
|
||||
@ -721,7 +721,7 @@ func ResetGraphicsDriverState() (err error) {
|
||||
// MaxImageSize returns the maximum size of an image.
|
||||
func MaxImageSize() int {
|
||||
var size int
|
||||
RunOnMainThread(func() {
|
||||
RunOnRenderingThread(func() {
|
||||
size = theGraphicsDriver.MaxImageSize()
|
||||
})
|
||||
return size
|
||||
|
@ -20,13 +20,13 @@ type Thread interface {
|
||||
Call(f func())
|
||||
}
|
||||
|
||||
// SetMainThread must be called from the main thread (i.e, the goroutine where the thread is created).
|
||||
func SetMainThread(thread Thread) {
|
||||
// SetRenderingThread must be called from the rendering thread where e.g. OpenGL works.
|
||||
func SetRenderingThread(thread Thread) {
|
||||
theThread = thread
|
||||
}
|
||||
|
||||
// RunOnMainThread calls f on the main thread, and returns an error if any.
|
||||
func RunOnMainThread(f func()) {
|
||||
// RunOnRenderingThread calls f on the rendering thread, and returns an error if any.
|
||||
func RunOnRenderingThread(f func()) {
|
||||
// The thread is nil when 1) GOOS=js or 2) using golang.org/x/mobile/gl.
|
||||
// When golang.org/x/mobile/gl is used, all the GL functions are called via Context, which already runs on an
|
||||
// appropriate thread.
|
||||
|
@ -27,7 +27,7 @@ func (u *UserInterface) Run(game Game) error {
|
||||
|
||||
// Initialize the main thread first so the thread is available at u.run (#809).
|
||||
u.t = thread.NewOSThread()
|
||||
graphicscommand.SetMainThread(u.t)
|
||||
graphicscommand.SetRenderingThread(u.t)
|
||||
|
||||
ch := make(chan error, 1)
|
||||
go func() {
|
||||
@ -65,11 +65,11 @@ func (u *UserInterface) runOnAnotherThreadFromMainThread(f func() error) error {
|
||||
t := u.t
|
||||
defer func() {
|
||||
u.t = t
|
||||
graphicscommand.SetMainThread(t)
|
||||
graphicscommand.SetRenderingThread(t)
|
||||
}()
|
||||
|
||||
u.t = thread.NewOSThread()
|
||||
graphicscommand.SetMainThread(u.t)
|
||||
graphicscommand.SetRenderingThread(u.t)
|
||||
|
||||
var err error
|
||||
go func() {
|
||||
|
@ -27,7 +27,7 @@ func (u *UserInterface) Run(game Game) error {
|
||||
|
||||
// Initialize the main thread first so the thread is available at u.run (#809).
|
||||
u.t = thread.NewNoopThread()
|
||||
graphicscommand.SetMainThread(u.t)
|
||||
graphicscommand.SetRenderingThread(u.t)
|
||||
|
||||
u.setRunning(true)
|
||||
|
||||
|
@ -286,7 +286,7 @@ func (u *UserInterface) run(game Game, mainloop bool) (err error) {
|
||||
graphics().(*opengl.Graphics).SetGomobileGLContext(ctx)
|
||||
} else {
|
||||
u.t = thread.NewOSThread()
|
||||
graphicscommand.SetMainThread(u.t)
|
||||
graphicscommand.SetRenderingThread(u.t)
|
||||
}
|
||||
|
||||
// If gomobile-build is used, wait for the outside size fixed.
|
||||
|
Loading…
Reference in New Issue
Block a user