mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Rebind the compositor when the Surface changes size
A foldable opening or closing resizes the Surface rather than recreating it. The compositor's swapchain, built for the old size, kept presenting, and the system scaled those buffers onto the new window — on a Fold a 16:9 picture came back stretched to the square panel, the same width and 2.09x the height. Rebinding the window on a size change rebuilds the swapchain at the new size, and the fit mode letterboxes as it should.
This commit is contained in:
1 parent
033db93058
commit
de1bfb6b94
2 files changed
+28
-1
No files matched your search
@@ -226,9 +226,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
applyFrameGen()
|
||||
}
|
||||
|
||||
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {}
|
||||
private var surfaceW = 0
|
||||
private var surfaceH = 0
|
||||
|
||||
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
|
||||
val resized = surfaceW != 0 && (width != surfaceW || height != surfaceH)
|
||||
surfaceW = width
|
||||
surfaceH = height
|
||||
if (resized) {
|
||||
Log.i(TAG, "surface resized to ${width}x$height — rebinding the compositor")
|
||||
CompositorHost.resize(holder.surface)
|
||||
}
|
||||
}
|
||||
|
||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||
surfaceW = 0
|
||||
surfaceH = 0
|
||||
CompositorHost.detach()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user