[HTML5] Refactor JS, threads support, closures.

- Refactored the Engine code, splitted across files.
- Use MODULARIZE option to build emscripten code into it's own closure.
- Optional closure compiler run for JS and generated code.
- Enable lto support (saves ~2MiB in release).
- Can now build with tools=yes (not much to see yet).
- Dropped some deprecated code for older toolchains.
- Add onExit, and onExecute JS function.
- Add files drag and drop support.
- Add support for low precessor usage mode (via offscreen render, swap).
This commit is contained in:
Fabio Alessandrelli
2020-01-19 11:44:19 +01:00
parent 93e20a4cd4
commit 21c9f37757
18 changed files with 1097 additions and 627 deletions

View File

@ -48,6 +48,8 @@ class OS_JavaScript : public OS_Unix {
bool just_exited_fullscreen;
bool transparency_enabled;
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE webgl_ctx;
InputDefault *input;
Ref<InputEventKey> deferred_key_event;
CursorShape cursor_shape;
@ -62,6 +64,7 @@ class OS_JavaScript : public OS_Unix {
MainLoop *main_loop;
int video_driver_index;
AudioDriverJavaScript audio_driver_javascript;
VisualServer *visual_server;
bool idb_available;
int64_t sync_wait_time;
@ -84,8 +87,6 @@ class OS_JavaScript : public OS_Unix {
static EM_BOOL gamepad_change_callback(int p_event_type, const EmscriptenGamepadEvent *p_event, void *p_user_data);
void process_joypads();
static void main_loop_callback();
static void file_access_close_callback(const String &p_file, int p_flags);
protected:
@ -102,9 +103,13 @@ protected:
virtual bool _check_internal_feature_support(const String &p_feature);
public:
String canvas_id;
void finalize_async();
// Override return type to make writing static callbacks less tedious.
static OS_JavaScript *get_singleton();
virtual void swap_buffers();
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
virtual VideoMode get_video_mode(int p_screen = 0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
@ -142,7 +147,6 @@ public:
virtual String get_clipboard() const;
virtual MainLoop *get_main_loop() const;
void run_async();
bool main_loop_iterate();
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL);
@ -157,7 +161,9 @@ public:
virtual String get_name() const;
virtual bool can_draw() const;
virtual String get_resource_dir() const;
virtual String get_cache_path() const;
virtual String get_config_path() const;
virtual String get_data_path() const;
virtual String get_user_data_dir() const;
virtual OS::PowerState get_power_state();