mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix(hud): isolate strip rendering in a software layer (#2194)
* fix(hud): skip relayout when size is unchanged and cap graph redraws * fix(hud): limit the redraw and relayout changes to the strip * fix(hud): draw the strip background from a cached bitmap like the panels * fix(hud): drop the strip-only redraw cap and relayout skip * fix(hud): the strip graph redraws at most 15 times a second * fix(hud): isolate strip rendering in a software layer --------- Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
1 parent
066834d17d
commit
a552f1e293
2 files changed
+67
-10
No files matched your search
@@ -139,6 +139,36 @@ class DroidDeckHudPanelTest {
|
||||
assertFalse(line, "BAT" in line)
|
||||
}
|
||||
|
||||
@Test fun stripGraphClearsThePreviousTraceWhenFrameHistoryChanges() {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
val parent = FrameLayout(app)
|
||||
val view = DroidDeckHudView(app)
|
||||
parent.addView(view)
|
||||
parent.layout(0, 0, 2400, 1080)
|
||||
val stats = FrameStats()
|
||||
var now = 1_000_000_000L
|
||||
repeat(300) { now += 25_000_000L; stats.add(25_000_000L, now) }
|
||||
view.setFrameStats(stats)
|
||||
view.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS +
|
||||
("hudSize" to "strip") + ("showFPSGraph" to "1") + ("hudOpacity" to "100")))
|
||||
view.showForTest(SNAPSHOT, "DXVK", now)
|
||||
val unspecified = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
||||
view.measure(unspecified, unspecified)
|
||||
view.layout(0, 0, view.measuredWidth, view.measuredHeight)
|
||||
fun render() = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888).also {
|
||||
view.draw(Canvas(it))
|
||||
}
|
||||
val graph = requireNotNull(view.graphForTest())
|
||||
val x = (graph.left + graph.width() * 0.75f).toInt()
|
||||
val y = graph.centerY().toInt()
|
||||
val before = render()
|
||||
stats.reset()
|
||||
val after = render()
|
||||
assertTrue("the graph initially crosses its midpoint", before.getPixel(x, y) != after.getPixel(x, y))
|
||||
assertEquals("the previous trace is cleared to the strip background",
|
||||
after.getPixel(x, graph.top.toInt() + 2), after.getPixel(x, y))
|
||||
}
|
||||
|
||||
@Test fun stripFollowsTheHudScaleInHeightAndKeepsTheFullWidth() {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
val parent = FrameLayout(app)
|
||||
|
||||
Reference in new issue
Block a user