no memory leak on ImageBuffer rendering

Turns out, <ImageBuffer>.image creates new Image instance which will NEVER be reclaimed (which causes OutOfMemoryError) unless manually destroy()ed.


Former-commit-id: 34840cf63e52e5635ec8acd5fb1bb78923c61063
Former-commit-id: aca4388320fae022a4744f75c1b0f66b544bdafb
This commit is contained in:
Song Minjae
2017-02-25 02:39:02 +09:00
parent d7b49b0f9d
commit 3b7e88b0af
6 changed files with 61 additions and 24 deletions

View File

@@ -49,20 +49,26 @@ class StateGraphicComputerTest : BasicGameState() {
monitor.update(container, delta)
computer.update(container, delta)
val sprite = (computer.getPeripheral("ppu") as PeripheralVideoCard).vram.sprites[0]
val vcard = (computer.getPeripheral("ppu") as PeripheralVideoCard)
val sprite = vcard.vram.sprites[0]
angle += delta / 500.0
sprite.posX = (Math.cos(angle) * 80 + 100).roundInt()
sprite.posY = (Math.sin(angle) * 80 + 100).roundInt()
sprite.pal0 = (sprite.pal0 + 1) % 65
sprite.pal1 = (sprite.pal1 + 1) % 65
sprite.pal2 = (sprite.pal2 + 1) % 65
sprite.pal3 = (sprite.pal3 + 1) % 65
//sprite.pal0 = (sprite.pal0 + 1) % 65
//sprite.pal1 = (sprite.pal1 + 1) % 65
//sprite.pal2 = (sprite.pal2 + 1) % 65
//sprite.pal3 = (sprite.pal3 + 1) % 65
sprite.rotation = (angle * 2 / Math.PI).roundInt() % 4
//vcard.vram.setBackgroundPixel(Random().nextInt(320), Random().nextInt(200), Random().nextInt(64))
//kotlin.repeat(64) {
// vcard.vram.setBackgroundPixel(Random().nextInt(320), Random().nextInt(200), 0)
//}
}
override fun getID() = Terrarum.STATE_ID_TEST_TTY