mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 03:58:55 +01:00
ebitenutil: Speed up to avoid copying by image.Rect
This commit is contained in:
parent
ee7ef75b8b
commit
063153e41d
@ -270,7 +270,7 @@ func (c *Context) loop() {
|
|||||||
c.pingCount--
|
c.pingCount--
|
||||||
c.m.Unlock()
|
c.m.Unlock()
|
||||||
|
|
||||||
const n = 4096
|
const n = 2048
|
||||||
if _, err := io.CopyN(p, c.players, n); err != nil {
|
if _, err := io.CopyN(p, c.players, n); err != nil {
|
||||||
c.err = err
|
c.err = err
|
||||||
return
|
return
|
||||||
|
@ -63,6 +63,7 @@ func drawDebugText(rt *ebiten.Image, str string, ox, oy int, src *ebiten.Image)
|
|||||||
x := 0
|
x := 0
|
||||||
y := 0
|
y := 0
|
||||||
w, _ := debugPrintTextImage.Size()
|
w, _ := debugPrintTextImage.Size()
|
||||||
|
var r image.Rectangle
|
||||||
for _, c := range str {
|
for _, c := range str {
|
||||||
const (
|
const (
|
||||||
cw = assets.CharWidth
|
cw = assets.CharWidth
|
||||||
@ -76,7 +77,10 @@ func drawDebugText(rt *ebiten.Image, str string, ox, oy int, src *ebiten.Image)
|
|||||||
n := w / cw
|
n := w / cw
|
||||||
sx := (int(c) % n) * cw
|
sx := (int(c) % n) * cw
|
||||||
sy := (int(c) / n) * ch
|
sy := (int(c) / n) * ch
|
||||||
r := image.Rect(sx, sy, sx+cw, sy+ch)
|
r.Min.X = sx
|
||||||
|
r.Min.Y = sy
|
||||||
|
r.Max.X = sx + cw
|
||||||
|
r.Max.Y = sy + ch
|
||||||
op.SourceRect = &r
|
op.SourceRect = &r
|
||||||
op.GeoM.Reset()
|
op.GeoM.Reset()
|
||||||
op.GeoM.Translate(float64(x), float64(y))
|
op.GeoM.Translate(float64(x), float64(y))
|
||||||
|
Loading…
Reference in New Issue
Block a user