internal/atlas: Bug fix: pix was reset at a wrong timing

Closes #1788
This commit is contained in:
Hajime Hoshi 2021-08-25 20:01:30 +09:00
parent d1c764640d
commit 9c321375c9

View File

@ -79,9 +79,8 @@ func (t *temporaryPixels) resetAtFrameEnd() {
// Let the pixels GCed if this is not used for a while.
if t.notFullyUsedTime == maxNotFullyUsedTime && len(t.pixels) > 0 {
t.pixels = nil
t.pos = 0
}
t.pos = 0
}
func max(a, b int) int {
@ -532,8 +531,9 @@ func (i *Image) replacePixels(pix []byte) {
panic(fmt.Sprintf("atlas: len(p) must be %d but %d", l, len(pix)))
}
// Add a padding around the image.
pixb := theTemporaryPixels.alloc(4 * w * h)
// Copy the content.
for j := 0; j < oh; j++ {
copy(pixb[4*((j+paddingSize)*w+paddingSize):], pix[4*j*ow:4*(j+1)*ow])
}