Skip to content

Commit

Permalink
Android: minor, remove static attributes, move mIsSurfaceReady to SDL…
Browse files Browse the repository at this point in the history
…Surface
  • Loading branch information
1bsyl committed Jan 14, 2019
1 parent 647b1f6 commit ae41831
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
Expand Up @@ -37,7 +37,7 @@
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
private static final String TAG = "SDL";

public static boolean mIsResumedCalled, mIsSurfaceReady, mHasFocus;
public static boolean mIsResumedCalled, mHasFocus;

// Cursor types
private static final int SDL_SYSTEM_CURSOR_NONE = -1;
Expand Down Expand Up @@ -179,7 +179,6 @@ public static void initialize() {
mSDLThread = null;
mBrokenLibraries = false;
mIsResumedCalled = false;
mIsSurfaceReady = false;
mHasFocus = true;
mNextNativeState = NativeState.INIT;
mCurrentNativeState = NativeState.INIT;
Expand Down Expand Up @@ -497,7 +496,7 @@ public static void handleNativeState() {

// Try a transition to resumed state
if (mNextNativeState == NativeState.RESUMED) {
if (mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
if (mSurface.mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
if (mSDLThread == null) {
// This is the entry point to the C app.
// Start up the C app thread and enable sensor input for the first time
Expand Down Expand Up @@ -1531,11 +1530,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
View.OnKeyListener, View.OnTouchListener, SensorEventListener {

// Sensors
protected static SensorManager mSensorManager;
protected static Display mDisplay;
protected SensorManager mSensorManager;
protected Display mDisplay;

// Keep track of the surface size to normalize touch events
protected static float mWidth, mHeight;
protected float mWidth, mHeight;

// Is SurfaceView ready for rendering
public boolean mIsSurfaceReady;

// Startup
public SDLSurface(Context context) {
Expand All @@ -1558,6 +1560,8 @@ public SDLSurface(Context context) {
// Some arbitrary defaults to avoid a potential division by zero
mWidth = 1.0f;
mHeight = 1.0f;

mIsSurfaceReady = false;
}

public void handlePause() {
Expand Down Expand Up @@ -1593,7 +1597,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {
SDLActivity.mNextNativeState = SDLActivity.NativeState.PAUSED;
SDLActivity.handleNativeState();

SDLActivity.mIsSurfaceReady = false;
mIsSurfaceReady = false;
SDLActivity.onNativeSurfaceDestroyed();
}

Expand Down Expand Up @@ -1686,15 +1690,15 @@ else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || req

if (skip) {
Log.v("SDL", "Skip .. Surface is not ready.");
SDLActivity.mIsSurfaceReady = false;
mIsSurfaceReady = false;
return;
}

/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
SDLActivity.onNativeSurfaceChanged();

/* Surface is ready */
SDLActivity.mIsSurfaceReady = true;
mIsSurfaceReady = true;

SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED;
SDLActivity.handleNativeState();
Expand Down

0 comments on commit ae41831

Please sign in to comment.