mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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.m.Unlock()
|
||||
|
||||
const n = 4096
|
||||
const n = 2048
|
||||
if _, err := io.CopyN(p, c.players, n); err != nil {
|
||||
c.err = err
|
||||
return
|
||||
|
@ -63,6 +63,7 @@ func drawDebugText(rt *ebiten.Image, str string, ox, oy int, src *ebiten.Image)
|
||||
x := 0
|
||||
y := 0
|
||||
w, _ := debugPrintTextImage.Size()
|
||||
var r image.Rectangle
|
||||
for _, c := range str {
|
||||
const (
|
||||
cw = assets.CharWidth
|
||||
@ -76,7 +77,10 @@ func drawDebugText(rt *ebiten.Image, str string, ox, oy int, src *ebiten.Image)
|
||||
n := w / cw
|
||||
sx := (int(c) % n) * cw
|
||||
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.GeoM.Reset()
|
||||
op.GeoM.Translate(float64(x), float64(y))
|
||||
|
Loading…
Reference in New Issue
Block a user