diff options
| author | JosJuice <josjuice@gmail.com> | 2021-08-08 12:10:03 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2021-09-21 16:31:55 +0200 |
| commit | 2c564a0b9d654d860dcc2832b2492f8e1b94813b (patch) | |
| tree | 197c0ca4e6a457862df935b65ed3e67b406551ee /Source/Android/app/src/main/java | |
| parent | 6129290d3188f9f38ee045f809ec2cb890b3dcab (diff) | |
Android: Remove mSurface from EmulationState
Diffstat (limited to 'Source/Android/app/src/main/java')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java | 2 | ||||
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java | 30 |
2 files changed, 8 insertions, 24 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index 0ac2463217..5ab4e15993 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -393,6 +393,8 @@ public final class NativeLibrary public static native void SurfaceDestroyed(); + public static native boolean HasSurface(); + /** * Unpauses emulation from a paused state. */ diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java index 7d18c47936..2ea106cb4a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java @@ -173,13 +173,15 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.debug("[EmulationFragment] Surface changed. Resolution: " + width + "x" + height); - mEmulationState.newSurface(holder.getSurface()); + NativeLibrary.SurfaceChanged(holder.getSurface()); + mEmulationState.newSurface(); } @Override public void surfaceDestroyed(@NonNull SurfaceHolder holder) { - mEmulationState.clearSurface(); + Log.debug("[EmulationFragment] Surface destroyed."); + NativeLibrary.SurfaceDestroyed(); } public void stopEmulation() @@ -219,7 +221,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C private final String[] mGamePaths; private State state; - private Surface mSurface; private boolean mRunWhenSurfaceIsValid; private boolean loadPreviousTemporaryState; private final String temporaryStatePath; @@ -304,7 +305,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C } // If the surface is set, run now. Otherwise, wait for it to get set. - if (mSurface != null) + if (NativeLibrary.HasSurface()) { runWithValidSurface(); } @@ -314,31 +315,14 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C } } - // Surface callbacks - public synchronized void newSurface(Surface surface) + public synchronized void newSurface() { - mSurface = surface; if (mRunWhenSurfaceIsValid) { runWithValidSurface(); } } - public synchronized void clearSurface() - { - if (mSurface == null) - { - Log.warning("[EmulationFragment] clearSurface called, but surface already null."); - } - else - { - mSurface = null; - Log.debug("[EmulationFragment] Surface destroyed."); - - NativeLibrary.SurfaceDestroyed(); - } - } - private void runWithValidSurface() { mRunWhenSurfaceIsValid = false; @@ -346,7 +330,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C { Thread emulationThread = new Thread(() -> { - NativeLibrary.SurfaceChanged(mSurface); if (loadPreviousTemporaryState) { Log.debug("[EmulationFragment] Starting emulation thread from previous state."); @@ -363,7 +346,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C } else if (state == State.PAUSED) { - NativeLibrary.SurfaceChanged(mSurface); if (!EmulationActivity.getHasUserPausedEmulation() && !NativeLibrary.IsShowingAlertMessage()) { |
