fix(hud): skip relayout when size is unchanged and cap graph redraws

This commit is contained in:
Kurt Himebauch committed 2026-11-06 16:25:29 -05:00
1 parent 542bbf89c3
commit dc309187fd
1 file changed
+11 -2
@@ -274,9 +274,15 @@ class DroidDeckHudView(context: Context) : View(context) {
seenFpsUpdates = updates seenFpsUpdates = updates
periodDone.trySend(Unit) periodDone.trySend(Unit)
} }
if (graphRect != null) invalidate() if (graphRect == null) return
val now = SystemClock.uptimeMillis()
if (now - lastGraphDrawMs < GRAPH_REDRAW_MS) return
lastGraphDrawMs = now
invalidate()
} }
private var lastGraphDrawMs = 0L
private fun cycleSize() { private fun cycleSize() {
size = size.next() size = size.next()
onSizeCycledListener?.accept(size.token) onSizeCycledListener?.accept(size.token)
@@ -423,8 +429,10 @@ class DroidDeckHudView(context: Context) : View(context) {
) )
private fun rebuildAndInvalidate() { private fun rebuildAndInvalidate() {
val wasStrip = stripRect != null
val oldW = contentW; val oldH = contentH
rebuild() rebuild()
requestLayout() if (oldW != contentW || oldH != contentH || wasStrip != (stripRect != null)) requestLayout()
invalidate() invalidate()
} }
@@ -1499,6 +1507,7 @@ class DroidDeckHudView(context: Context) : View(context) {
const val TAB_PAD_X_SP = 7f const val TAB_PAD_X_SP = 7f
const val TAB_PAD_Y_SP = 5.5f const val TAB_PAD_Y_SP = 5.5f
const val REFRESH_MS = 500L const val REFRESH_MS = 500L
const val GRAPH_REDRAW_MS = 33L
private const val HUE_IDLE_MS = 500L private const val HUE_IDLE_MS = 500L
const val MIN_SCALE = 0.5f const val MIN_SCALE = 0.5f
const val MAX_SCALE = 2f const val MAX_SCALE = 2f