Add proxy_to_pthread option to platform=web
Co-authored-by: Fabio Alessandrelli <fabio.alessandrelli@gmail.com>
This commit is contained in:
@@ -40,7 +40,10 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
static OS_Web *os = nullptr;
|
||||
#ifndef PROXY_TO_PTHREAD_ENABLED
|
||||
static uint64_t target_ticks = 0;
|
||||
#endif
|
||||
|
||||
static bool main_started = false;
|
||||
static bool shutdown_complete = false;
|
||||
|
||||
@@ -63,15 +66,20 @@ void cleanup_after_sync() {
|
||||
}
|
||||
|
||||
void main_loop_callback() {
|
||||
#ifndef PROXY_TO_PTHREAD_ENABLED
|
||||
uint64_t current_ticks = os->get_ticks_usec();
|
||||
#endif
|
||||
|
||||
bool force_draw = DisplayServerWeb::get_singleton()->check_size_force_redraw();
|
||||
if (force_draw) {
|
||||
Main::force_redraw();
|
||||
#ifndef PROXY_TO_PTHREAD_ENABLED
|
||||
} else if (current_ticks < target_ticks) {
|
||||
return; // Skip frame.
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef PROXY_TO_PTHREAD_ENABLED
|
||||
int max_fps = Engine::get_singleton()->get_max_fps();
|
||||
if (max_fps > 0) {
|
||||
if (current_ticks - target_ticks > 1000000) {
|
||||
@@ -81,6 +89,8 @@ void main_loop_callback() {
|
||||
}
|
||||
target_ticks += (uint64_t)(1000000 / max_fps);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (os->main_loop_iterate()) {
|
||||
emscripten_cancel_main_loop(); // Cancel current loop and set the cleanup one.
|
||||
emscripten_set_main_loop(exit_callback, -1, false);
|
||||
|
||||
Reference in New Issue
Block a user