updated ebiten version from 2.7.9 to 2.9.9

This commit is contained in:
2026-06-15 19:06:55 +02:00
parent 21edbc41c4
commit db1b625069
405 changed files with 31913 additions and 12595 deletions
+83
View File
@@ -0,0 +1,83 @@
// Copyright 2024 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package debug
import (
"go/build"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
)
var (
ebitengineFileDir string
ebitengineFileDirOnce sync.Once
)
type CallerType int
const (
CallerTypeNone CallerType = iota
CallerTypeRegular
CallerTypeInternal
)
// FirstCaller returns the file and line number of the first caller outside of Ebitengine.
func FirstCaller() (file string, line int, callerType CallerType) {
ebitengineFileDirOnce.Do(func() {
pkg, err := build.Default.Import("github.com/hajimehoshi/ebiten/v2", "", build.FindOnly)
if err != nil {
return
}
ebitengineFileDir = filepath.ToSlash(pkg.Dir)
})
if ebitengineFileDir == "" {
return "", 0, CallerTypeNone
}
// Relying on a caller stacktrace is very fragile, but this is fine as this is only for debugging.
var ebitenPackageReached bool
for i := 0; ; i++ {
_, file, line, ok := runtime.Caller(i)
if !ok {
break
}
// The file should be with a slash, but just in case, convert it.
file = filepath.ToSlash(file)
if !ebitenPackageReached {
if path.Dir(file) == ebitengineFileDir {
ebitenPackageReached = true
}
continue
}
if path.Dir(file) == ebitengineFileDir {
continue
}
if strings.HasPrefix(path.Dir(file), ebitengineFileDir+"/") && !strings.HasPrefix(path.Dir(file), ebitengineFileDir+"/examples/") {
if strings.HasPrefix(path.Dir(file), ebitengineFileDir+"/internal/") {
return file, line, CallerTypeInternal
}
continue
}
return file, line, CallerTypeRegular
}
return "", 0, CallerTypeNone
}
+3 -2
View File
@@ -14,7 +14,8 @@
package debug
type Logger interface {
Logf(format string, args ...any)
// FrameLogger defines the interface for logging debug information for each frame.
type FrameLogger interface {
FrameLogf(format string, args ...any)
Flush()
}
@@ -23,30 +23,32 @@ import (
const IsDebug = true
var theLogger = &logger{}
var theFrameLogger = &frameLogger{}
var flushM sync.Mutex
// Logf calls the current global logger's Logf.
// Logf buffers the arguments and doesn't dump the log immediately.
// FrameLogf calls the current global logger's FrameLogf.
// FrameLogf buffers the arguments and doesn't dump the log immediately.
// You can dump logs by calling SwitchLogger and Flush.
//
// Logf is not concurrent safe.
func Logf(format string, args ...any) {
theLogger.Logf(format, args...)
// FrameLogf is not concurrent safe.
// FrameLogf and SwitchFrameLogger must be called from the same goroutine.
func FrameLogf(format string, args ...any) {
theFrameLogger.FrameLogf(format, args...)
}
// SwitchLogger sets a new logger as the current logger and returns the original global logger.
// SwitchFrameLogger 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.
//
// SwitchLogger and a returned Logger are not concurrent safe.
func SwitchLogger() Logger {
current := theLogger
theLogger = &logger{}
// SwitchFrameLogger and a returned Logger are not concurrent safe.
// FrameLogf and SwitchFrameLogger must be called from the same goroutine.
func SwitchFrameLogger() FrameLogger {
current := theFrameLogger
theFrameLogger = &frameLogger{}
return current
}
type logger struct {
type frameLogger struct {
items []logItem
}
@@ -55,14 +57,14 @@ type logItem struct {
args []any
}
func (l *logger) Logf(format string, args ...any) {
func (l *frameLogger) FrameLogf(format string, args ...any) {
l.items = append(l.items, logItem{
format: format,
args: args,
})
}
func (l *logger) Flush() {
func (l *frameLogger) Flush() {
// Flushing is protected by a mutex not to mix another logger's logs.
flushM.Lock()
defer flushM.Unlock()
@@ -18,17 +18,17 @@ package debug
const IsDebug = false
func Logf(format string, args ...any) {
func FrameLogf(format string, args ...any) {
}
func SwitchLogger() Logger {
return dummyLogger{}
func SwitchFrameLogger() FrameLogger {
return dummyFrameLogger{}
}
type dummyLogger struct{}
type dummyFrameLogger struct{}
func (dummyLogger) Logf(format string, args ...any) {
func (dummyFrameLogger) FrameLogf(format string, args ...any) {
}
func (dummyLogger) Flush() {
func (dummyFrameLogger) Flush() {
}