Skip to content

Commit

Permalink
Simplify tile consumption logic
Browse files Browse the repository at this point in the history
  • Loading branch information
p-lr committed Jul 3, 2020
1 parent 7c1e6bc commit 3884fbb
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,10 @@ internal class TileCanvasViewModel(private val scope: CoroutineScope, tileSize:
*/
private fun CoroutineScope.consumeTiles(tileChannel: ReceiveChannel<Tile>) = launch {
for (tile in tileChannel) {
if (lastVisible.contains(tile)) {
if (!tilesToRender.contains(tile)) {
tile.setPaint()
tilesToRender.add(tile)
idleDebounced.offer(Unit)
} else {
tile.recycle()
}
if (lastVisible.contains(tile) && !tilesToRender.contains(tile)) {
tile.setPaint()
tilesToRender.add(tile)
idleDebounced.offer(Unit)
renderThrottled()
} else {
tile.recycle()
Expand Down

0 comments on commit 3884fbb

Please sign in to comment.