mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Android: Remove mSurface from EmulationState
This commit is contained in:
parent
6129290d31
commit
2c564a0b9d
@ -393,6 +393,8 @@ public final class NativeLibrary
|
|||||||
|
|
||||||
public static native void SurfaceDestroyed();
|
public static native void SurfaceDestroyed();
|
||||||
|
|
||||||
|
public static native boolean HasSurface();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpauses emulation from a paused state.
|
* Unpauses emulation from a paused state.
|
||||||
*/
|
*/
|
||||||
|
@ -173,13 +173,15 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
|
||||||
{
|
{
|
||||||
Log.debug("[EmulationFragment] Surface changed. Resolution: " + width + "x" + height);
|
Log.debug("[EmulationFragment] Surface changed. Resolution: " + width + "x" + height);
|
||||||
mEmulationState.newSurface(holder.getSurface());
|
NativeLibrary.SurfaceChanged(holder.getSurface());
|
||||||
|
mEmulationState.newSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(@NonNull SurfaceHolder holder)
|
public void surfaceDestroyed(@NonNull SurfaceHolder holder)
|
||||||
{
|
{
|
||||||
mEmulationState.clearSurface();
|
Log.debug("[EmulationFragment] Surface destroyed.");
|
||||||
|
NativeLibrary.SurfaceDestroyed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopEmulation()
|
public void stopEmulation()
|
||||||
@ -219,7 +221,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||||||
|
|
||||||
private final String[] mGamePaths;
|
private final String[] mGamePaths;
|
||||||
private State state;
|
private State state;
|
||||||
private Surface mSurface;
|
|
||||||
private boolean mRunWhenSurfaceIsValid;
|
private boolean mRunWhenSurfaceIsValid;
|
||||||
private boolean loadPreviousTemporaryState;
|
private boolean loadPreviousTemporaryState;
|
||||||
private final String temporaryStatePath;
|
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 the surface is set, run now. Otherwise, wait for it to get set.
|
||||||
if (mSurface != null)
|
if (NativeLibrary.HasSurface())
|
||||||
{
|
{
|
||||||
runWithValidSurface();
|
runWithValidSurface();
|
||||||
}
|
}
|
||||||
@ -314,31 +315,14 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Surface callbacks
|
public synchronized void newSurface()
|
||||||
public synchronized void newSurface(Surface surface)
|
|
||||||
{
|
{
|
||||||
mSurface = surface;
|
|
||||||
if (mRunWhenSurfaceIsValid)
|
if (mRunWhenSurfaceIsValid)
|
||||||
{
|
{
|
||||||
runWithValidSurface();
|
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()
|
private void runWithValidSurface()
|
||||||
{
|
{
|
||||||
mRunWhenSurfaceIsValid = false;
|
mRunWhenSurfaceIsValid = false;
|
||||||
@ -346,7 +330,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||||||
{
|
{
|
||||||
Thread emulationThread = new Thread(() ->
|
Thread emulationThread = new Thread(() ->
|
||||||
{
|
{
|
||||||
NativeLibrary.SurfaceChanged(mSurface);
|
|
||||||
if (loadPreviousTemporaryState)
|
if (loadPreviousTemporaryState)
|
||||||
{
|
{
|
||||||
Log.debug("[EmulationFragment] Starting emulation thread from previous state.");
|
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)
|
else if (state == State.PAUSED)
|
||||||
{
|
{
|
||||||
NativeLibrary.SurfaceChanged(mSurface);
|
|
||||||
if (!EmulationActivity.getHasUserPausedEmulation() &&
|
if (!EmulationActivity.getHasUserPausedEmulation() &&
|
||||||
!NativeLibrary.IsShowingAlertMessage())
|
!NativeLibrary.IsShowingAlertMessage())
|
||||||
{
|
{
|
||||||
|
@ -442,6 +442,13 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_HasSurface(JNIEnv*, jclass)
|
||||||
|
{
|
||||||
|
std::lock_guard guard(s_surface_lock);
|
||||||
|
|
||||||
|
return s_surf ? JNI_TRUE : JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameAspectRatio(JNIEnv*,
|
JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameAspectRatio(JNIEnv*,
|
||||||
jclass)
|
jclass)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user