Permalink
Browse files

Merge pull request #11455 from unknownbrackets/android-resize

Android: Fix Vulkan immersive startup
  • Loading branch information...
hrydgard committed Oct 8, 2018
2 parents 6fd1c0e + 5a5483c commit a0b019d473976cbf02db17c30c19984b54b7b514
Showing with 35 additions and 27 deletions.
  1. +4 −1 UI/NativeApp.cpp
  2. +1 −1 android/jni/app-android.cpp
  3. +30 −25 android/src/org/ppsspp/ppsspp/NativeActivity.java
View
@@ -133,6 +133,7 @@ static UI::Theme ui_theme;
ScreenManager *screenManager;
std::string config_filename;
bool g_graphicsIniting;
bool g_graphicsInited;
// Really need to clean this mess of globals up... but instead I add more :P
@@ -747,6 +748,7 @@ static void UIThemeInit() {
void RenderOverlays(UIContext *dc, void *userdata);
bool NativeInitGraphics(GraphicsContext *graphicsContext) {
g_graphicsIniting = true;
ILOG("NativeInitGraphics");
_assert_msg_(G3D, graphicsContext, "No graphics context!");
@@ -823,6 +825,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
gpu->DeviceRestore();
g_graphicsInited = true;
g_graphicsIniting = false;
ILOG("NativeInitGraphics completed");
return true;
}
@@ -1244,7 +1247,7 @@ void NativeMessageReceived(const char *message, const char *value) {
void NativeResized() {
// NativeResized can come from any thread so we just set a flag, then process it later.
if (g_graphicsInited) {
if (g_graphicsInited || g_graphicsIniting) {
resized = true;
} else {
ILOG("NativeResized ignored, not initialized");
@@ -946,7 +946,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
// This is up here to prevent race conditions, in case we pause during init.
renderLoopRunning = true;
ANativeWindow *wnd = ANativeWindow_fromSurface(env, _surf);
ANativeWindow *wnd = _surf ? ANativeWindow_fromSurface(env, _surf) : nullptr;
WLOG("runEGLRenderLoop. display_xres=%d display_yres=%d", display_xres, display_yres);
@@ -142,7 +142,7 @@ NativeRenderer getRenderer() {
return nativeRenderer;
}
@TargetApi(17)
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void detectOptimalAudioSettings() {
try {
optimalFramesPerBuffer = Integer.parseInt(this.audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
@@ -174,7 +174,7 @@ String getApplicationLibraryDir(ApplicationInfo application) {
return libdir;
}
@TargetApi(23)
@TargetApi(Build.VERSION_CODES.M)
boolean askForPermissions(String[] permissions, int requestCode) {
boolean shouldAsk = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -190,7 +190,7 @@ boolean askForPermissions(String[] permissions, int requestCode) {
return shouldAsk;
}
@TargetApi(23)
@TargetApi(Build.VERSION_CODES.M)
public void sendInitialGrants() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Let's start out granted if it was granted already.
@@ -244,12 +244,12 @@ public void Initialize() {
this.audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
this.audioFocusChangeListener = new AudioFocusChangeListener();
if (Build.VERSION.SDK_INT >= 17) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
// Get the optimal buffer sz
detectOptimalAudioSettings();
}
powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= 24) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (powerManager.isSustainedPerformanceModeSupported()) {
sustainedPerfSupported = true;
NativeApp.sendMessage("sustained_perf_supported", "1");
@@ -314,7 +314,7 @@ public void Initialize() {
PowerSaveModeReceiver.initAndSend(this);
// OK, config should be initialized, we can query for screen rotation.
if (Build.VERSION.SDK_INT >= 9) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
updateScreenRotation("Initialize");
}
@@ -331,18 +331,18 @@ public void Initialize() {
}
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
checkForVibrator();
}
mLocationHelper = new LocationHelper(this);
if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// android.graphics.SurfaceTexture is not available before version 11.
mCameraHelper = new CameraHelper(this);
}
}
@TargetApi(24)
@TargetApi(Build.VERSION_CODES.N)
private void updateSustainedPerformanceMode() {
if (sustainedPerfSupported) {
// Query the native application on the desired rotation.
@@ -358,7 +358,7 @@ private void updateSustainedPerformanceMode() {
}
}
@TargetApi(9)
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void updateScreenRotation(String cause) {
// Query the native application on the desired rotation.
int rot = 0;
@@ -401,7 +401,7 @@ private boolean useImmersive() {
}
@SuppressLint("InlinedApi")
@TargetApi(14)
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateSystemUiVisibility() {
int flags = 0;
if (useLowProfileButtons()) {
@@ -419,9 +419,9 @@ private void updateSystemUiVisibility() {
}
// Need API 11 to check for existence of a vibrator? Zany.
@TargetApi(11)
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void checkForVibrator() {
if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (!vibrator.hasVibrator()) {
vibrator = null;
}
@@ -451,12 +451,12 @@ public void getDesiredBackbufferSize(Point sz) {
sz.y = NativeApp.getDesiredBackbufferHeight();
}
@TargetApi(17)
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void updateDisplayMeasurements() {
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
if (useImmersive() && Build.VERSION.SDK_INT >= 17) {
if (useImmersive() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealMetrics(metrics);
} else {
display.getMetrics(metrics);
@@ -569,6 +569,11 @@ public void surfaceCreated(SurfaceHolder holder) {
// Note that desiredSize might be 0,0 here - but that's fine when calling setFixedSize! It means auto.
Log.d(TAG, "Setting fixed size " + desiredSize.x + " x " + desiredSize.y);
holder.setFixedSize(desiredSize.x, desiredSize.y);
// This may change it - but, since we're visible now, we can actually set this.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
updateSystemUiVisibility();
}
}
@Override
@@ -651,7 +656,7 @@ private synchronized void joinRenderLoopThread() {
}
}
@TargetApi(19)
@TargetApi(Build.VERSION_CODES.KITKAT)
void setupSystemUiCallback() {
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {
@Override
@@ -745,7 +750,7 @@ protected void onResume() {
updateSystemUiVisibility();
}
// OK, config should be initialized, we can query for screen rotation.
if (javaGL || Build.VERSION.SDK_INT >= 9) {
if (javaGL || Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
updateScreenRotation("onResume");
}
@@ -892,7 +897,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
return super.dispatchKeyEvent(event);
}
@TargetApi(16)
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static String getInputDesc(InputDevice input) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return input.getDescriptor();
@@ -906,11 +911,11 @@ public static String getInputDesc(InputDevice input) {
}
@Override
@TargetApi(12)
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public boolean onGenericMotionEvent(MotionEvent event) {
// Log.d(TAG, "onGenericMotionEvent: " + event);
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
if (Build.VERSION.SDK_INT >= 12) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
InputDeviceState state = getInputDeviceState(event);
if (state == null) {
Log.w(TAG, "Joystick event but failed to get input device state.");
@@ -1025,19 +1030,19 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
@TargetApi(11)
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressWarnings("deprecation")
private AlertDialog.Builder createDialogBuilderWithTheme() {
return new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK);
}
@TargetApi(14)
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@SuppressWarnings("deprecation")
private AlertDialog.Builder createDialogBuilderWithDeviceTheme() {
return new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_DARK);
}
@TargetApi(17)
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@SuppressWarnings("deprecation")
private AlertDialog.Builder createDialogBuilderWithDeviceThemeAndUiVisibility() {
AlertDialog.Builder bld = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_DARK);
@@ -1050,7 +1055,7 @@ public void onDismiss(DialogInterface dialog) {
return bld;
}
@TargetApi(23)
@TargetApi(Build.VERSION_CODES.M)
private AlertDialog.Builder createDialogBuilderNew() {
AlertDialog.Builder bld = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Dialog_Alert);
bld.setOnDismissListener(new DialogInterface.OnDismissListener() {
@@ -1260,7 +1265,7 @@ public boolean processCommand(String command, String params) {
Log.i(TAG, "Must recreate activity on rotation");
}
} else {
if (Build.VERSION.SDK_INT >= 9) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
updateScreenRotation("rotate");
}
}

0 comments on commit a0b019d

Please sign in to comment.