mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 23:19:57 +01:00
android: Add Display Listener methods for smoother secondary display updates
This commit is contained in:
parent
4ac3cab012
commit
01dc2bb776
@ -20,7 +20,7 @@ import org.citra.citra_emu.features.settings.model.IntSetting
|
|||||||
import org.citra.citra_emu.display.SecondaryDisplayLayout
|
import org.citra.citra_emu.display.SecondaryDisplayLayout
|
||||||
import org.citra.citra_emu.NativeLibrary
|
import org.citra.citra_emu.NativeLibrary
|
||||||
|
|
||||||
class SecondaryDisplay(val context: Context) {
|
class SecondaryDisplay(val context: Context) : DisplayManager.DisplayListener {
|
||||||
private var pres: SecondaryDisplayPresentation? = null
|
private var pres: SecondaryDisplayPresentation? = null
|
||||||
private val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
private val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||||
private val vd: VirtualDisplay
|
private val vd: VirtualDisplay
|
||||||
@ -34,6 +34,7 @@ class SecondaryDisplay(val context: Context) {
|
|||||||
null,
|
null,
|
||||||
DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION
|
DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION
|
||||||
)
|
)
|
||||||
|
displayManager.registerDisplayListener(this, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateSurface() {
|
fun updateSurface() {
|
||||||
@ -74,8 +75,20 @@ class SecondaryDisplay(val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun releaseVD() {
|
fun releaseVD() {
|
||||||
|
displayManager.unregisterDisplayListener(this)
|
||||||
vd.release()
|
vd.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDisplayAdded(displayId: Int) {
|
||||||
|
updateDisplay()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDisplayRemoved(displayId: Int) {
|
||||||
|
updateDisplay()
|
||||||
|
}
|
||||||
|
override fun onDisplayChanged(displayId: Int) {
|
||||||
|
updateDisplay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class SecondaryDisplayPresentation(
|
class SecondaryDisplayPresentation(
|
||||||
context: Context, display: Display, val parent: SecondaryDisplay
|
context: Context, display: Display, val parent: SecondaryDisplay
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user