Route UI thread lifecycle through platform services
This commit is contained in:
10
src/app.cpp
10
src/app.cpp
@@ -20,8 +20,6 @@
|
||||
void android_async_lock();
|
||||
void android_async_swap();
|
||||
void android_async_unlock();
|
||||
void android_attach_jni();
|
||||
void android_detach_jni();
|
||||
#elif _WIN32
|
||||
bool async_lock_try();
|
||||
void async_lock();
|
||||
@@ -1083,9 +1081,7 @@ void App::ui_thread_main()
|
||||
ui_thread_id = std::this_thread::get_id();
|
||||
ui_running = true;
|
||||
|
||||
#if __ANDROID__
|
||||
android_attach_jni();
|
||||
#endif
|
||||
attach_ui_thread();
|
||||
|
||||
LOG("ui thread init()");
|
||||
init();
|
||||
@@ -1169,9 +1165,7 @@ void App::ui_thread_main()
|
||||
rendered_frames++;
|
||||
}
|
||||
}
|
||||
#if __ANDROID__
|
||||
android_detach_jni();
|
||||
#endif
|
||||
detach_ui_thread();
|
||||
}
|
||||
|
||||
void App::render_thread_start()
|
||||
|
||||
@@ -190,6 +190,8 @@ public:
|
||||
void display_file(std::string path);
|
||||
void share_file(std::string path);
|
||||
void request_app_close();
|
||||
void attach_ui_thread();
|
||||
void detach_ui_thread();
|
||||
void update_platform_frame(float delta_time_seconds);
|
||||
void report_rendered_frames(int frames);
|
||||
void save_prepared_file(
|
||||
|
||||
@@ -219,6 +219,16 @@ void App::request_app_close()
|
||||
active_platform_services().request_app_close();
|
||||
}
|
||||
|
||||
void App::attach_ui_thread()
|
||||
{
|
||||
active_platform_services().attach_ui_thread();
|
||||
}
|
||||
|
||||
void App::detach_ui_thread()
|
||||
{
|
||||
active_platform_services().detach_ui_thread();
|
||||
}
|
||||
|
||||
void App::update_platform_frame(float delta_time_seconds)
|
||||
{
|
||||
active_platform_services().update_platform_frame(delta_time_seconds);
|
||||
|
||||
@@ -18,6 +18,8 @@ public:
|
||||
[[nodiscard]] virtual bool set_clipboard_text(std::string_view text) = 0;
|
||||
virtual void set_cursor_visible(bool visible) = 0;
|
||||
virtual void set_virtual_keyboard_visible(bool visible) = 0;
|
||||
virtual void attach_ui_thread() = 0;
|
||||
virtual void detach_ui_thread() = 0;
|
||||
virtual void update_platform_frame(float delta_time_seconds) = 0;
|
||||
virtual void report_rendered_frames(int frames) = 0;
|
||||
virtual void display_file(std::string_view path) = 0;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#ifdef __ANDROID__
|
||||
void displayKeyboard(bool pShow);
|
||||
void android_attach_jni();
|
||||
void android_detach_jni();
|
||||
void android_pick_file(std::function<void(std::string)> callback);
|
||||
void android_pick_file_save(std::function<void(std::string)> callback);
|
||||
std::string android_get_clipboard();
|
||||
@@ -88,6 +90,20 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void attach_ui_thread() override
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
android_attach_jni();
|
||||
#endif
|
||||
}
|
||||
|
||||
void detach_ui_thread() override
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
android_detach_jni();
|
||||
#endif
|
||||
}
|
||||
|
||||
void update_platform_frame(float delta_time_seconds) override
|
||||
{
|
||||
(void)delta_time_seconds;
|
||||
|
||||
@@ -170,6 +170,14 @@ public:
|
||||
(void)visible;
|
||||
}
|
||||
|
||||
void attach_ui_thread() override
|
||||
{
|
||||
}
|
||||
|
||||
void detach_ui_thread() override
|
||||
{
|
||||
}
|
||||
|
||||
void update_platform_frame(float delta_time_seconds) override
|
||||
{
|
||||
win32_update_stylus(delta_time_seconds);
|
||||
|
||||
Reference in New Issue
Block a user