mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
feat(dual-screen): bottom-screen HUD, Line strip, strip under every bottom tab, Bottom screen HUD settings (#1982)
- In-game stats shows a bottom-screen HUD while no game sends dashboard data: 11 styles, tap to change; it reads the game's frames and the device itself, so it works with the top-screen HUD off. - Line strip: one line like the top HUD's Strip (API + FPS, frame-time graph, 1 / 0.1 / 0.01 % lows, GPU, CPU with temperature, VRAM, RAM, clock); default strip above a game's dashboard; numbers that do not fit are left out by importance. - The same strip under the tabs on every other bottom page during a session. - Bottom screen HUD settings, shown even with the top HUD off: one switch for the whole bottom HUD, strip on every tab, and which numbers the Line strip shows. - The bottom HUD redraws about 10 times a second (was about 3) and reads device stats twice a second. - GPU load, clock and VRAM readers also run while the bottom HUD shows them (BottomHudPresence). - Night style stays dim instead of flickering with the FPS. - Review fixes: slow-frame ring 2048, tab strip redraw without gamescope frames, Proton name per game, Graphs' duration from the kept readings, Fahrenheit in Tiles, Rings and Cores.
This commit is contained in:
1 parent
6a30a9bb4b
commit
e1d241d723
22 files changed
+1393
-92
No files matched your search
@@ -0,0 +1,15 @@
|
||||
package com.droiddeck.launcher.hud
|
||||
|
||||
import android.os.SystemClock
|
||||
|
||||
internal object BottomHudPresence {
|
||||
private const val STALE_MS = 2_500L
|
||||
|
||||
@Volatile private var seenAt = 0L
|
||||
|
||||
fun beat() {
|
||||
seenAt = SystemClock.elapsedRealtime()
|
||||
}
|
||||
|
||||
val showing: Boolean get() = seenAt != 0L && SystemClock.elapsedRealtime() - seenAt < STALE_MS
|
||||
}
|
||||
@@ -19,6 +19,10 @@ internal class FrameStats {
|
||||
private var sessionStartNs = 0L
|
||||
private var sessionFrames = 0L
|
||||
|
||||
private val slowTimes = LongArray(SLOW_FRAMES)
|
||||
private var slowHead = 0
|
||||
private var slowSize = 0
|
||||
|
||||
@Volatile var fps = 0f
|
||||
private set
|
||||
|
||||
@@ -51,6 +55,11 @@ internal class FrameStats {
|
||||
if (lowsSize < LOWS_FRAMES) lowsSize++
|
||||
if (sessionStartNs == 0L) sessionStartNs = timeNs - frametimeNs
|
||||
sessionFrames++
|
||||
if (frametimeNs > SLOW_NS) {
|
||||
slowTimes[slowHead] = timeNs
|
||||
slowHead = (slowHead + 1) % SLOW_FRAMES
|
||||
if (slowSize < SLOW_FRAMES) slowSize++
|
||||
}
|
||||
}
|
||||
count++
|
||||
}
|
||||
@@ -68,6 +77,8 @@ internal class FrameStats {
|
||||
cachedLowsNs = 0L
|
||||
sessionStartNs = 0L
|
||||
sessionFrames = 0L
|
||||
slowHead = 0
|
||||
slowSize = 0
|
||||
fps = 0f
|
||||
count++
|
||||
}
|
||||
@@ -94,6 +105,16 @@ internal class FrameStats {
|
||||
@Synchronized
|
||||
fun sessionSeconds(nowNs: Long): Float = if (sessionStartNs == 0L) 0f else (nowNs - sessionStartNs) / 1e9f
|
||||
|
||||
@Synchronized
|
||||
fun slowFrames(nowNs: Long, windowNs: Long): Int {
|
||||
var n = 0
|
||||
for (i in 0 until slowSize) {
|
||||
if (nowNs - slowTimes[(slowHead - 1 - i + SLOW_FRAMES) % SLOW_FRAMES] > windowNs) break
|
||||
n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
class Lows(val low1Fps: Float, val low01Fps: Float, val low001Fps: Float) {
|
||||
companion object {
|
||||
val EMPTY = Lows(0f, 0f, 0f)
|
||||
@@ -128,6 +149,8 @@ internal class FrameStats {
|
||||
const val FPS_PERIOD_NS = 500_000_000L
|
||||
const val LOWS_FRAMES = 8192
|
||||
private const val PAUSE_NS = 1_000_000_000L
|
||||
const val SLOW_NS = 33_333_334L
|
||||
private const val SLOW_FRAMES = 2048
|
||||
private const val LOWS_RECOMPUTE_NS = 250_000_000L
|
||||
}
|
||||
}
|
||||
@@ -158,6 +181,8 @@ internal class GameFrameFeed(private val file: File, val stats: FrameStats = Fra
|
||||
@Volatile var refreshMilliHz = 0
|
||||
private set
|
||||
|
||||
val live: Boolean get() = fromGamescope
|
||||
|
||||
fun poll(nowNs: Long): Boolean {
|
||||
val compositorAdded = compositorFrames != seenCompositorFrames
|
||||
seenCompositorFrames = compositorFrames
|
||||
|
||||
Reference in new issue
Block a user