mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: stop switching between display modes with the same refresh rate (S26 lag and heat since 0.6.7) (#2192)
fix: stop switching between display modes with the same refresh rate
This commit is contained in:
1 parent
542bbf89c3
commit
250f80fbb5
2 files changed
+28
-1
No files matched your search
@@ -21,7 +21,7 @@ object PerfMode {
|
||||
val cur = display.mode
|
||||
val cap = minOf(peakRefreshCap(a), refreshLimit.takeIf { it > 0 }?.toFloat() ?: Float.POSITIVE_INFINITY)
|
||||
val best = selectMode(display.supportedModes, cur, fpsLimit, cap)
|
||||
if (best != null && a.window.attributes.preferredDisplayModeId != best.modeId) {
|
||||
if (best != null && needsChange(display.supportedModes, a.window.attributes.preferredDisplayModeId, best)) {
|
||||
a.window.attributes = a.window.attributes.apply { preferredDisplayModeId = best.modeId }
|
||||
"display ${cur.refreshRate.toInt()} → ${best.refreshRate.toInt()} Hz (mode ${best.modeId})"
|
||||
} else "display ${cur.refreshRate.toInt()} Hz"
|
||||
@@ -64,6 +64,11 @@ object PerfMode {
|
||||
?: sameSize.minByOrNull { it.refreshRate }
|
||||
}
|
||||
|
||||
internal fun needsChange(modes: Array<Display.Mode>, preferredId: Int, best: Display.Mode): Boolean {
|
||||
val preferred = modes.firstOrNull { preferredId != 0 && it.modeId == preferredId } ?: return true
|
||||
return Math.abs(preferred.refreshRate - best.refreshRate) > 0.5f
|
||||
}
|
||||
|
||||
fun cadenceFits(hz: Float, fpsLimit: Int): Boolean {
|
||||
if (fpsLimit <= 0) return true
|
||||
val ratio = hz / fpsLimit
|
||||
|
||||
Reference in new issue
Block a user