mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/atlas: bug fix: possible overflowing on 32bit machines
Closes #2728
This commit is contained in:
parent
14c03e9aec
commit
a5af6dc0a9
@ -17,6 +17,7 @@ package atlas
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
"math"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -113,8 +114,10 @@ const baseCountToPutOnSourceBackend = 10
|
|||||||
|
|
||||||
func putImagesOnSourceBackend(graphicsDriver graphicsdriver.Graphics) error {
|
func putImagesOnSourceBackend(graphicsDriver graphicsdriver.Graphics) error {
|
||||||
for i := range imagesToPutOnSourceBackend {
|
for i := range imagesToPutOnSourceBackend {
|
||||||
|
if i.usedAsSourceCount < math.MaxInt {
|
||||||
i.usedAsSourceCount++
|
i.usedAsSourceCount++
|
||||||
if i.usedAsSourceCount >= baseCountToPutOnSourceBackend*(1<<uint(min(i.destinationCount, 31))) {
|
}
|
||||||
|
if int64(i.usedAsSourceCount) >= int64(baseCountToPutOnSourceBackend*(1<<uint(min(i.destinationCount, 31)))) {
|
||||||
if err := i.putOnSourceBackend(graphicsDriver); err != nil {
|
if err := i.putOnSourceBackend(graphicsDriver); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user