mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Re-arm frame generation when the presenting window changes
Opening the Steam menu over a fullscreen game and closing it again left the game as a strip in a corner with an engine on. gamescope forwards a fullscreen game's own buffers straight through and hands over its composited output while the menu is up; each is a different window to the compositor, and the engine's ring and history straddled the switch. The compositor already reports every change of presenting window, so the engine is disarmed on it and re-armed against the new one, as it is across a Surface resize.
This commit is contained in:
1 parent
565987edae
commit
83ad9dfa79
3 files changed
+28
-1
No files matched your search
@@ -104,6 +104,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
loading = LoadingState(this)
|
||||
hud = PerfHud(this)
|
||||
hud.onPresentingWindowChanged = {
|
||||
if (FrameGen.engine(this) != FrameGen.ENGINE_OFF) CompositorHost.rearmFrameGen { applyFrameGen() }
|
||||
}
|
||||
// A session that has already drawn is past its milestones; do not cover its picture.
|
||||
if (SessionState.running && SessionState.firstFrameSeen) {
|
||||
loading.visible = false
|
||||
|
||||
@@ -38,8 +38,19 @@ class PerfHud(context: Context) {
|
||||
get() = SessionPrefs.hudEnabled(context)
|
||||
&& !File(Environment.getExternalStorageDirectory(), "Download/steamdeck-no-hud").exists()
|
||||
|
||||
/** Told, on the main thread, when the window presenting frames changes. */
|
||||
var onPresentingWindowChanged: (() -> Unit)? = null
|
||||
private var lastWindow: String? = null
|
||||
|
||||
private val listener = object : WaylandCompositor.GameListener {
|
||||
override fun onGameSurface(window: String?, gpuName: String?) {}
|
||||
override fun onGameSurface(window: String?, gpuName: String?) {
|
||||
// gamescope forwards a fullscreen game's own buffers straight through and its composited
|
||||
// output when the Steam menu is up; each is a different window here. Compositor thread.
|
||||
if (window != null && window != lastWindow) {
|
||||
lastWindow = window
|
||||
handler.post { onPresentingWindowChanged?.invoke() }
|
||||
}
|
||||
}
|
||||
override fun onGameFrame() { frames.incrementAndGet() }
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,19 @@ object CompositorHost {
|
||||
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(rearm, 600)
|
||||
}
|
||||
|
||||
/**
|
||||
* The window the guest presents through has changed (the Steam menu opening or closing over a
|
||||
* fullscreen game swaps gamescope between forwarding the game's own buffers and its composited
|
||||
* output). The engine's ring and history straddle that switch and come back wrong-sized — a
|
||||
* game shown as a strip in a corner — so it is disarmed and re-armed against the new window.
|
||||
*/
|
||||
fun rearmFrameGen(rearm: () -> Unit) {
|
||||
if (!started) return
|
||||
WaylandCompositor.nativeSetFrameGenArmed(false, 0)
|
||||
WaylandCompositor.nativeLog("screen", "presenting window changed: frame generation re-armed")
|
||||
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(rearm, 600)
|
||||
}
|
||||
|
||||
/**
|
||||
* The activity is going away. The compositor keeps running with nothing to present into —
|
||||
* the guest carries on, and its next frames land on the Surface the next activity brings.
|
||||
|
||||
Reference in new issue
Block a user