mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Revert "internal/debug: rename functions"
This reverts commit 74722298a2
.
Reason: This included an unexpected change in internal/gamepad
This commit is contained in:
parent
74722298a2
commit
fab9482e0e
@ -866,7 +866,7 @@ func SwapBuffers(graphicsDriver graphicsdriver.Graphics) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
if debug.IsDebug {
|
if debug.IsDebug {
|
||||||
debug.FrameLogf("Internal image sizes:\n")
|
debug.Logf("Internal image sizes:\n")
|
||||||
imgs := make([]*graphicscommand.Image, 0, len(theBackends))
|
imgs := make([]*graphicscommand.Image, 0, len(theBackends))
|
||||||
for _, backend := range theBackends {
|
for _, backend := range theBackends {
|
||||||
imgs = append(imgs, backend.image)
|
imgs = append(imgs, backend.image)
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
|
|
||||||
package debug
|
package debug
|
||||||
|
|
||||||
// FrameLogger defines the interface for logging debug information for each frame.
|
type Logger interface {
|
||||||
type FrameLogger interface {
|
Logf(format string, args ...any)
|
||||||
FrameLogf(format string, args ...any)
|
|
||||||
Flush()
|
Flush()
|
||||||
}
|
}
|
||||||
|
@ -23,32 +23,30 @@ import (
|
|||||||
|
|
||||||
const IsDebug = true
|
const IsDebug = true
|
||||||
|
|
||||||
var theFrameLogger = &frameLogger{}
|
var theLogger = &logger{}
|
||||||
|
|
||||||
var flushM sync.Mutex
|
var flushM sync.Mutex
|
||||||
|
|
||||||
// FrameLogf calls the current global logger's FrameLogf.
|
// Logf calls the current global logger's Logf.
|
||||||
// FrameLogf buffers the arguments and doesn't dump the log immediately.
|
// Logf buffers the arguments and doesn't dump the log immediately.
|
||||||
// You can dump logs by calling SwitchLogger and Flush.
|
// You can dump logs by calling SwitchLogger and Flush.
|
||||||
//
|
//
|
||||||
// FrameLogf is not concurrent safe.
|
// Logf is not concurrent safe.
|
||||||
// FrameLogf and SwitchFrameLogger must be called from the same goroutine.
|
func Logf(format string, args ...any) {
|
||||||
func FrameLogf(format string, args ...any) {
|
theLogger.Logf(format, args...)
|
||||||
theFrameLogger.FrameLogf(format, args...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SwitchFrameLogger sets a new logger as the current logger and returns the original global logger.
|
// SwitchLogger sets a new logger as the current logger and returns the original global logger.
|
||||||
// The new global logger and the returned logger have separate statuses, so you can use them for different goroutines.
|
// The new global logger and the returned logger have separate statuses, so you can use them for different goroutines.
|
||||||
//
|
//
|
||||||
// SwitchFrameLogger and a returned Logger are not concurrent safe.
|
// SwitchLogger and a returned Logger are not concurrent safe.
|
||||||
// FrameLogf and SwitchFrameLogger must be called from the same goroutine.
|
func SwitchLogger() Logger {
|
||||||
func SwitchFrameLogger() FrameLogger {
|
current := theLogger
|
||||||
current := theFrameLogger
|
theLogger = &logger{}
|
||||||
theFrameLogger = &frameLogger{}
|
|
||||||
return current
|
return current
|
||||||
}
|
}
|
||||||
|
|
||||||
type frameLogger struct {
|
type logger struct {
|
||||||
items []logItem
|
items []logItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,14 +55,14 @@ type logItem struct {
|
|||||||
args []any
|
args []any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *frameLogger) FrameLogf(format string, args ...any) {
|
func (l *logger) Logf(format string, args ...any) {
|
||||||
l.items = append(l.items, logItem{
|
l.items = append(l.items, logItem{
|
||||||
format: format,
|
format: format,
|
||||||
args: args,
|
args: args,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *frameLogger) Flush() {
|
func (l *logger) Flush() {
|
||||||
// Flushing is protected by a mutex not to mix another logger's logs.
|
// Flushing is protected by a mutex not to mix another logger's logs.
|
||||||
flushM.Lock()
|
flushM.Lock()
|
||||||
defer flushM.Unlock()
|
defer flushM.Unlock()
|
||||||
|
@ -18,17 +18,17 @@ package debug
|
|||||||
|
|
||||||
const IsDebug = false
|
const IsDebug = false
|
||||||
|
|
||||||
func FrameLogf(format string, args ...any) {
|
func Logf(format string, args ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SwitchFrameLogger() FrameLogger {
|
func SwitchLogger() Logger {
|
||||||
return dummyFrameLogger{}
|
return dummyLogger{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type dummyFrameLogger struct{}
|
type dummyLogger struct{}
|
||||||
|
|
||||||
func (dummyFrameLogger) FrameLogf(format string, args ...any) {
|
func (dummyLogger) Logf(format string, args ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dummyFrameLogger) Flush() {
|
func (dummyLogger) Flush() {
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,6 @@ func (g *nativeGamepadsImpl) init(gamepads *gamepads) error {
|
|||||||
if err == unix.ENOENT {
|
if err == unix.ENOENT {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err == unix.EPERM {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("gamepad: Stat failed: %w", err)
|
return fmt.Errorf("gamepad: Stat failed: %w", err)
|
||||||
}
|
}
|
||||||
if stat.Mode&unix.S_IFDIR == 0 {
|
if stat.Mode&unix.S_IFDIR == 0 {
|
||||||
|
@ -197,7 +197,7 @@ func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := debug.SwitchFrameLogger()
|
logger := debug.SwitchLogger()
|
||||||
|
|
||||||
var flushErr error
|
var flushErr error
|
||||||
runOnRenderThread(func() {
|
runOnRenderThread(func() {
|
||||||
@ -223,7 +223,7 @@ func (q *commandQueue) Flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// flush must be called the render thread.
|
// flush must be called the render thread.
|
||||||
func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bool, logger debug.FrameLogger) (err error) {
|
func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bool, logger debug.Logger) (err error) {
|
||||||
// If endFrame is true, Begin/End should be called to ensure the framebuffer is swapped.
|
// If endFrame is true, Begin/End should be called to ensure the framebuffer is swapped.
|
||||||
if len(q.commands) == 0 && !endFrame {
|
if len(q.commands) == 0 && !endFrame {
|
||||||
return nil
|
return nil
|
||||||
@ -231,7 +231,7 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
|||||||
|
|
||||||
es := q.indices
|
es := q.indices
|
||||||
vs := q.vertices
|
vs := q.vertices
|
||||||
logger.FrameLogf("Graphics commands:\n")
|
logger.Logf("Graphics commands:\n")
|
||||||
|
|
||||||
if err := graphicsDriver.Begin(); err != nil {
|
if err := graphicsDriver.Begin(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -294,7 +294,7 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
|||||||
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
|
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.FrameLogf(" %s\n", c)
|
logger.Logf(" %s\n", c)
|
||||||
// TODO: indexOffset should be reset if the command type is different
|
// TODO: indexOffset should be reset if the command type is different
|
||||||
// from the previous one. This fix is needed when another drawing command is
|
// from the previous one. This fix is needed when another drawing command is
|
||||||
// introduced than drawTrianglesCommand.
|
// introduced than drawTrianglesCommand.
|
||||||
|
@ -234,6 +234,6 @@ func LogImagesInfo(images []*Image) {
|
|||||||
if i.screen {
|
if i.screen {
|
||||||
screen = " (screen)"
|
screen = " (screen)"
|
||||||
}
|
}
|
||||||
debug.FrameLogf(" %d: (%d, %d)%s\n", i.id, w, h, screen)
|
debug.Logf(" %d: (%d, %d)%s\n", i.id, w, h, screen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.FrameLogf("----\n")
|
debug.Logf("----\n")
|
||||||
|
|
||||||
if err := atlas.BeginFrame(graphicsDriver); err != nil {
|
if err := atlas.BeginFrame(graphicsDriver); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -133,7 +133,7 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
|
|||||||
updateCount = 1
|
updateCount = 1
|
||||||
c.updateCalled = true
|
c.updateCalled = true
|
||||||
}
|
}
|
||||||
debug.FrameLogf("Update count per frame: %d\n", updateCount)
|
debug.Logf("Update count per frame: %d\n", updateCount)
|
||||||
|
|
||||||
// Update the game.
|
// Update the game.
|
||||||
for i := 0; i < updateCount; i++ {
|
for i := 0; i < updateCount; i++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user