Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
3ecdc27f
Unverified
Commit
3ecdc27f
authored
May 24, 2020
by
Rémi Verschelde
Committed by
GitHub
May 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39004 from nekomatata/android-reset-surface
Proper surface reset when resuming app on Android
parents
926d6c10
b987677c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
17 deletions
+43
-17
display_server_android.cpp
platform/android/display_server_android.cpp
+19
-0
display_server_android.h
platform/android/display_server_android.h
+2
-0
GodotLib.java
.../android/java/lib/src/org/godotengine/godot/GodotLib.java
+4
-3
GodotRenderer.java
...oid/java/lib/src/org/godotengine/godot/GodotRenderer.java
+1
-1
VkRenderer.kt
...d/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt
+2
-9
java_godot_lib_jni.cpp
platform/android/java_godot_lib_jni.cpp
+14
-3
java_godot_lib_jni.h
platform/android/java_godot_lib_jni.h
+1
-1
No files found.
platform/android/display_server_android.cpp
View file @
3ecdc27f
...
...
@@ -367,6 +367,25 @@ void DisplayServerAndroid::register_android_driver() {
register_create_function
(
"android"
,
create_func
,
get_rendering_drivers_func
);
}
void
DisplayServerAndroid
::
reset_window
()
{
#if defined(VULKAN_ENABLED)
if
(
rendering_driver
==
"vulkan"
)
{
ANativeWindow
*
native_window
=
OS_Android
::
get_singleton
()
->
get_native_window
();
ERR_FAIL_COND
(
!
native_window
);
ERR_FAIL_COND
(
!
context_vulkan
);
context_vulkan
->
window_destroy
(
MAIN_WINDOW_ID
);
Size2i
display_size
=
OS_Android
::
get_singleton
()
->
get_display_size
();
if
(
context_vulkan
->
window_create
(
native_window
,
display_size
.
width
,
display_size
.
height
)
==
-
1
)
{
memdelete
(
context_vulkan
);
context_vulkan
=
nullptr
;
ERR_FAIL_MSG
(
"Failed to reset Vulkan window."
);
}
}
#endif
}
DisplayServerAndroid
::
DisplayServerAndroid
(
const
String
&
p_rendering_driver
,
DisplayServer
::
WindowMode
p_mode
,
uint32_t
p_flags
,
const
Vector2i
&
p_resolution
,
Error
&
r_error
)
{
rendering_driver
=
p_rendering_driver
;
...
...
platform/android/display_server_android.h
View file @
3ecdc27f
...
...
@@ -166,6 +166,8 @@ public:
static
Vector
<
String
>
get_rendering_drivers_func
();
static
void
register_android_driver
();
void
reset_window
();
DisplayServerAndroid
(
const
String
&
p_rendering_driver
,
WindowMode
p_mode
,
uint32_t
p_flags
,
const
Vector2i
&
p_resolution
,
Error
&
r_error
);
~
DisplayServerAndroid
();
};
...
...
platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
View file @
3ecdc27f
...
...
@@ -66,11 +66,12 @@ public class GodotLib {
/**
* Invoked on the GL thread when the underlying Android surface has changed size.
* @param width
* @param height
* @param p_surface
* @param p_width
* @param p_height
* @see android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(GL10, int, int)
*/
public
static
native
void
resize
(
int
width
,
int
height
);
public
static
native
void
resize
(
Surface
p_surface
,
int
p_width
,
int
p_
height
);
/**
* Invoked on the render thread when the underlying Android surface is created or recreated.
...
...
platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java
View file @
3ecdc27f
...
...
@@ -64,7 +64,7 @@ class GodotRenderer implements GLSurfaceView.Renderer {
}
public
void
onSurfaceChanged
(
GL10
gl
,
int
width
,
int
height
)
{
GodotLib
.
resize
(
width
,
height
);
GodotLib
.
resize
(
null
,
width
,
height
);
for
(
GodotPlugin
plugin
:
pluginRegistry
.
getAllPlugins
())
{
plugin
.
onGLSurfaceChanged
(
gl
,
width
,
height
);
}
...
...
platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt
View file @
3ecdc27f
...
...
@@ -59,9 +59,7 @@ internal class VkRenderer {
* Called when the surface is created and signals the beginning of rendering.
*/
fun
onVkSurfaceCreated
(
surface
:
Surface
)
{
// TODO: properly implement surface re-creation:
// GodotLib.newcontext should be called here once it's done.
//GodotLib.newcontext(surface, false)
GodotLib
.
newcontext
(
surface
,
false
)
for
(
plugin
in
pluginRegistry
.
getAllPlugins
())
{
plugin
.
onVkSurfaceCreated
(
surface
)
...
...
@@ -72,12 +70,7 @@ internal class VkRenderer {
* Called after the surface is created and whenever its size changes.
*/
fun
onVkSurfaceChanged
(
surface
:
Surface
,
width
:
Int
,
height
:
Int
)
{
GodotLib
.
resize
(
width
,
height
)
// TODO: properly implement surface re-creation:
// Update the native renderer instead of restarting the app.
// GodotLib.newcontext should not be called here once it's done.
GodotLib
.
newcontext
(
surface
,
false
)
GodotLib
.
resize
(
surface
,
width
,
height
)
for
(
plugin
in
pluginRegistry
.
getAllPlugins
())
{
plugin
.
onVkSurfaceChanged
(
surface
,
width
,
height
)
...
...
platform/android/java_godot_lib_jni.cpp
View file @
3ecdc27f
...
...
@@ -164,9 +164,20 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jc
ClassDB
::
register_class
<
JNISingleton
>
();
}
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_resize
(
JNIEnv
*
env
,
jclass
clazz
,
jint
width
,
jint
height
)
{
if
(
os_android
)
os_android
->
set_display_size
(
Size2i
(
width
,
height
));
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_resize
(
JNIEnv
*
env
,
jclass
clazz
,
jobject
p_surface
,
jint
p_width
,
jint
p_height
)
{
if
(
os_android
)
{
os_android
->
set_display_size
(
Size2i
(
p_width
,
p_height
));
// No need to reset the surface during startup
if
(
step
>
0
)
{
if
(
p_surface
)
{
ANativeWindow
*
native_window
=
ANativeWindow_fromSurface
(
env
,
p_surface
);
os_android
->
set_native_window
(
native_window
);
DisplayServerAndroid
::
get_singleton
()
->
reset_window
();
}
}
}
}
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_newcontext
(
JNIEnv
*
env
,
jclass
clazz
,
jobject
p_surface
,
jboolean
p_32_bits
)
{
...
...
platform/android/java_godot_lib_jni.h
View file @
3ecdc27f
...
...
@@ -40,7 +40,7 @@ extern "C" {
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_initialize
(
JNIEnv
*
env
,
jclass
clazz
,
jobject
activity
,
jobject
p_asset_manager
,
jboolean
p_use_apk_expansion
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_ondestroy
(
JNIEnv
*
env
,
jclass
clazz
,
jobject
activity
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_setup
(
JNIEnv
*
env
,
jclass
clazz
,
jobjectArray
p_cmdline
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_resize
(
JNIEnv
*
env
,
jclass
clazz
,
j
int
width
,
jint
height
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_resize
(
JNIEnv
*
env
,
jclass
clazz
,
j
object
p_surface
,
jint
p_width
,
jint
p_
height
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_newcontext
(
JNIEnv
*
env
,
jclass
clazz
,
jobject
p_surface
,
jboolean
p_32_bits
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_step
(
JNIEnv
*
env
,
jclass
clazz
);
JNIEXPORT
void
JNICALL
Java_org_godotengine_godot_GodotLib_back
(
JNIEnv
*
env
,
jclass
clazz
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment