Route platform frame hooks through services
This commit is contained in:
13
src/app.cpp
13
src/app.cpp
@@ -1123,10 +1123,7 @@ void App::ui_thread_main()
|
||||
float dt = std::chrono::duration<float>(t_now - t_start).count();
|
||||
t_start = t_now;
|
||||
|
||||
#ifdef _WIN32
|
||||
extern void win32_update_stylus(float dt);
|
||||
win32_update_stylus(dt);
|
||||
#endif
|
||||
update_platform_frame(dt);
|
||||
|
||||
// increment timers
|
||||
t_frame += dt;
|
||||
@@ -1134,13 +1131,7 @@ void App::ui_thread_main()
|
||||
|
||||
if (t_fps_counter > 1.f)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
extern void win32_update_fps(int frames);
|
||||
win32_update_fps(rendered_frames);
|
||||
#elif __LINUX__
|
||||
extern void linux_update_fps(int frames);
|
||||
linux_update_fps(rendered_frames);
|
||||
#endif
|
||||
report_rendered_frames(rendered_frames);
|
||||
t_fps_counter = 0;
|
||||
rendered_frames = 0;
|
||||
}
|
||||
|
||||
@@ -190,6 +190,8 @@ public:
|
||||
void display_file(std::string path);
|
||||
void share_file(std::string path);
|
||||
void request_app_close();
|
||||
void update_platform_frame(float delta_time_seconds);
|
||||
void report_rendered_frames(int frames);
|
||||
void save_prepared_file(
|
||||
std::string path,
|
||||
std::string suggested_name,
|
||||
|
||||
@@ -219,6 +219,16 @@ void App::request_app_close()
|
||||
active_platform_services().request_app_close();
|
||||
}
|
||||
|
||||
void App::update_platform_frame(float delta_time_seconds)
|
||||
{
|
||||
active_platform_services().update_platform_frame(delta_time_seconds);
|
||||
}
|
||||
|
||||
void App::report_rendered_frames(int frames)
|
||||
{
|
||||
active_platform_services().report_rendered_frames(frames);
|
||||
}
|
||||
|
||||
void App::save_prepared_file(
|
||||
std::string path,
|
||||
std::string suggested_name,
|
||||
|
||||
@@ -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 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;
|
||||
virtual void share_file(std::string_view path) = 0;
|
||||
virtual void request_app_close() = 0;
|
||||
|
||||
@@ -13,6 +13,7 @@ bool android_set_clipboard(const std::string& s);
|
||||
#elif __APPLE__
|
||||
#elif __LINUX__
|
||||
#include <tinyfiledialogs.h>
|
||||
void linux_update_fps(int frames);
|
||||
#elif __WEB__
|
||||
void webgl_pick_file(std::function<void(std::string)> callback);
|
||||
void webgl_pick_file_save(
|
||||
@@ -87,6 +88,20 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void update_platform_frame(float delta_time_seconds) override
|
||||
{
|
||||
(void)delta_time_seconds;
|
||||
}
|
||||
|
||||
void report_rendered_frames(int frames) override
|
||||
{
|
||||
#ifdef __LINUX__
|
||||
linux_update_fps(frames);
|
||||
#else
|
||||
(void)frames;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pick_image(pp::platform::PickedPathCallback callback) override
|
||||
{
|
||||
#ifdef __IOS__
|
||||
|
||||
@@ -8,6 +8,8 @@ extern std::deque<std::packaged_task<void()>> main_tasklist;
|
||||
extern std::mutex main_task_mutex;
|
||||
|
||||
void destroy_window();
|
||||
void win32_update_fps(int frames);
|
||||
void win32_update_stylus(float dt);
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -168,6 +170,16 @@ public:
|
||||
(void)visible;
|
||||
}
|
||||
|
||||
void update_platform_frame(float delta_time_seconds) override
|
||||
{
|
||||
win32_update_stylus(delta_time_seconds);
|
||||
}
|
||||
|
||||
void report_rendered_frames(int frames) override
|
||||
{
|
||||
win32_update_fps(frames);
|
||||
}
|
||||
|
||||
void display_file(std::string_view path) override
|
||||
{
|
||||
(void)path;
|
||||
|
||||
Reference in New Issue
Block a user