From b9a2f108fc055de6a093fcec89624de0583da9cd Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Thu, 31 Oct 2024 16:52:26 -0300 Subject: Fix splash screen upside down on Android Fixes an issue introduced in #96439 (see https://github.com/godotengine/godot/pull/96439#issuecomment-2447288702) Godot was relying on Java's activity.getWindowManager().getDefaultDisplay().getRotation(); to apply pre-rotation but this is wrong. First, getRotation() may temporarily return a different value from the correct one; which is what was causing the splash screen to be upside down. It would return -90 instead of 90 for the first rendered frame. But unfortunately, the splash screen is just one frame rendered for a very long time, so the error lingered for a long time for everyone to see. Second, to determine what rotation to use, we should be looking at what Vulkan told us, which is the value we pass to VkSurfaceTransformFlagBitsKHR::preTransform. This commit removes the now-unnecessary screen_get_internal_current_rotation() function (which was introduced by #96439) and now saves the preTransform value in the swapchain. --- platform/android/java_godot_io_wrapper.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'platform/android/java_godot_io_wrapper.cpp') diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp index e58ef50a73..623db39985 100644 --- a/platform/android/java_godot_io_wrapper.cpp +++ b/platform/android/java_godot_io_wrapper.cpp @@ -66,7 +66,6 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc _has_hardware_keyboard = p_env->GetMethodID(cls, "hasHardwareKeyboard", "()Z"); _set_screen_orientation = p_env->GetMethodID(cls, "setScreenOrientation", "(I)V"); _get_screen_orientation = p_env->GetMethodID(cls, "getScreenOrientation", "()I"); - _get_internal_current_screen_rotation = p_env->GetMethodID(cls, "getInternalCurrentScreenRotation", "()I"); _get_system_dir = p_env->GetMethodID(cls, "getSystemDir", "(IZ)Ljava/lang/String;"); } } @@ -268,16 +267,6 @@ int GodotIOJavaWrapper::get_screen_orientation() { } } -int GodotIOJavaWrapper::get_internal_current_screen_rotation() { - if (_get_internal_current_screen_rotation) { - JNIEnv *env = get_jni_env(); - ERR_FAIL_NULL_V(env, 0); - return env->CallIntMethod(godot_io_instance, _get_internal_current_screen_rotation); - } else { - return 0; - } -} - String GodotIOJavaWrapper::get_system_dir(int p_dir, bool p_shared_storage) { if (_get_system_dir) { JNIEnv *env = get_jni_env(); -- cgit v1.2.3