sorta working unsafesvecarray; and then issue #26 is fucking shit up

This commit is contained in:
minjaesong
2019-06-22 04:16:03 +09:00
parent b45caebda0
commit 64bbe6b53b
7 changed files with 283 additions and 78 deletions

View File

@@ -22,7 +22,7 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
private var layerPtr = unsafe.allocateMemory(width * height * BYTES_PER_BLOCK.toLong())
init {
unsafe.setMemory(layerPtr, width * height * BYTES_PER_BLOCK.toLong(), 0) // sometimes does not work?!
unsafe.setMemory(layerPtr, width * height * BYTES_PER_BLOCK.toLong(), 0) // does reliably fill the memory with zeroes
}
/**
@@ -89,12 +89,9 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
}
override fun next(): Byte {
val y = iteratorCount / width
val x = iteratorCount % width
// advance counter
iteratorCount += 1
return unsafe.getByte(layerPtr + 1)
return unsafe.getByte(layerPtr + iteratorCount)
}
}
}