mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-18 07:17:18 +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;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
@ -75,7 +74,6 @@ import android.view.Window;
|
|||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowInsetsAnimation;
|
import android.view.WindowInsetsAnimation;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
@ -86,9 +84,6 @@ import androidx.annotation.Keep;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StringRes;
|
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 androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.google.android.vending.expansion.downloader.DownloadProgressInfo;
|
import com.google.android.vending.expansion.downloader.DownloadProgressInfo;
|
||||||
@ -919,7 +914,8 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mView.onPause();
|
|
||||||
|
mView.onActivityPaused();
|
||||||
|
|
||||||
mSensorManager.unregisterListener(this);
|
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() {
|
public boolean hasClipboard() {
|
||||||
return mClipboard.hasPrimaryClip();
|
return mClipboard.hasPrimaryClip();
|
||||||
}
|
}
|
||||||
@ -950,6 +958,19 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
|||||||
mClipboard.setPrimaryClip(clip);
|
mClipboard.setPrimaryClip(clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (!pandemonium_initialized) {
|
||||||
|
if (null != mDownloaderClientStub) {
|
||||||
|
mDownloaderClientStub.connect(getActivity());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mView.onActivityStarted();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -961,7 +982,7 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mView.onResume();
|
mView.onActivityResumed();
|
||||||
|
|
||||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
||||||
mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME);
|
mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
@ -284,10 +284,11 @@ public class PandemoniumView extends PandemoniumGLSurfaceView {
|
|||||||
return inputHandler;
|
return inputHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
void onActivityStarted() {
|
||||||
public void onResume() {
|
resumeGLThread();
|
||||||
super.onResume();
|
}
|
||||||
|
|
||||||
|
void onActivityResumed() {
|
||||||
queueEvent(() -> {
|
queueEvent(() -> {
|
||||||
// Resume the renderer
|
// Resume the renderer
|
||||||
pandemoniumRenderer.onActivityResumed();
|
pandemoniumRenderer.onActivityResumed();
|
||||||
@ -295,14 +296,15 @@ public class PandemoniumView extends PandemoniumGLSurfaceView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
void onActivityPaused() {
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
queueEvent(() -> {
|
queueEvent(() -> {
|
||||||
PandemoniumLib.focusout();
|
PandemoniumLib.focusout();
|
||||||
// Pause the renderer
|
// Pause the renderer
|
||||||
pandemoniumRenderer.onActivityPaused();
|
pandemoniumRenderer.onActivityPaused();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onActivityStopped() {
|
||||||
|
pauseGLThread();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,8 +250,8 @@ public class PandemoniumGLSurfaceView extends SurfaceView implements SurfaceHold
|
|||||||
* setRenderer is called:
|
* setRenderer is called:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link #getRenderMode()}
|
* <li>{@link #getRenderMode()}
|
||||||
* <li>{@link #onPause()}
|
* <li>{@link #pauseGLThread()}
|
||||||
* <li>{@link #onResume()}
|
* <li>{@link #resumeGLThread()}
|
||||||
* <li>{@link #queueEvent(Runnable)}
|
* <li>{@link #queueEvent(Runnable)}
|
||||||
* <li>{@link #requestRender()}
|
* <li>{@link #requestRender()}
|
||||||
* <li>{@link #setRenderMode(int)}
|
* <li>{@link #setRenderMode(int)}
|
||||||
@ -489,6 +489,7 @@ public class PandemoniumGLSurfaceView extends SurfaceView implements SurfaceHold
|
|||||||
mGLThread.requestFramebufferSwap();
|
mGLThread.requestFramebufferSwap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- GODOT start --
|
||||||
/**
|
/**
|
||||||
* Pause the rendering thread, optionally tearing down the EGL context
|
* Pause the rendering thread, optionally tearing down the EGL context
|
||||||
* depending upon the value of {@link #setPreserveEGLContextOnPause(boolean)}.
|
* 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.
|
* Must not be called before a renderer has been set.
|
||||||
*/
|
*/
|
||||||
public void onPause() {
|
protected final void pauseGLThread() {
|
||||||
mGLThread.onPause();
|
mGLThread.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resumes the rendering thread, re-creating the OpenGL context if necessary. It
|
* 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
|
* This method should typically be called in
|
||||||
* {@link android.app.Activity#onStart Activity.onStart}.
|
* {@link android.app.Activity#onStart Activity.onStart}.
|
||||||
*
|
*
|
||||||
* Must not be called before a renderer has been set.
|
* Must not be called before a renderer has been set.
|
||||||
*/
|
*/
|
||||||
public void onResume() {
|
protected final void resumeGLThread() {
|
||||||
mGLThread.onResume();
|
mGLThread.onResume();
|
||||||
}
|
}
|
||||||
|
// -- GODOT end --
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue a runnable to be run on the GL rendering thread. This can be used
|
* Queue a runnable to be run on the GL rendering thread. This can be used
|
||||||
|
Loading…
Reference in New Issue
Block a user