mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-14 23:17:27 +01:00
Compare commits
28 Commits
0bdbc5e115
...
155c3a41ba
Author | SHA1 | Date | |
---|---|---|---|
|
155c3a41ba | ||
|
4267664b8b | ||
|
2a22260d14 | ||
|
3f91d8cdf1 | ||
|
ec7ef5e6a3 | ||
|
5b8fd9733c | ||
|
9ff93e3063 | ||
|
def82fd5d3 | ||
|
32417353d3 | ||
|
f6fbb3ddea | ||
|
4061742067 | ||
|
b749976a84 | ||
|
0c3b4a2d91 | ||
|
c86874b506 | ||
|
7524f990ba | ||
|
b7015c4354 | ||
|
96984210e1 | ||
|
1cd6a1f10c | ||
|
0eb2b9980d | ||
|
76a170eecf | ||
|
941aec5f51 | ||
|
a6d7cadab7 | ||
|
dc8dfae3bf | ||
|
ffb77757f0 | ||
|
60f0a03749 | ||
|
22339c2510 | ||
|
96e0fd7a50 | ||
|
546c47878d |
6
.github/workflows/pages.yml
vendored
6
.github/workflows/pages.yml
vendored
@ -21,14 +21,14 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
uses: actions/configure-pages@v3
|
uses: actions/configure-pages@v5
|
||||||
- name: Build with Jekyll
|
- name: Build with Jekyll
|
||||||
uses: actions/jekyll-build-pages@v1
|
uses: actions/jekyll-build-pages@v1
|
||||||
with:
|
with:
|
||||||
source: ./.github/workflows/site
|
source: ./.github/workflows/site
|
||||||
destination: ./_site
|
destination: ./_site
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v1
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
environment:
|
environment:
|
||||||
@ -39,4 +39,4 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v2
|
uses: actions/deploy-pages@v4
|
||||||
|
2
.github/workflows/steam.yml
vendored
2
.github/workflows/steam.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Docker build (amd64)
|
- name: Docker build (amd64)
|
||||||
run: |
|
run: |
|
||||||
|
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
go: ['1.19.x', '1.20.x', '1.21.x', '1.22.x']
|
go: ['1.19.x', '1.20.x', '1.21.x', '1.22.x', '1.23.0-rc.1']
|
||||||
name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
|
name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
@ -23,15 +23,15 @@ jobs:
|
|||||||
git config --global core.eol lf
|
git config --global core.eol lf
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Setup JDK
|
- name: Setup JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
4
.github/workflows/vuln.yml
vendored
4
.github/workflows/vuln.yml
vendored
@ -39,10 +39,10 @@ jobs:
|
|||||||
git config --global core.eol lf
|
git config --global core.eol lf
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func init() {
|
|||||||
debugPrintTextImage = ebiten.NewImageFromImage(img)
|
debugPrintTextImage = ebiten.NewImageFromImage(img)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebugPrint draws the string str on the image on left top corner.
|
// DebugPrint draws the string str on the image at (0, 0) position (the upper-left corner in most cases).
|
||||||
//
|
//
|
||||||
// The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement.
|
// The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement.
|
||||||
func DebugPrint(image *ebiten.Image, str string) {
|
func DebugPrint(image *ebiten.Image, str string) {
|
||||||
|
@ -22,6 +22,9 @@ var (
|
|||||||
//go:embed jab.wav
|
//go:embed jab.wav
|
||||||
Jab_wav []byte
|
Jab_wav []byte
|
||||||
|
|
||||||
|
//go:embed jab8.wav
|
||||||
|
Jab8_wav []byte
|
||||||
|
|
||||||
//go:embed jump.ogg
|
//go:embed jump.ogg
|
||||||
Jump_ogg []byte
|
Jump_ogg []byte
|
||||||
|
|
||||||
|
BIN
examples/resources/audio/jab8.wav
Normal file
BIN
examples/resources/audio/jab8.wav
Normal file
Binary file not shown.
@ -3,24 +3,35 @@
|
|||||||
## ebiten.png
|
## ebiten.png
|
||||||
|
|
||||||
```
|
```
|
||||||
http://www.sozai-page.com/02_sozai/b/b04/b04_002/b04_002.html
|
https://web.archive.org/web/20200110174435/http://www.sozai-page.com/02_sozai/b/b04/b04_002/b04_002.html
|
||||||
|
https://web.archive.org/web/20191229033100/http://www.sozai-page.com/rule/rule1.html
|
||||||
|
|
||||||
|
● 商用・個人使用を問わず自由に使用できます。
|
||||||
|
● 画像の内容、画質、状態などにより生じた結果に当方は一切責任を負いません。
|
||||||
|
● 全ての画像は自由に加工・修正できます。
|
||||||
|
ただし、加工により生じた結果に当方は一切責任を負いません。
|
||||||
|
● 加工・修正に関わらず、許可無く画像として再配布・販売することを禁止します。
|
||||||
|
|
||||||
|
これはあくまで「お願い」なのですが、出版・放送等メディア関係の方は使用の際にご連絡いただけると助かります。印刷物やテレビ放送での使用に制限はありませんが、書名、雑誌名、番組名、また発売日・放送日が決まっているようでしたらお知らせいただけないでしょうか。
|
||||||
|
当サイトの画像がどのように利用されたのか、今後の参考にいたします。
|
||||||
```
|
```
|
||||||
|
|
||||||
## fiveyears.jpg
|
## fiveyears.jpg
|
||||||
|
|
||||||
```
|
```
|
||||||
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
||||||
The design is licensed under the Creative Commons 3.0 Attributions license.
|
The design is licensed under the Creative Commons 4.0 Attributions license.
|
||||||
Read this article for more details: https://blog.golang.org/gopher
|
Read this article for more details: https://blog.golang.org/gopher
|
||||||
```
|
```
|
||||||
|
|
||||||
## gophers.jpg
|
## gophers.jpg
|
||||||
|
|
||||||
```
|
```
|
||||||
http://blog.golang.org/go-programming-language-turns-two
|
https://go.dev/blog/2years
|
||||||
|
https://go.dev/copyright
|
||||||
|
|
||||||
Photograph by Chris Nokleberg
|
Photograph by Chris Nokleberg
|
||||||
the Creative Commons Attribution 3.0 License
|
The Creative Commons Attribution 4.0 License
|
||||||
```
|
```
|
||||||
|
|
||||||
## runner.png
|
## runner.png
|
||||||
@ -106,7 +117,7 @@ CC0 1.0
|
|||||||
|
|
||||||
```
|
```
|
||||||
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
||||||
The design is licensed under the Creative Commons 3.0 Attributions license.
|
The design is licensed under the Creative Commons 4.0 Attributions license.
|
||||||
Read this article for more details: https://blog.golang.org/gopher
|
Read this article for more details: https://blog.golang.org/gopher
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -128,7 +139,7 @@ MIT License
|
|||||||
|
|
||||||
```
|
```
|
||||||
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
||||||
The design is licensed under the Creative Commons 3.0 Attributions license.
|
The design is licensed under the Creative Commons 4.0 Attributions license.
|
||||||
Read this article for more details: https://blog.golang.org/gopher
|
Read this article for more details: https://blog.golang.org/gopher
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -136,7 +147,7 @@ Read this article for more details: https://blog.golang.org/gopher
|
|||||||
|
|
||||||
```
|
```
|
||||||
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
||||||
The design is licensed under the Creative Commons 3.0 Attributions license.
|
The design is licensed under the Creative Commons 4.0 Attributions license.
|
||||||
Read this article for more details: https://blog.golang.org/gopher
|
Read this article for more details: https://blog.golang.org/gopher
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -150,7 +161,7 @@ https://corvussg.itch.io/2d-game-backgrounds
|
|||||||
|
|
||||||
```
|
```
|
||||||
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
|
||||||
The design is licensed under the Creative Commons 3.0 Attributions license.
|
The design is licensed under the Creative Commons 4.0 Attributions license.
|
||||||
Read this article for more details: https://blog.golang.org/gopher
|
Read this article for more details: https://blog.golang.org/gopher
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -175,5 +186,5 @@ MIT License
|
|||||||
|
|
||||||
```
|
```
|
||||||
Copyright 2014 Hajime Hoshi
|
Copyright 2014 Hajime Hoshi
|
||||||
the Creative Commons Attribution 3.0 License
|
The Creative Commons Attribution 4.0 License
|
||||||
```
|
```
|
||||||
|
@ -16,6 +16,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
@ -32,6 +34,10 @@ const (
|
|||||||
sampleRate = 48000
|
sampleRate = 48000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
flagBitsPerSample = flag.Int("bits", 16, "bits per sample")
|
||||||
|
)
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
audioContext *audio.Context
|
audioContext *audio.Context
|
||||||
audioPlayer *audio.Player
|
audioPlayer *audio.Player
|
||||||
@ -59,7 +65,14 @@ func NewGame() (*Game, error) {
|
|||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Decode wav-formatted data and retrieve decoded PCM stream.
|
// Decode wav-formatted data and retrieve decoded PCM stream.
|
||||||
d, err := wav.DecodeWithoutResampling(bytes.NewReader(raudio.Jab_wav))
|
var r io.Reader
|
||||||
|
switch *flagBitsPerSample {
|
||||||
|
case 8:
|
||||||
|
r = bytes.NewReader(raudio.Jab8_wav)
|
||||||
|
default:
|
||||||
|
r = bytes.NewReader(raudio.Jab_wav)
|
||||||
|
}
|
||||||
|
d, err := wav.DecodeWithoutResampling(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -99,6 +112,7 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
g, err := NewGame()
|
g, err := NewGame()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -47,7 +47,7 @@ var (
|
|||||||
flagAutoRestore = flag.Bool("autorestore", false, "restore the window automatically")
|
flagAutoRestore = flag.Bool("autorestore", false, "restore the window automatically")
|
||||||
flagInitFocused = flag.Bool("initfocused", true, "whether the window is focused on start")
|
flagInitFocused = flag.Bool("initfocused", true, "whether the window is focused on start")
|
||||||
flagMinWindowSize = flag.String("minwindowsize", "", "minimum window size (e.g., 100x200)")
|
flagMinWindowSize = flag.String("minwindowsize", "", "minimum window size (e.g., 100x200)")
|
||||||
flagMaxWindowSize = flag.String("maxwindowsize", "", "maximium window size (e.g., 1920x1080)")
|
flagMaxWindowSize = flag.String("maxwindowsize", "", "maximum window size (e.g., 1920x1080)")
|
||||||
flagGraphicsLibrary = flag.String("graphicslibrary", "", "graphics library (e.g. opengl)")
|
flagGraphicsLibrary = flag.String("graphicslibrary", "", "graphics library (e.g. opengl)")
|
||||||
flagRunnableOnUnfocused = flag.Bool("runnableonunfocused", true, "whether the app is runnable even on unfocused")
|
flagRunnableOnUnfocused = flag.Bool("runnableonunfocused", true, "whether the app is runnable even on unfocused")
|
||||||
)
|
)
|
||||||
|
@ -106,7 +106,7 @@ func (f *Field) HandleInput(x, y int) (handled bool, err error) {
|
|||||||
f.ch, f.end = Start(x, y)
|
f.ch, f.end = Start(x, y)
|
||||||
// Start returns nil for non-supported envrionments.
|
// Start returns nil for non-supported envrionments.
|
||||||
if f.ch == nil {
|
if f.ch == nil {
|
||||||
return true, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,10 @@ func (t *textInput) init() {
|
|||||||
e.Call("preventDefault")
|
e.Call("preventDefault")
|
||||||
}
|
}
|
||||||
if e.Get("code").String() == "Enter" || e.Get("key").String() == "Enter" {
|
if e.Get("code").String() == "Enter" || e.Get("key").String() == "Enter" {
|
||||||
// Ignore Enter key to avoid ebiten.IsKeyPressed(ebiten.KeyEnter) unexpectedly becomes true, especially for iOS Safari.
|
// Ignore Enter key to avoid ebiten.IsKeyPressed(ebiten.KeyEnter) unexpectedly becomes true.
|
||||||
|
e.Call("preventDefault")
|
||||||
|
ui.Get().UpdateInputFromEvent(e)
|
||||||
|
t.trySend(true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !e.Get("isComposing").Bool() {
|
if !e.Get("isComposing").Bool() {
|
||||||
@ -96,6 +99,11 @@ func (t *textInput) init() {
|
|||||||
}))
|
}))
|
||||||
t.textareaElement.Call("addEventListener", "input", js.FuncOf(func(this js.Value, args []js.Value) any {
|
t.textareaElement.Call("addEventListener", "input", js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||||
e := args[0]
|
e := args[0]
|
||||||
|
// On iOS Safari, `isComposing` can be undefined.
|
||||||
|
if e.Get("isComposing").IsUndefined() {
|
||||||
|
t.trySend(false)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if e.Get("isComposing").Bool() {
|
if e.Get("isComposing").Bool() {
|
||||||
t.trySend(false)
|
t.trySend(false)
|
||||||
return nil
|
return nil
|
||||||
@ -109,8 +117,12 @@ func (t *textInput) init() {
|
|||||||
t.trySend(true)
|
t.trySend(true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Though `isComposing` is false, send the text as being not committed for text completion on mobile browsers.
|
// Though `isComposing` is false, send the text as being not committed for text completion with a virtual keyboard.
|
||||||
t.trySend(false)
|
if ui.IsVirtualKeyboard() {
|
||||||
|
t.trySend(false)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.trySend(true)
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
t.textareaElement.Call("addEventListener", "change", js.FuncOf(func(this js.Value, args []js.Value) any {
|
t.textareaElement.Call("addEventListener", "change", js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||||
@ -172,7 +184,13 @@ func (t *textInput) Start(x, y int) (chan State, func()) {
|
|||||||
s := newSession()
|
s := newSession()
|
||||||
t.session = s
|
t.session = s
|
||||||
}
|
}
|
||||||
return t.session.ch, t.session.end
|
return t.session.ch, func() {
|
||||||
|
if t.session != nil {
|
||||||
|
t.session.end()
|
||||||
|
// Reset the session explictly, or a new session cannot be created above.
|
||||||
|
t.session = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.session != nil {
|
if t.session != nil {
|
||||||
@ -193,6 +211,10 @@ func (t *textInput) trySend(committed bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
textareaValue := t.textareaElement.Get("value").String()
|
textareaValue := t.textareaElement.Get("value").String()
|
||||||
|
if textareaValue == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
start := t.textareaElement.Get("selectionStart").Int()
|
start := t.textareaElement.Get("selectionStart").Int()
|
||||||
end := t.textareaElement.Get("selectionEnd").Int()
|
end := t.textareaElement.Get("selectionEnd").Int()
|
||||||
startInBytes := convertUTF16CountToByteCount(textareaValue, start)
|
startInBytes := convertUTF16CountToByteCount(textareaValue, start)
|
||||||
|
@ -66,10 +66,6 @@ func (g *gameForUI) NewOffscreenImage(width, height int) *ui.Image {
|
|||||||
// An image on an atlas is surrounded by a transparent edge,
|
// An image on an atlas is surrounded by a transparent edge,
|
||||||
// and the shader program unexpectedly picks the pixel on the edges.
|
// and the shader program unexpectedly picks the pixel on the edges.
|
||||||
imageType := atlas.ImageTypeUnmanaged
|
imageType := atlas.ImageTypeUnmanaged
|
||||||
if ui.Get().IsScreenClearedEveryFrame() {
|
|
||||||
// A volatile image is also always isolated.
|
|
||||||
imageType = atlas.ImageTypeVolatile
|
|
||||||
}
|
|
||||||
g.offscreen = newImage(image.Rect(0, 0, width, height), imageType)
|
g.offscreen = newImage(image.Rect(0, 0, width, height), imageType)
|
||||||
return g.offscreen.image
|
return g.offscreen.image
|
||||||
}
|
}
|
||||||
|
16
go.mod
16
go.mod
@ -5,24 +5,24 @@ go 1.19
|
|||||||
require (
|
require (
|
||||||
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895
|
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895
|
||||||
github.com/ebitengine/hideconsole v1.0.0
|
github.com/ebitengine/hideconsole v1.0.0
|
||||||
github.com/ebitengine/oto/v3 v3.3.0-alpha.1
|
github.com/ebitengine/oto/v3 v3.3.0-alpha.2
|
||||||
github.com/ebitengine/purego v0.8.0-alpha.2
|
github.com/ebitengine/purego v0.8.0-alpha.3
|
||||||
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f
|
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f
|
||||||
github.com/go-text/typesetting v0.1.1
|
github.com/go-text/typesetting v0.1.1
|
||||||
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.1
|
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.2
|
||||||
github.com/hajimehoshi/go-mp3 v0.3.4
|
github.com/hajimehoshi/go-mp3 v0.3.4
|
||||||
github.com/jakecoffman/cp v1.2.1
|
github.com/jakecoffman/cp v1.2.1
|
||||||
github.com/jezek/xgb v1.1.1
|
github.com/jezek/xgb v1.1.1
|
||||||
github.com/jfreymuth/oggvorbis v1.0.5
|
github.com/jfreymuth/oggvorbis v1.0.5
|
||||||
github.com/kisielk/errcheck v1.7.0
|
github.com/kisielk/errcheck v1.7.0
|
||||||
golang.org/x/image v0.16.0
|
golang.org/x/image v0.18.0
|
||||||
golang.org/x/sync v0.7.0
|
golang.org/x/sync v0.7.0
|
||||||
golang.org/x/sys v0.20.0
|
golang.org/x/sys v0.21.0
|
||||||
golang.org/x/text v0.15.0
|
golang.org/x/text v0.16.0
|
||||||
golang.org/x/tools v0.21.0
|
golang.org/x/tools v0.22.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/jfreymuth/vorbis v1.0.2 // indirect
|
github.com/jfreymuth/vorbis v1.0.2 // indirect
|
||||||
golang.org/x/mod v0.17.0 // indirect
|
golang.org/x/mod v0.18.0 // indirect
|
||||||
)
|
)
|
||||||
|
32
go.sum
32
go.sum
@ -2,17 +2,17 @@ github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895 h1:48bCqKTuD7Z
|
|||||||
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895/go.mod h1:XZdLv05c5hOZm3fM2NlJ92FyEZjnslcMcNRrhxs8+8M=
|
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895/go.mod h1:XZdLv05c5hOZm3fM2NlJ92FyEZjnslcMcNRrhxs8+8M=
|
||||||
github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE=
|
github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE=
|
||||||
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
|
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
|
||||||
github.com/ebitengine/oto/v3 v3.3.0-alpha.1 h1:J2nBmQwPLKc4+yLObytq1jKNydI96l6EjZfgefiqGbk=
|
github.com/ebitengine/oto/v3 v3.3.0-alpha.2 h1:ex2UbULSPuLt76yyaR2JBXICx83Ph6Oz5ugN7h1Jo/I=
|
||||||
github.com/ebitengine/oto/v3 v3.3.0-alpha.1/go.mod h1:T2/VV0UWG97GEEf4kORMU2nCneYT/YmwSTxPutSVaUg=
|
github.com/ebitengine/oto/v3 v3.3.0-alpha.2/go.mod h1:yYvXK7mgNwsFawY5RsvGI6yhMHtD+0MfaPkDTl9/uv8=
|
||||||
github.com/ebitengine/purego v0.8.0-alpha.2 h1:+Kyr9n4eXAGMzhtWJxfdQ7AzGn0+6ZWihfCCxul3Dso=
|
github.com/ebitengine/purego v0.8.0-alpha.3 h1:qoFlpGuVwJ6J85kuj6Qpyp0DBgxsNYfSY9efidSNFgA=
|
||||||
github.com/ebitengine/purego v0.8.0-alpha.2/go.mod h1:w5fARo4H5UrAgQTz0yqDfZ6bjstTQwUFmO+TN+nHlWE=
|
github.com/ebitengine/purego v0.8.0-alpha.3/go.mod h1:b94LtM1jUWDZPKDyENVhB0WsLdLWFApjbNw5AyxmKyI=
|
||||||
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f h1:ysqRe+lvUiL0dH5XzkH0Bz68bFMPJ4f5Si4L/HD9SGk=
|
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f h1:ysqRe+lvUiL0dH5XzkH0Bz68bFMPJ4f5Si4L/HD9SGk=
|
||||||
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f/go.mod h1:i/ebyRRv/IoHixuZ9bElZnXbmfoUVPGQpdsJ4sVuX38=
|
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f/go.mod h1:i/ebyRRv/IoHixuZ9bElZnXbmfoUVPGQpdsJ4sVuX38=
|
||||||
github.com/go-text/typesetting v0.1.1 h1:bGAesCuo85nXnEN5LmFMVGAGpGkCPtHrZLi//qD7EJo=
|
github.com/go-text/typesetting v0.1.1 h1:bGAesCuo85nXnEN5LmFMVGAGpGkCPtHrZLi//qD7EJo=
|
||||||
github.com/go-text/typesetting v0.1.1/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI=
|
github.com/go-text/typesetting v0.1.1/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI=
|
||||||
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
|
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
|
||||||
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.1 h1:GLoMNCbvXOd39tFkqk9w/MI0xSLJaDzEOOl8mT1ILtI=
|
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.2 h1:3x/UYntkuEcDN8kjSohmR+ddDSFEB8Bsvm/QFug+teA=
|
||||||
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.1/go.mod h1:VVaVK/4HpV1MHWswCl5miFOuLoRVyIplB3qEJxZK2OA=
|
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.2/go.mod h1:VVaVK/4HpV1MHWswCl5miFOuLoRVyIplB3qEJxZK2OA=
|
||||||
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
|
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
|
||||||
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
|
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
|
||||||
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
|
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
|
||||||
@ -31,12 +31,12 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
|
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
|
||||||
golang.org/x/image v0.16.0 h1:9kloLAKhUufZhA12l5fwnx2NZW39/we1UhBesW433jw=
|
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
|
||||||
golang.org/x/image v0.16.0/go.mod h1:ugSZItdV4nOxyqp56HmXwH0Ry0nBCpjnZdpDaIHdoPs=
|
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
|
||||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
@ -54,8 +54,8 @@ golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
@ -64,12 +64,12 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
|
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
|
||||||
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
@ -69,3 +69,9 @@ func DeferredFuncCountForTesting() int {
|
|||||||
defer deferredM.Unlock()
|
defer deferredM.Unlock()
|
||||||
return len(deferred)
|
return len(deferred)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BackendCountForTesting() int {
|
||||||
|
backendsM.Lock()
|
||||||
|
defer backendsM.Unlock()
|
||||||
|
return len(theBackends)
|
||||||
|
}
|
||||||
|
@ -89,7 +89,7 @@ func putImagesOnSourceBackend() {
|
|||||||
if i.usedAsSourceCount < math.MaxInt {
|
if i.usedAsSourceCount < math.MaxInt {
|
||||||
i.usedAsSourceCount++
|
i.usedAsSourceCount++
|
||||||
}
|
}
|
||||||
if int64(i.usedAsSourceCount) >= int64(baseCountToPutOnSourceBackend*(1<<uint(min(i.usedAsDestinationCount, 31)))) {
|
if i.usedAsSourceCount >= baseCountToPutOnSourceBackend*(1<<uint(min(i.usedAsDestinationCount, 31))) {
|
||||||
i.putOnSourceBackend()
|
i.putOnSourceBackend()
|
||||||
i.usedAsSourceCount = 0
|
i.usedAsSourceCount = 0
|
||||||
}
|
}
|
||||||
@ -97,6 +97,8 @@ func putImagesOnSourceBackend() {
|
|||||||
imagesToPutOnSourceBackend.clear()
|
imagesToPutOnSourceBackend.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// backend is a big texture atlas that can have multiple images.
|
||||||
|
// backend is a texture in GPU.
|
||||||
type backend struct {
|
type backend struct {
|
||||||
// image is an atlas on which there might be multiple images.
|
// image is an atlas on which there might be multiple images.
|
||||||
image *graphicscommand.Image
|
image *graphicscommand.Image
|
||||||
@ -109,6 +111,7 @@ type backend struct {
|
|||||||
page *packing.Page
|
page *packing.Page
|
||||||
|
|
||||||
// source reports whether this backend is mainly used a rendering source, but this is not 100%.
|
// source reports whether this backend is mainly used a rendering source, but this is not 100%.
|
||||||
|
//
|
||||||
// If a non-source (destination) image is used as a source many times,
|
// If a non-source (destination) image is used as a source many times,
|
||||||
// the image's backend might be turned into a source backend to optimize draw calls.
|
// the image's backend might be turned into a source backend to optimize draw calls.
|
||||||
source bool
|
source bool
|
||||||
@ -144,8 +147,6 @@ func (b *backend) extendIfNeeded(width, height int) {
|
|||||||
// Assume that the screen image is never extended.
|
// Assume that the screen image is never extended.
|
||||||
newImg := newClearedImage(width, height, false)
|
newImg := newClearedImage(width, height, false)
|
||||||
|
|
||||||
// Use DrawTriangles instead of WritePixels because the image i might be stale and not have its pixels
|
|
||||||
// information.
|
|
||||||
srcs := [graphics.ShaderSrcImageCount]*graphicscommand.Image{b.image}
|
srcs := [graphics.ShaderSrcImageCount]*graphicscommand.Image{b.image}
|
||||||
sw, sh := b.image.InternalSize()
|
sw, sh := b.image.InternalSize()
|
||||||
vs := quadVertices(0, 0, float32(sw), float32(sh), 0, 0, float32(sw), float32(sh), 1, 1, 1, 1)
|
vs := quadVertices(0, 0, float32(sw), float32(sh), 0, 0, float32(sw), float32(sh), 1, 1, 1, 1)
|
||||||
@ -220,12 +221,18 @@ var (
|
|||||||
deferredM sync.Mutex
|
deferredM sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ImageType represents the type of an image.
|
||||||
type ImageType int
|
type ImageType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ImageTypeRegular is a regular image, that can be on a big texture atlas (backend).
|
||||||
ImageTypeRegular ImageType = iota
|
ImageTypeRegular ImageType = iota
|
||||||
|
|
||||||
|
// ImageTypeScreen is a screen image that is not on an atlas.
|
||||||
|
// A screen image is also unmanaged.
|
||||||
ImageTypeScreen
|
ImageTypeScreen
|
||||||
ImageTypeVolatile
|
|
||||||
|
// ImageTypeUnmanaged is an unmanaged image that is not on an atlas.
|
||||||
ImageTypeUnmanaged
|
ImageTypeUnmanaged
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -245,11 +252,13 @@ type Image struct {
|
|||||||
// In the current implementation, if an image is being modified by DrawTriangles, the image is separated from
|
// In the current implementation, if an image is being modified by DrawTriangles, the image is separated from
|
||||||
// a graphicscommand.Image on an atlas by ensureIsolatedFromSource.
|
// a graphicscommand.Image on an atlas by ensureIsolatedFromSource.
|
||||||
//
|
//
|
||||||
|
// The type is int64 instead of int to avoid overflow when comparing the limitation.
|
||||||
|
//
|
||||||
// usedAsSourceCount is increased if the image is used as a rendering source, or set to 0 if the image is
|
// usedAsSourceCount is increased if the image is used as a rendering source, or set to 0 if the image is
|
||||||
// modified.
|
// modified.
|
||||||
//
|
//
|
||||||
// WritePixels doesn't affect this value since WritePixels can be done on images on an atlas.
|
// WritePixels doesn't affect this value since WritePixels can be done on images on an atlas.
|
||||||
usedAsSourceCount int
|
usedAsSourceCount int64
|
||||||
|
|
||||||
// usedAsDestinationCount represents how many times an image is used as a rendering destination at DrawTriangles.
|
// usedAsDestinationCount represents how many times an image is used as a rendering destination at DrawTriangles.
|
||||||
// usedAsDestinationCount affects the calculation when to put the image onto a texture atlas again.
|
// usedAsDestinationCount affects the calculation when to put the image onto a texture atlas again.
|
||||||
@ -810,18 +819,14 @@ func (i *Image) deallocate() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !i.isOnAtlas() {
|
if i.isOnAtlas() {
|
||||||
i.backend.image.Dispose()
|
i.backend.page.Free(i.node)
|
||||||
i.backend.image = nil
|
if !i.backend.page.IsEmpty() {
|
||||||
return
|
// As this part can be reused, this should be cleared explicitly.
|
||||||
}
|
r := i.regionWithPadding()
|
||||||
|
i.backend.clearPixels(r)
|
||||||
i.backend.page.Free(i.node)
|
return
|
||||||
if !i.backend.page.IsEmpty() {
|
}
|
||||||
// As this part can be reused, this should be cleared explicitly.
|
|
||||||
r := i.regionWithPadding()
|
|
||||||
i.backend.clearPixels(r)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i.backend.image.Dispose()
|
i.backend.image.Dispose()
|
||||||
@ -878,20 +883,6 @@ func (i *Image) allocate(forbiddenBackends []*backend, asSource bool) {
|
|||||||
|
|
||||||
runtime.SetFinalizer(i, (*Image).finalize)
|
runtime.SetFinalizer(i, (*Image).finalize)
|
||||||
|
|
||||||
if i.imageType == ImageTypeScreen {
|
|
||||||
if asSource {
|
|
||||||
panic("atlas: a screen image cannot be created as a source")
|
|
||||||
}
|
|
||||||
// A screen image doesn't have a padding.
|
|
||||||
i.backend = &backend{
|
|
||||||
image: newClearedImage(i.width, i.height, true),
|
|
||||||
width: i.width,
|
|
||||||
height: i.height,
|
|
||||||
}
|
|
||||||
theBackends = append(theBackends, i.backend)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
wp := i.width + i.paddingSize()
|
wp := i.width + i.paddingSize()
|
||||||
hp := i.height + i.paddingSize()
|
hp := i.height + i.paddingSize()
|
||||||
|
|
||||||
@ -901,7 +892,7 @@ func (i *Image) allocate(forbiddenBackends []*backend, asSource bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i.backend = &backend{
|
i.backend = &backend{
|
||||||
image: newClearedImage(wp, hp, false),
|
image: newClearedImage(wp, hp, i.imageType == ImageTypeScreen),
|
||||||
width: wp,
|
width: wp,
|
||||||
height: hp,
|
height: hp,
|
||||||
source: asSource && i.imageType == ImageTypeRegular,
|
source: asSource && i.imageType == ImageTypeRegular,
|
||||||
|
@ -177,8 +177,8 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
img2.WritePixels(pix, image.Rect(0, 0, size, size))
|
img2.WritePixels(pix, image.Rect(0, 0, size, size))
|
||||||
|
|
||||||
// Create a volatile image. This should always be on a non-source backend.
|
// Create an unmanaged image. This should always be on a non-source backend.
|
||||||
img3 := atlas.NewImage(size, size, atlas.ImageTypeVolatile)
|
img3 := atlas.NewImage(size, size, atlas.ImageTypeUnmanaged)
|
||||||
defer img3.Deallocate()
|
defer img3.Deallocate()
|
||||||
img3.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
img3.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
||||||
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
@ -296,7 +296,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use img3 as a render source. As img3 is volatile, img3 is never on an atlas.
|
// Use img3 as a render source. As img3 is unmanaged, img3 is never on an atlas.
|
||||||
for i := 0; i < atlas.BaseCountToPutOnSourceBackend*2; i++ {
|
for i := 0; i < atlas.BaseCountToPutOnSourceBackend*2; i++ {
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
@ -688,7 +688,7 @@ func TestImageIsNotReputOnSourceBackendWithoutUsingAsSource(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImageWritePixelsModify(t *testing.T) {
|
func TestImageWritePixelsModify(t *testing.T) {
|
||||||
for _, typ := range []atlas.ImageType{atlas.ImageTypeRegular, atlas.ImageTypeVolatile, atlas.ImageTypeUnmanaged} {
|
for _, typ := range []atlas.ImageType{atlas.ImageTypeRegular, atlas.ImageTypeRegular, atlas.ImageTypeUnmanaged} {
|
||||||
const size = 16
|
const size = 16
|
||||||
img := atlas.NewImage(size, size, typ)
|
img := atlas.NewImage(size, size, typ)
|
||||||
defer img.Deallocate()
|
defer img.Deallocate()
|
||||||
@ -881,4 +881,26 @@ func TestGC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDallocateUnmanagedImageBackends(t *testing.T) {
|
||||||
|
const w, h = 16, 16
|
||||||
|
img0 := atlas.NewImage(w, h, atlas.ImageTypeUnmanaged)
|
||||||
|
img1 := atlas.NewImage(w, h, atlas.ImageTypeUnmanaged)
|
||||||
|
|
||||||
|
// Call DrawTriangles to ensure the images are on backends.
|
||||||
|
vs := quadVertices(w, h, 0, 0, 1)
|
||||||
|
is := graphics.QuadIndices()
|
||||||
|
dr := image.Rect(0, 0, w, h)
|
||||||
|
img0.DrawTriangles([graphics.ShaderSrcImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderSrcImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
|
// Get the difference of the number of backends before and after the images are deallocated.
|
||||||
|
c := atlas.BackendCountForTesting()
|
||||||
|
img0.Deallocate()
|
||||||
|
img1.Deallocate()
|
||||||
|
|
||||||
|
diff := c - atlas.BackendCountForTesting()
|
||||||
|
if got, want := diff, 2; got != want {
|
||||||
|
t.Errorf("got: %d, want: %d", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add tests to extend image on an atlas out of the main loop
|
// TODO: Add tests to extend image on an atlas out of the main loop
|
||||||
|
@ -36,8 +36,8 @@ type playstation5Error struct {
|
|||||||
func newPlaystation5Error(name string, err C.ebitengine_Error) *playstation5Error {
|
func newPlaystation5Error(name string, err C.ebitengine_Error) *playstation5Error {
|
||||||
return &playstation5Error{
|
return &playstation5Error{
|
||||||
name: name,
|
name: name,
|
||||||
code: int(err.code),
|
code: int(err.Code),
|
||||||
message: C.GoString(err.message),
|
message: C.GoString(err.Message),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct ebitengine_Error {
|
typedef struct ebitengine_Error {
|
||||||
const char* message;
|
const char* Message;
|
||||||
int code;
|
int Code;
|
||||||
} ebitengine_Error;
|
} ebitengine_Error;
|
||||||
|
|
||||||
static bool ebitengine_IsErrorNil(ebitengine_Error* err) {
|
static bool ebitengine_IsErrorNil(ebitengine_Error* err) {
|
||||||
return err->message == NULL && err->code == 0;
|
return err->Message == NULL && err->Code == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ebitengine_Error ebitengine_InitializeGraphics(void);
|
ebitengine_Error ebitengine_InitializeGraphics(void);
|
||||||
|
@ -71,7 +71,6 @@ func (m *Mipmap) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Mipmap, verti
|
|||||||
}
|
}
|
||||||
|
|
||||||
level := 0
|
level := 0
|
||||||
// TODO: Do we need to check all the sources' states of being volatile?
|
|
||||||
if !canSkipMipmap && srcs[0] != nil && canUseMipmap(srcs[0].imageType) {
|
if !canSkipMipmap && srcs[0] != nil && canUseMipmap(srcs[0].imageType) {
|
||||||
level = math.MaxInt32
|
level = math.MaxInt32
|
||||||
for i := 0; i < len(indices)/3; i++ {
|
for i := 0; i < len(indices)/3; i++ {
|
||||||
@ -215,7 +214,7 @@ func (m *Mipmap) level(level int) *buffered.Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !canUseMipmap(m.imageType) {
|
if !canUseMipmap(m.imageType) {
|
||||||
panic("mipmap: mipmap images for a volatile or a screen image is not implemented yet")
|
panic("mipmap: mipmap images for a screen image is not implemented yet")
|
||||||
}
|
}
|
||||||
|
|
||||||
if img, ok := m.imgs[level]; ok {
|
if img, ok := m.imgs[level]; ok {
|
||||||
|
@ -178,12 +178,6 @@ func (c *context) newOffscreenImage(w, h int) *Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, ui *UserInterface, forceDraw bool) error {
|
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, ui *UserInterface, forceDraw bool) error {
|
||||||
if (c.offscreen.imageType == atlas.ImageTypeVolatile) != ui.IsScreenClearedEveryFrame() {
|
|
||||||
w, h := c.offscreen.width, c.offscreen.height
|
|
||||||
c.offscreen.Deallocate()
|
|
||||||
c.offscreen = c.newOffscreenImage(w, h)
|
|
||||||
}
|
|
||||||
|
|
||||||
// isOffscreenModified is updated when an offscreen's modifyCallback.
|
// isOffscreenModified is updated when an offscreen's modifyCallback.
|
||||||
c.isOffscreenModified = false
|
c.isOffscreenModified = false
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
@ -86,16 +85,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
|
|||||||
|
|
||||||
if antialias {
|
if antialias {
|
||||||
if i.bigOffscreenBuffer == nil {
|
if i.bigOffscreenBuffer == nil {
|
||||||
var imageType atlas.ImageType
|
i.bigOffscreenBuffer = i.ui.newBigOffscreenImage(i, atlas.ImageTypeUnmanaged)
|
||||||
switch i.imageType {
|
|
||||||
case atlas.ImageTypeRegular, atlas.ImageTypeUnmanaged:
|
|
||||||
imageType = atlas.ImageTypeUnmanaged
|
|
||||||
case atlas.ImageTypeScreen, atlas.ImageTypeVolatile:
|
|
||||||
imageType = atlas.ImageTypeVolatile
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("ui: unexpected image type: %d", imageType))
|
|
||||||
}
|
|
||||||
i.bigOffscreenBuffer = i.ui.newBigOffscreenImage(i, imageType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule, canSkipMipmap)
|
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule, canSkipMipmap)
|
||||||
|
@ -16,6 +16,7 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"strings"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
"unicode"
|
"unicode"
|
||||||
)
|
)
|
||||||
@ -64,6 +65,11 @@ var codeToMouseButton = map[int]MouseButton{
|
|||||||
|
|
||||||
func eventToKeys(e js.Value) (key0, key1 Key, fromKeyProperty bool) {
|
func eventToKeys(e js.Value) (key0, key1 Key, fromKeyProperty bool) {
|
||||||
id := jsCodeToID(e.Get("code"))
|
id := jsCodeToID(e.Get("code"))
|
||||||
|
|
||||||
|
// On mobile browsers, treat enter key as if this is from a `key` property.
|
||||||
|
if IsVirtualKeyboard() && id == KeyEnter {
|
||||||
|
return KeyEnter, -1, true
|
||||||
|
}
|
||||||
if id >= 0 {
|
if id >= 0 {
|
||||||
return id, -1, false
|
return id, -1, false
|
||||||
}
|
}
|
||||||
@ -426,3 +432,15 @@ func (i *InputState) resetForBlur() {
|
|||||||
}
|
}
|
||||||
i.Touches = i.Touches[:0]
|
i.Touches = i.Touches[:0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsVirtualKeyboard() bool {
|
||||||
|
// Detect a virtual keyboard by the user agent.
|
||||||
|
// Note that this is not a correct way to detect a virtual keyboard.
|
||||||
|
// In the future, we should use the `navigator.virtualKeyboard` API.
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/virtualKeyboard
|
||||||
|
ua := js.Global().Get("navigator").Get("userAgent").String()
|
||||||
|
if strings.Contains(ua, "Android") || strings.Contains(ua, "iPhone") || strings.Contains(ua, "iPad") || strings.Contains(ua, "iPod") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -905,13 +905,10 @@ func (u *UserInterface) registerWindowCloseCallback() error {
|
|||||||
|
|
||||||
// registerWindowFramebufferSizeCallback must be called from the main thread.
|
// registerWindowFramebufferSizeCallback must be called from the main thread.
|
||||||
func (u *UserInterface) registerWindowFramebufferSizeCallback() error {
|
func (u *UserInterface) registerWindowFramebufferSizeCallback() error {
|
||||||
if u.defaultFramebufferSizeCallback == nil && runtime.GOOS != "darwin" {
|
if u.defaultFramebufferSizeCallback == nil {
|
||||||
// When the window gets resized (either by manual window resize or a window
|
// When the window gets resized (either by manual window resize or a window
|
||||||
// manager), glfw sends a framebuffer size callback which we need to handle (#1960).
|
// manager), glfw sends a framebuffer size callback which we need to handle (#1960).
|
||||||
// This event is the only way to handle the size change at least on i3 window manager.
|
// This event is the only way to handle the size change at least on i3 window manager.
|
||||||
//
|
|
||||||
// When a decorating state changes, the callback of arguments might be an unexpected value on macOS (#2257)
|
|
||||||
// Then, do not register this callback on macOS.
|
|
||||||
u.defaultFramebufferSizeCallback = func(_ *glfw.Window, w, h int) {
|
u.defaultFramebufferSizeCallback = func(_ *glfw.Window, w, h int) {
|
||||||
f, err := u.isFullscreen()
|
f, err := u.isFullscreen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user