summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt22
-rw-r--r--src/android/app/src/main/jni/emu_window/emu_window.cpp14
2 files changed, 11 insertions, 25 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
index 3e6c157c7..43d1d2364 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
@@ -15,7 +15,6 @@ import android.net.Uri
15import android.os.Bundle 15import android.os.Bundle
16import android.os.Handler 16import android.os.Handler
17import android.os.Looper 17import android.os.Looper
18import android.util.Rational
19import android.view.* 18import android.view.*
20import android.widget.TextView 19import android.widget.TextView
21import androidx.activity.OnBackPressedCallback 20import androidx.activity.OnBackPressedCallback
@@ -287,6 +286,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
287 286
288 override fun onConfigurationChanged(newConfig: Configuration) { 287 override fun onConfigurationChanged(newConfig: Configuration) {
289 super.onConfigurationChanged(newConfig) 288 super.onConfigurationChanged(newConfig)
289 updateScreenLayout()
290 if (emulationActivity?.isInPictureInPictureMode == true) { 290 if (emulationActivity?.isInPictureInPictureMode == true) {
291 if (binding.drawerLayout.isOpen) { 291 if (binding.drawerLayout.isOpen) {
292 binding.drawerLayout.close() 292 binding.drawerLayout.close()
@@ -394,16 +394,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
394 } 394 }
395 395
396 private fun updateScreenLayout() { 396 private fun updateScreenLayout() {
397 binding.surfaceEmulation.setAspectRatio( 397 binding.surfaceEmulation.setAspectRatio(null)
398 when (IntSetting.RENDERER_ASPECT_RATIO.int) {
399 0 -> Rational(16, 9)
400 1 -> Rational(4, 3)
401 2 -> Rational(21, 9)
402 3 -> Rational(16, 10)
403 4 -> null // Stretch
404 else -> Rational(16, 9)
405 }
406 )
407 emulationActivity?.buildPictureInPictureParams() 398 emulationActivity?.buildPictureInPictureParams()
408 updateOrientation() 399 updateOrientation()
409 } 400 }
@@ -693,7 +684,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
693 private class EmulationState(private val gamePath: String) { 684 private class EmulationState(private val gamePath: String) {
694 private var state: State 685 private var state: State
695 private var surface: Surface? = null 686 private var surface: Surface? = null
696 private var runWhenSurfaceIsValid = false
697 687
698 init { 688 init {
699 // Starting state is stopped. 689 // Starting state is stopped.
@@ -751,8 +741,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
751 // If the surface is set, run now. Otherwise, wait for it to get set. 741 // If the surface is set, run now. Otherwise, wait for it to get set.
752 if (surface != null) { 742 if (surface != null) {
753 runWithValidSurface() 743 runWithValidSurface()
754 } else {
755 runWhenSurfaceIsValid = true
756 } 744 }
757 } 745 }
758 746
@@ -760,7 +748,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
760 @Synchronized 748 @Synchronized
761 fun newSurface(surface: Surface?) { 749 fun newSurface(surface: Surface?) {
762 this.surface = surface 750 this.surface = surface
763 if (runWhenSurfaceIsValid) { 751 if (this.surface != null) {
764 runWithValidSurface() 752 runWithValidSurface()
765 } 753 }
766 } 754 }
@@ -788,10 +776,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
788 } 776 }
789 777
790 private fun runWithValidSurface() { 778 private fun runWithValidSurface() {
791 runWhenSurfaceIsValid = false 779 NativeLibrary.surfaceChanged(surface)
792 when (state) { 780 when (state) {
793 State.STOPPED -> { 781 State.STOPPED -> {
794 NativeLibrary.surfaceChanged(surface)
795 val emulationThread = Thread({ 782 val emulationThread = Thread({
796 Log.debug("[EmulationFragment] Starting emulation thread.") 783 Log.debug("[EmulationFragment] Starting emulation thread.")
797 NativeLibrary.run(gamePath) 784 NativeLibrary.run(gamePath)
@@ -801,7 +788,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
801 788
802 State.PAUSED -> { 789 State.PAUSED -> {
803 Log.debug("[EmulationFragment] Resuming emulation.") 790 Log.debug("[EmulationFragment] Resuming emulation.")
804 NativeLibrary.surfaceChanged(surface)
805 NativeLibrary.unpauseEmulation() 791 NativeLibrary.unpauseEmulation()
806 } 792 }
807 793
diff --git a/src/android/app/src/main/jni/emu_window/emu_window.cpp b/src/android/app/src/main/jni/emu_window/emu_window.cpp
index a890c6604..a7e414b81 100644
--- a/src/android/app/src/main/jni/emu_window/emu_window.cpp
+++ b/src/android/app/src/main/jni/emu_window/emu_window.cpp
@@ -11,6 +11,12 @@
11#include "jni/emu_window/emu_window.h" 11#include "jni/emu_window/emu_window.h"
12 12
13void EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) { 13void EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) {
14 m_window_width = ANativeWindow_getWidth(surface);
15 m_window_height = ANativeWindow_getHeight(surface);
16
17 // Ensures that we emulate with the correct aspect ratio.
18 UpdateCurrentFramebufferLayout(m_window_width, m_window_height);
19
14 window_info.render_surface = reinterpret_cast<void*>(surface); 20 window_info.render_surface = reinterpret_cast<void*>(surface);
15} 21}
16 22
@@ -62,14 +68,8 @@ EmuWindow_Android::EmuWindow_Android(InputCommon::InputSubsystem* input_subsyste
62 return; 68 return;
63 } 69 }
64 70
65 m_window_width = ANativeWindow_getWidth(surface); 71 OnSurfaceChanged(surface);
66 m_window_height = ANativeWindow_getHeight(surface);
67
68 // Ensures that we emulate with the correct aspect ratio.
69 UpdateCurrentFramebufferLayout(m_window_width, m_window_height);
70
71 window_info.type = Core::Frontend::WindowSystemType::Android; 72 window_info.type = Core::Frontend::WindowSystemType::Android;
72 window_info.render_surface = reinterpret_cast<void*>(surface);
73 73
74 m_input_subsystem->Initialize(); 74 m_input_subsystem->Initialize();
75} 75}