mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Render the Steam home tab at 60 FPS (#3647)
Raise the shared Steam home idle animation cadence from 30 to 60 FPS without changing mixed-refresh displays or in-game frame limits.
This commit is contained in:
1 parent
18d735b4c4
commit
f75cb387eb
2 files changed
+40
-14
No files matched your search
@@ -82,17 +82,25 @@ import kotlinx.coroutines.withContext
|
||||
private const val WALL_MIN_GAMES = 4
|
||||
private const val WALL_DISTINCT = 40
|
||||
|
||||
private const val IDLE_FRAME_NS = 30_000_000L
|
||||
internal val IdleFrames = IdleFrameGate()
|
||||
|
||||
internal object IdleFrames {
|
||||
private var shown = 0L
|
||||
internal class IdleFrameGate {
|
||||
private var next = Long.MIN_VALUE
|
||||
private var shown = Long.MIN_VALUE
|
||||
|
||||
fun due(nanos: Long): Boolean {
|
||||
if (nanos == shown) return true
|
||||
if (nanos - shown < IDLE_FRAME_NS) return false
|
||||
// Allow sub-ms vsync jitter; carry the phase on panels whose refresh isn't a multiple of 60.
|
||||
if (nanos + VSYNC_TOLERANCE_NS < next) return false
|
||||
next = if (next == Long.MIN_VALUE || nanos - next >= FRAME_NS) nanos + FRAME_NS else next + FRAME_NS
|
||||
shown = nanos
|
||||
return true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val FRAME_NS = 1_000_000_000L / 60
|
||||
const val VSYNC_TOLERANCE_NS = 500_000L
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -1,19 +1,37 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class IdleFramesTest {
|
||||
@Test
|
||||
fun idleLoopsDrawThirtyFramesASecondAndShareEachOne() {
|
||||
val start = 5_000_000_000L
|
||||
val frame = 8_333_333L
|
||||
val drawn = (0 until 120).count { IdleFrames.due(start + it * frame) }
|
||||
assertEquals(30, drawn)
|
||||
private val start = 5_000_000_000L
|
||||
|
||||
val later = start + 1_000_000_000L
|
||||
assertEquals(listOf(true, true, true), List(3) { IdleFrames.due(later) })
|
||||
assertEquals(listOf(false, false), List(2) { IdleFrames.due(later + frame) })
|
||||
assertEquals(listOf(true, true), List(2) { IdleFrames.due(later + 4 * frame) })
|
||||
@Test
|
||||
fun idleLoopsDrawAtSixtyOrThePanelRateIfLower() {
|
||||
for (hz in listOf(30, 60, 90, 120, 144)) {
|
||||
val gate = IdleFrameGate()
|
||||
val drawn = (0 until 10 * hz).count { gate.due(start + it * 1_000_000_000L / hz) }
|
||||
assertEquals("panel at $hz Hz", 10 * minOf(hz, 60), drawn)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun idleLoopsShareTheDecisionForEachVsync() {
|
||||
val gate = IdleFrameGate()
|
||||
assertEquals(List(3) { true }, List(3) { gate.due(start) })
|
||||
assertEquals(List(2) { false }, List(2) { gate.due(start + 8_333_333) })
|
||||
assertEquals(List(2) { true }, List(2) { gate.due(start + 16_666_666) })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aLongPauseDoesNotCauseCatchUpDraws() {
|
||||
val gate = IdleFrameGate()
|
||||
assertTrue(gate.due(start))
|
||||
val resumed = start + 1_000_000_000L
|
||||
assertTrue(gate.due(resumed))
|
||||
assertFalse(gate.due(resumed + 8_333_333))
|
||||
assertTrue(gate.due(resumed + 16_666_666))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user