mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
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:
@@ -23,21 +23,21 @@ class StateBlurTest : BasicGameState() {
|
||||
override fun init(gc: GameContainer, sbg: StateBasedGame) {
|
||||
testImage.flushPixelData()
|
||||
|
||||
System.arraycopy(
|
||||
/*System.arraycopy(
|
||||
testImage.texture.textureData, 0,
|
||||
bluredImage.rgba, 0, testImage.texture.textureData.size
|
||||
)
|
||||
kotlin.repeat(3, { fastBoxBlur(bluredImage, 3) })
|
||||
kotlin.repeat(3, { fastBoxBlur(bluredImage, 3) })*/
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
|
||||
Terrarum.appgc.setTitle("${Terrarum.NAME} — F: ${Terrarum.appgc.fps}")
|
||||
|
||||
/*System.arraycopy(
|
||||
System.arraycopy(
|
||||
testImage.texture.textureData, 0,
|
||||
bluredImage.rgba, 0, testImage.texture.textureData.size
|
||||
)*/
|
||||
//fastBoxBlur(testImage, bluredImage, 3)
|
||||
)
|
||||
fastBoxBlur(testImage, bluredImage, 3)
|
||||
//fastBoxBlur(bluredImage, 3)
|
||||
//fastBoxBlur(bluredImage, 3)
|
||||
}
|
||||
@@ -46,11 +46,14 @@ class StateBlurTest : BasicGameState() {
|
||||
|
||||
override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) {
|
||||
g.background = Color(0x404040)
|
||||
g.drawImage(bluredImage.image,
|
||||
val image = bluredImage.image
|
||||
g.drawImage(image,
|
||||
Terrarum.WIDTH.minus(testImage.width).div(2f).floor(),
|
||||
Terrarum.HEIGHT.minus(testImage.height).div(2f).floor()
|
||||
)
|
||||
g.flush()
|
||||
|
||||
image.destroy()
|
||||
}
|
||||
|
||||
private val isLE: Boolean
|
||||
|
||||
Reference in New Issue
Block a user