mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-03 09:29:38 +01:00
Ported: Update the logic used to start / stop the GL thread
Currently the GL thread is started / stopped when the activity is respectively resumed / paused. However, according to the `GLSurfaceView` documentation, this should be done instead when the activity is started / stopped, so this change updates the start / stop logic for the GL thread to match the documentation.
- m4gr3d
194452bf38
This commit is contained in:
parent
da41965485
commit
deec900b5e
@ -49,7 +49,6 @@ import android.content.pm.ConfigurationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
@ -75,7 +74,6 @@ import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowInsetsAnimation;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
@ -86,9 +84,6 @@ import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.view.OnApplyWindowInsetsListener;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.vending.expansion.downloader.DownloadProgressInfo;
|
||||
@ -919,7 +914,8 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
||||
}
|
||||
return;
|
||||
}
|
||||
mView.onPause();
|
||||
|
||||
mView.onActivityPaused();
|
||||
|
||||
mSensorManager.unregisterListener(this);
|
||||
|
||||
@ -931,6 +927,18 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (!pandemonium_initialized) {
|
||||
if (null != mDownloaderClientStub) {
|
||||
mDownloaderClientStub.disconnect(getActivity());
|
||||
}
|
||||
return;
|
||||
}
|
||||
mView.onActivityStopped();
|
||||
}
|
||||
|
||||
public boolean hasClipboard() {
|
||||
return mClipboard.hasPrimaryClip();
|
||||
}
|
||||
@ -950,6 +958,19 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
||||
mClipboard.setPrimaryClip(clip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!pandemonium_initialized) {
|
||||
if (null != mDownloaderClientStub) {
|
||||
mDownloaderClientStub.connect(getActivity());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
mView.onActivityStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -961,7 +982,7 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
||||
return;
|
||||
}
|
||||
|
||||
mView.onResume();
|
||||
mView.onActivityResumed();
|
||||
|
||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
||||
mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME);
|
||||
|
@ -284,10 +284,11 @@ public class PandemoniumView extends PandemoniumGLSurfaceView {
|
||||
return inputHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
void onActivityStarted() {
|
||||
resumeGLThread();
|
||||
}
|
||||
|
||||
void onActivityResumed() {
|
||||
queueEvent(() -> {
|
||||
// Resume the renderer
|
||||
pandemoniumRenderer.onActivityResumed();
|
||||
@ -295,14 +296,15 @@ public class PandemoniumView extends PandemoniumGLSurfaceView {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
void onActivityPaused() {
|
||||
queueEvent(() -> {
|
||||
PandemoniumLib.focusout();
|
||||
// Pause the renderer
|
||||
pandemoniumRenderer.onActivityPaused();
|
||||
});
|
||||
}
|
||||
|
||||
void onActivityStopped() {
|
||||
pauseGLThread();
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,8 @@ public class PandemoniumGLSurfaceView extends SurfaceView implements SurfaceHold
|
||||
* setRenderer is called:
|
||||
* <ul>
|
||||
* <li>{@link #getRenderMode()}
|
||||
* <li>{@link #onPause()}
|
||||
* <li>{@link #onResume()}
|
||||
* <li>{@link #pauseGLThread()}
|
||||
* <li>{@link #resumeGLThread()}
|
||||
* <li>{@link #queueEvent(Runnable)}
|
||||
* <li>{@link #requestRender()}
|
||||
* <li>{@link #setRenderMode(int)}
|
||||
@ -489,6 +489,7 @@ public class PandemoniumGLSurfaceView extends SurfaceView implements SurfaceHold
|
||||
mGLThread.requestFramebufferSwap();
|
||||
}
|
||||
|
||||
// -- GODOT start --
|
||||
/**
|
||||
* Pause the rendering thread, optionally tearing down the EGL context
|
||||
* depending upon the value of {@link #setPreserveEGLContextOnPause(boolean)}.
|
||||
@ -499,22 +500,23 @@ public class PandemoniumGLSurfaceView extends SurfaceView implements SurfaceHold
|
||||
*
|
||||
* Must not be called before a renderer has been set.
|
||||
*/
|
||||
public void onPause() {
|
||||
protected final void pauseGLThread() {
|
||||
mGLThread.onPause();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumes the rendering thread, re-creating the OpenGL context if necessary. It
|
||||
* is the counterpart to {@link #onPause()}.
|
||||
* is the counterpart to {@link #pauseGLThread()}.
|
||||
*
|
||||
* This method should typically be called in
|
||||
* {@link android.app.Activity#onStart Activity.onStart}.
|
||||
*
|
||||
* Must not be called before a renderer has been set.
|
||||
*/
|
||||
public void onResume() {
|
||||
protected final void resumeGLThread() {
|
||||
mGLThread.onResume();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
/**
|
||||
* Queue a runnable to be run on the GL rendering thread. This can be used
|
||||
|
Loading…
Reference in New Issue
Block a user