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
+70 -31
View File
@@ -23,6 +23,7 @@ import (
_ "github.com/ebitengine/hideconsole"
"github.com/hajimehoshi/ebiten/v2/internal/atlas"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/v2/internal/mipmap"
"github.com/hajimehoshi/ebiten/v2/internal/thread"
)
@@ -75,10 +76,12 @@ type UserInterface struct {
err error
errM sync.Mutex
isScreenClearedEveryFrame int32
graphicsLibrary int32
running int32
terminated int32
isScreenClearedEveryFrame atomic.Bool
graphicsLibrary atomic.Int32
running atomic.Bool
terminated atomic.Bool
tick atomic.Int64
inputTime atomic.Int64
whiteImage *Image
@@ -106,10 +109,9 @@ func Get() *UserInterface {
// newUserInterface must be called from the main thread.
func newUserInterface() (*UserInterface, error) {
u := &UserInterface{
isScreenClearedEveryFrame: 1,
graphicsLibrary: int32(GraphicsLibraryUnknown),
}
u := &UserInterface{}
u.isScreenClearedEveryFrame.Store(true)
u.graphicsLibrary.Store(int32(GraphicsLibraryUnknown))
u.whiteImage = u.NewImage(3, 3, atlas.ImageTypeRegular)
pix := make([]byte, 4*u.whiteImage.width*u.whiteImage.height)
@@ -127,6 +129,10 @@ func newUserInterface() (*UserInterface, error) {
}
func (u *UserInterface) readPixels(mipmap *mipmap.Mipmap, pixels []byte, region image.Rectangle) error {
if !u.running.Load() {
panic("ui: ReadPixels cannot be called before the game starts")
}
ok, err := mipmap.ReadPixels(u.graphicsDriver, pixels, region)
if err != nil {
return err
@@ -167,13 +173,17 @@ func (u *UserInterface) dumpImages(dir string) (string, error) {
}
type RunOptions struct {
GraphicsLibrary GraphicsLibrary
InitUnfocused bool
ScreenTransparent bool
SkipTaskbar bool
SingleThread bool
X11ClassName string
X11InstanceName string
GraphicsLibrary GraphicsLibrary
InitUnfocused bool
ScreenTransparent bool
SkipTaskbar bool
SingleThread bool
DisableHiDPI bool
ColorSpace graphicsdriver.ColorSpace
ApplePressAndHoldEnabled bool
X11ClassName string
X11InstanceName string
StrictContextRestoration bool
}
// InitialWindowPosition returns the position for centering the given second width/height pair within the first width/height pair.
@@ -196,41 +206,70 @@ func (u *UserInterface) setError(err error) {
}
func (u *UserInterface) IsScreenClearedEveryFrame() bool {
return atomic.LoadInt32(&u.isScreenClearedEveryFrame) != 0
return u.isScreenClearedEveryFrame.Load()
}
func (u *UserInterface) SetScreenClearedEveryFrame(cleared bool) {
v := int32(0)
if cleared {
v = 1
}
atomic.StoreInt32(&u.isScreenClearedEveryFrame, v)
u.isScreenClearedEveryFrame.Store(cleared)
}
func (u *UserInterface) setGraphicsLibrary(library GraphicsLibrary) {
atomic.StoreInt32(&u.graphicsLibrary, int32(library))
u.graphicsLibrary.Store(int32(library))
}
func (u *UserInterface) GraphicsLibrary() GraphicsLibrary {
return GraphicsLibrary(atomic.LoadInt32(&u.graphicsLibrary))
return GraphicsLibrary(u.graphicsLibrary.Load())
}
func (u *UserInterface) isRunning() bool {
return atomic.LoadInt32(&u.running) != 0 && !u.isTerminated()
return u.running.Load() && !u.isTerminated()
}
func (u *UserInterface) setRunning(running bool) {
if running {
atomic.StoreInt32(&u.running, 1)
} else {
atomic.StoreInt32(&u.running, 0)
}
u.running.Store(running)
}
func (u *UserInterface) isTerminated() bool {
return atomic.LoadInt32(&u.terminated) != 0
return u.terminated.Load()
}
func (u *UserInterface) setTerminated() {
atomic.StoreInt32(&u.terminated, 1)
u.terminated.Store(true)
}
func (u *UserInterface) Tick() int64 {
return u.tick.Load()
}
func (u *UserInterface) incrementTick() {
u.tick.Add(1)
u.inputTime.Store(int64(NewInputTimeFromTick(u.tick.Load())))
}
func (u *UserInterface) InputTime() InputTime {
t := InputTime(u.inputTime.Add(1))
if t.Subtick() == 0 {
panic("ui: too many input events in a tick")
}
return t
}
// inputTimeSubtickBits is the number of bits for a counter in a tick.
// An input time consists of a tick and a counter in a tick.
// This means that an input time will be invalid when 2^20 = 1048576 inputs are handled in a tick,
// but this should unlikely happen.
const inputTimeSubtickBits = 20
type InputTime int64
func NewInputTimeFromTick(tick int64) InputTime {
return InputTime(tick << inputTimeSubtickBits)
}
func (i InputTime) Tick() int64 {
return int64(i >> inputTimeSubtickBits)
}
func (i InputTime) Subtick() int64 {
return int64(i & ((1 << inputTimeSubtickBits) - 1))
}