perf(hud): reduce Strip rendering cost with bitmap graph and logo (#2235)

perf(hud): rasterize Strip graph and logo separately

Replace PR2194's whole-View software layer with a hardware-accelerated
Strip that rasterizes its graph and logo into small reusable bitmaps.
Keep the 66 ms graph invalidation cap, clear stale graph pixels, and
refresh cached logo colours when the theme changes.

Include the comparison method and six sanitized benchmark samples.
With matched Steam navigation, the hybrid averaged 12.2% less UI-thread
CPU and 34.0% lower draw p95 than the PR2194 software path. App-process
CPU averaged 5.9% lower in this run; whole-device and battery savings
are not established. Current-build physical flicker confirmation is
recorded separately from timing validation.

Validation: all 12 DroidDeckHudPanelTest checks passed; comparison APK
built and six alternating device samples completed with matched input
counts, no focus loss, thermal status 0, and no frame metric report drops.
This commit is contained in:
KeegantheVeganat0r authored and GitHub committed 2026-11-07 15:41:46 -05:00
1 parent d9bf6d8a17
commit 11218f0b24
4 files changed
+274 -5

No files matched your search

@@ -2,12 +2,15 @@ package com.droiddeck.launcher.hud
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.RectF
import android.os.Looper
import android.os.SystemClock
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.widget.FrameLayout
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.ui.Themes
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@@ -169,6 +172,40 @@ class DroidDeckHudPanelTest {
after.getPixel(x, graph.top.toInt() + 2), after.getPixel(x, y))
}
@Test fun stripMarkUpdatesAfterThemeChangesWithoutChangingSize() {
val app = RuntimeEnvironment.getApplication()
val oldTheme = SessionPrefs.theme(app)
val parent = FrameLayout(app)
val view = DroidDeckHudView(app)
parent.addView(view)
parent.layout(0, 0, 2400, 1080)
fun render(theme: String): Bitmap {
SessionPrefs.setTheme(app, theme)
view.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudSize" to "strip")))
view.showForTest(SNAPSHOT, "DXVK", 0L)
val unspecified = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
view.measure(unspecified, unspecified)
view.layout(0, 0, view.measuredWidth, view.measuredHeight)
return Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888).also { view.draw(Canvas(it)) }
}
try {
val first = render(Themes.GRAPHITE)
val mark = DroidDeckHudView::class.java.getDeclaredField("headerMark").let {
it.isAccessible = true
RectF(it.get(view) as RectF)
}
val second = render(Themes.ELECTRIC)
val x = (mark.left + mark.width() / 2f).toInt()
val y = mark.centerY().toInt()
assertEquals(first.width, second.width)
assertEquals(first.height, second.height)
assertTrue("the mark orb follows the current theme", first.getPixel(x, y) != second.getPixel(x, y))
assertEquals(View.LAYER_TYPE_NONE, view.layerType)
} finally {
SessionPrefs.setTheme(app, oldTheme)
}
}
@Test fun stripFollowsTheHudScaleInHeightAndKeepsTheFullWidth() {
val app = RuntimeEnvironment.getApplication()
val parent = FrameLayout(app)