Compare commits

...
Author SHA1 Message Date
Kurt Himebauch 24af194f45 Preserve FPS history across frame source changes 2026-11-12 21:43:16 -05:00
@@ -66,6 +66,15 @@ internal class FrameStats {
count++
}
@Synchronized
fun addIfNew(frametimeNs: Long, timeNs: Long, rebase: Boolean): Boolean {
if (timeNs <= lastPresentNs) return false
val elapsedNs = if (rebase && lastPresentNs != 0L) timeNs - lastPresentNs else frametimeNs
if (elapsedNs <= 0L) return false
add(elapsedNs, timeNs)
return true
}
@Synchronized
fun reset() {
graph.fill(0f)
@@ -199,11 +208,11 @@ internal class GameFrameFeed(private val file: File, val stats: FrameStats = Fra
}
val n = HudFrames.nativePoll(handle, frametimes, times)
if (n > 0) {
if (!fromGamescope) {
stats.reset()
fromGamescope = true
var rebase = !fromGamescope
fromGamescope = true
for (i in 0 until n) {
if (stats.addIfNew(frametimes[i], times[i], rebase)) rebase = false
}
for (i in 0 until n) stats.add(frametimes[i], times[i])
lastRingFrameNs = times[n - 1]
} else if (lastRingFrameNs != 0L && nowNs - lastRingFrameNs > LIVE_NS) {
fromGamescope = false