3636#include " tts_android.h"
3737
3838#include " core/config/project_settings.h"
39+ #include " main/main.h"
3940
4041#if defined(RD_ENABLED)
4142#include " servers/rendering/renderer_rd/renderer_compositor_rd.h"
@@ -703,6 +704,9 @@ void DisplayServerAndroid::reset_window() {
703704 }
704705 }
705706#endif
707+
708+ // We force redraw to ensure we render at least once when the window is reset.
709+ Main::force_redraw ();
706710}
707711
708712void DisplayServerAndroid::notify_surface_changed (int p_width, int p_height) {
@@ -837,23 +841,23 @@ void DisplayServerAndroid::_mouse_update_mode() {
837841 ? mouse_mode_override
838842 : mouse_mode_base;
839843
840- if (!OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()-> can_update_pointer_icon () || ! OS_Android::get_singleton ()-> get_godot_java ()-> get_godot_view ()-> can_capture_pointer ()) {
844+ if (!OS_Android::get_singleton ()->get_godot_java ()->can_capture_pointer ()) {
841845 return ;
842846 }
843847 if (mouse_mode == wanted_mouse_mode) {
844848 return ;
845849 }
846850
847851 if (wanted_mouse_mode == MouseMode::MOUSE_MODE_HIDDEN) {
848- OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()-> set_pointer_icon (CURSOR_TYPE_NULL);
852+ OS_Android::get_singleton ()->get_godot_java ()->set_pointer_icon (CURSOR_TYPE_NULL);
849853 } else {
850854 cursor_set_shape (cursor_shape);
851855 }
852856
853857 if (wanted_mouse_mode == MouseMode::MOUSE_MODE_CAPTURED) {
854- OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()-> request_pointer_capture ();
858+ OS_Android::get_singleton ()->get_godot_java ()->request_pointer_capture ();
855859 } else {
856- OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()-> release_pointer_capture ();
860+ OS_Android::get_singleton ()->get_godot_java ()->release_pointer_capture ();
857861 }
858862
859863 mouse_mode = wanted_mouse_mode;
@@ -903,17 +907,14 @@ BitField<MouseButtonMask> DisplayServerAndroid::mouse_get_button_state() const {
903907}
904908
905909void DisplayServerAndroid::_cursor_set_shape_helper (CursorShape p_shape, bool force) {
906- if (!OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()->can_update_pointer_icon ()) {
907- return ;
908- }
909910 if (cursor_shape == p_shape && !force) {
910911 return ;
911912 }
912913
913914 cursor_shape = p_shape;
914915
915916 if (mouse_mode == MouseMode::MOUSE_MODE_VISIBLE || mouse_mode == MouseMode::MOUSE_MODE_CONFINED) {
916- OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()-> set_pointer_icon (android_cursors[cursor_shape]);
917+ OS_Android::get_singleton ()->get_godot_java ()->set_pointer_icon (android_cursors[cursor_shape]);
917918 }
918919}
919920
@@ -932,7 +933,7 @@ void DisplayServerAndroid::cursor_set_custom_image(const Ref<Resource> &p_cursor
932933 if (!cursor_path.is_empty ()) {
933934 cursor_path = ProjectSettings::get_singleton ()->globalize_path (cursor_path);
934935 }
935- OS_Android::get_singleton ()->get_godot_java ()->get_godot_view ()-> configure_pointer_icon (android_cursors[cursor_shape], cursor_path, p_hotspot);
936+ OS_Android::get_singleton ()->get_godot_java ()->configure_pointer_icon (android_cursors[cursor_shape], cursor_path, p_hotspot);
936937 _cursor_set_shape_helper (p_shape, true );
937938}
938939
@@ -953,16 +954,24 @@ DisplayServer::VSyncMode DisplayServerAndroid::window_get_vsync_mode(WindowID p_
953954 return DisplayServer::VSYNC_ENABLED;
954955}
955956
956- void DisplayServerAndroid::reset_swap_buffers_flag () {
957- swap_buffers_flag = false ;
958- }
957+ void DisplayServerAndroid::release_rendering_thread () {
958+ if (egl_current_window_id == INVALID_WINDOW_ID) {
959+ return ;
960+ }
959961
960- bool DisplayServerAndroid::should_swap_buffers () const {
961- return swap_buffers_flag;
962+ GodotJavaWrapper *godot_java = OS_Android::get_singleton ()->get_godot_java ();
963+ ERR_FAIL_NULL (godot_java);
964+ godot_java->release_current_gl_window (egl_current_window_id);
962965}
963966
964967void DisplayServerAndroid::swap_buffers () {
965- swap_buffers_flag = true ;
968+ if (egl_current_window_id == INVALID_WINDOW_ID) {
969+ return ;
970+ }
971+
972+ GodotJavaWrapper *godot_java = OS_Android::get_singleton ()->get_godot_java ();
973+ ERR_FAIL_NULL (godot_java);
974+ godot_java->egl_swap_buffers (egl_current_window_id);
966975}
967976
968977void DisplayServerAndroid::set_native_icon (const String &p_filename) {
@@ -976,3 +985,18 @@ void DisplayServerAndroid::set_icon(const Ref<Image> &p_icon) {
976985bool DisplayServerAndroid::is_window_transparency_available () const {
977986 return GLOBAL_GET_CACHED (bool , " display/window/per_pixel_transparency/allowed" );
978987}
988+
989+ void DisplayServerAndroid::gl_window_make_current (DisplayServer::WindowID p_window_id) {
990+ if (p_window_id == INVALID_WINDOW_ID) {
991+ return ;
992+ }
993+
994+ if (egl_current_window_id == p_window_id) {
995+ return ;
996+ }
997+
998+ GodotJavaWrapper *godot_java = OS_Android::get_singleton ()->get_godot_java ();
999+ ERR_FAIL_NULL (godot_java);
1000+ godot_java->make_gl_window_current (p_window_id);
1001+ egl_current_window_id = p_window_id;
1002+ }
0 commit comments