summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liamwhite2023-11-06 11:09:59 -0500
committerGravatar GitHub2023-11-06 11:09:59 -0500
commitca1dd1862b89957b3c521904919aa7231ab8de5d (patch)
tree81d63ae71788114917f3dd7412c5c6003717e4de
parentMerge pull request #11974 from t895/ci-fix-again (diff)
parentandroid: Simplify FPS counter padding (diff)
downloadyuzu-ca1dd1862b89957b3c521904919aa7231ab8de5d.tar.gz
yuzu-ca1dd1862b89957b3c521904919aa7231ab8de5d.tar.xz
yuzu-ca1dd1862b89957b3c521904919aa7231ab8de5d.zip
Merge pull request #11972 from t895/fps-counter-adjustments
android: FPS counter adjustments
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt29
-rw-r--r--src/android/app/src/main/jni/native.cpp9
-rw-r--r--src/android/app/src/main/jni/native.h3
-rw-r--r--src/android/app/src/main/res/layout/fragment_emulation.xml8
4 files changed, 11 insertions, 38 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 c456c0592..c32fa0d7e 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
@@ -10,7 +10,6 @@ import android.content.DialogInterface
10import android.content.SharedPreferences 10import android.content.SharedPreferences
11import android.content.pm.ActivityInfo 11import android.content.pm.ActivityInfo
12import android.content.res.Configuration 12import android.content.res.Configuration
13import android.graphics.Color
14import android.net.Uri 13import android.net.Uri
15import android.os.Bundle 14import android.os.Bundle
16import android.os.Handler 15import android.os.Handler
@@ -155,7 +154,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
155 } 154 }
156 155
157 binding.surfaceEmulation.holder.addCallback(this) 156 binding.surfaceEmulation.holder.addCallback(this)
158 binding.showFpsText.setTextColor(Color.YELLOW)
159 binding.doneControlConfig.setOnClickListener { stopConfiguringControls() } 157 binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
160 158
161 binding.drawerLayout.addDrawerListener(object : DrawerListener { 159 binding.drawerLayout.addDrawerListener(object : DrawerListener {
@@ -414,12 +412,12 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
414 val FRAMETIME = 2 412 val FRAMETIME = 2
415 val SPEED = 3 413 val SPEED = 3
416 perfStatsUpdater = { 414 perfStatsUpdater = {
417 if (emulationViewModel.emulationStarted.value == true) { 415 if (emulationViewModel.emulationStarted.value) {
418 val perfStats = NativeLibrary.getPerfStats() 416 val perfStats = NativeLibrary.getPerfStats()
419 if (perfStats[FPS] > 0 && _binding != null) { 417 if (_binding != null) {
420 binding.showFpsText.text = String.format("FPS: %.1f", perfStats[FPS]) 418 binding.showFpsText.text = String.format("FPS: %.1f", perfStats[FPS])
421 } 419 }
422 perfStatsUpdateHandler.postDelayed(perfStatsUpdater!!, 100) 420 perfStatsUpdateHandler.postDelayed(perfStatsUpdater!!, 800)
423 } 421 }
424 } 422 }
425 perfStatsUpdateHandler.post(perfStatsUpdater!!) 423 perfStatsUpdateHandler.post(perfStatsUpdater!!)
@@ -464,7 +462,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
464 if (it.orientation == FoldingFeature.Orientation.HORIZONTAL) { 462 if (it.orientation == FoldingFeature.Orientation.HORIZONTAL) {
465 // Restrict emulation and overlays to the top of the screen 463 // Restrict emulation and overlays to the top of the screen
466 binding.emulationContainer.layoutParams.height = it.bounds.top 464 binding.emulationContainer.layoutParams.height = it.bounds.top
467 binding.overlayContainer.layoutParams.height = it.bounds.top
468 // Restrict input and menu drawer to the bottom of the screen 465 // Restrict input and menu drawer to the bottom of the screen
469 binding.inputContainer.layoutParams.height = it.bounds.bottom 466 binding.inputContainer.layoutParams.height = it.bounds.bottom
470 binding.inGameMenu.layoutParams.height = it.bounds.bottom 467 binding.inGameMenu.layoutParams.height = it.bounds.bottom
@@ -478,7 +475,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
478 if (!isFolding) { 475 if (!isFolding) {
479 binding.emulationContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT 476 binding.emulationContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
480 binding.inputContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT 477 binding.inputContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
481 binding.overlayContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
482 binding.inGameMenu.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT 478 binding.inGameMenu.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
483 isInFoldableLayout = false 479 isInFoldableLayout = false
484 updateOrientation() 480 updateOrientation()
@@ -486,7 +482,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
486 } 482 }
487 binding.emulationContainer.requestLayout() 483 binding.emulationContainer.requestLayout()
488 binding.inputContainer.requestLayout() 484 binding.inputContainer.requestLayout()
489 binding.overlayContainer.requestLayout()
490 binding.inGameMenu.requestLayout() 485 binding.inGameMenu.requestLayout()
491 } 486 }
492 487
@@ -712,24 +707,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
712 } 707 }
713 708
714 v.setPadding(left, cutInsets.top, right, 0) 709 v.setPadding(left, cutInsets.top, right, 0)
715
716 // Ensure FPS text doesn't get cut off by rounded display corners
717 val sidePadding = resources.getDimensionPixelSize(R.dimen.spacing_xtralarge)
718 if (cutInsets.left == 0) {
719 binding.showFpsText.setPadding(
720 sidePadding,
721 cutInsets.top,
722 cutInsets.right,
723 cutInsets.bottom
724 )
725 } else {
726 binding.showFpsText.setPadding(
727 cutInsets.left,
728 cutInsets.top,
729 cutInsets.right,
730 cutInsets.bottom
731 )
732 }
733 windowInsets 710 windowInsets
734 } 711 }
735 } 712 }
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index 46438906e..1484cc224 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -199,8 +199,8 @@ bool EmulationSession::IsPaused() const {
199 return m_is_running && m_is_paused; 199 return m_is_running && m_is_paused;
200} 200}
201 201
202const Core::PerfStatsResults& EmulationSession::PerfStats() const { 202const Core::PerfStatsResults& EmulationSession::PerfStats() {
203 std::scoped_lock m_perf_stats_lock(m_perf_stats_mutex); 203 m_perf_stats = m_system.GetAndResetPerfStats();
204 return m_perf_stats; 204 return m_perf_stats;
205} 205}
206 206
@@ -383,11 +383,6 @@ void EmulationSession::RunEmulation() {
383 break; 383 break;
384 } 384 }
385 } 385 }
386 {
387 // Refresh performance stats.
388 std::scoped_lock m_perf_stats_lock(m_perf_stats_mutex);
389 m_perf_stats = m_system.GetAndResetPerfStats();
390 }
391 } 386 }
392} 387}
393 388
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h
index 3b9596459..6b02c44b5 100644
--- a/src/android/app/src/main/jni/native.h
+++ b/src/android/app/src/main/jni/native.h
@@ -41,7 +41,7 @@ public:
41 void RunEmulation(); 41 void RunEmulation();
42 void ShutdownEmulation(); 42 void ShutdownEmulation();
43 43
44 const Core::PerfStatsResults& PerfStats() const; 44 const Core::PerfStatsResults& PerfStats();
45 void ConfigureFilesystemProvider(const std::string& filepath); 45 void ConfigureFilesystemProvider(const std::string& filepath);
46 void InitializeSystem(bool reload); 46 void InitializeSystem(bool reload);
47 Core::SystemResultStatus InitializeEmulation(const std::string& filepath); 47 Core::SystemResultStatus InitializeEmulation(const std::string& filepath);
@@ -80,6 +80,5 @@ private:
80 80
81 // Synchronization 81 // Synchronization
82 std::condition_variable_any m_cv; 82 std::condition_variable_any m_cv;
83 mutable std::mutex m_perf_stats_mutex;
84 mutable std::mutex m_mutex; 83 mutable std::mutex m_mutex;
85}; 84};
diff --git a/src/android/app/src/main/res/layout/fragment_emulation.xml b/src/android/app/src/main/res/layout/fragment_emulation.xml
index 750ce094a..cd6360b45 100644
--- a/src/android/app/src/main/res/layout/fragment_emulation.xml
+++ b/src/android/app/src/main/res/layout/fragment_emulation.xml
@@ -134,16 +134,18 @@
134 <FrameLayout 134 <FrameLayout
135 android:id="@+id/overlay_container" 135 android:id="@+id/overlay_container"
136 android:layout_width="match_parent" 136 android:layout_width="match_parent"
137 android:layout_height="match_parent"> 137 android:layout_height="match_parent"
138 android:fitsSystemWindows="true">
138 139
139 <TextView 140 <com.google.android.material.textview.MaterialTextView
140 android:id="@+id/show_fps_text" 141 android:id="@+id/show_fps_text"
142 style="@style/TextAppearance.Material3.BodyMedium"
141 android:layout_width="wrap_content" 143 android:layout_width="wrap_content"
142 android:layout_height="wrap_content" 144 android:layout_height="wrap_content"
143 android:layout_gravity="left" 145 android:layout_gravity="left"
144 android:clickable="false" 146 android:clickable="false"
145 android:focusable="false" 147 android:focusable="false"
146 android:shadowColor="@android:color/black" 148 android:paddingHorizontal="20dp"
147 android:textColor="@android:color/white" 149 android:textColor="@android:color/white"
148 android:textSize="12sp" 150 android:textSize="12sp"
149 tools:ignore="RtlHardcoded" /> 151 tools:ignore="RtlHardcoded" />