diff options
Diffstat (limited to 'platform/javascript')
-rw-r--r-- | platform/javascript/detect.py | 10 | ||||
-rw-r--r-- | platform/javascript/engine.js | 10 | ||||
-rw-r--r-- | platform/javascript/javascript_main.cpp | 2 | ||||
-rw-r--r-- | platform/javascript/os_javascript.cpp | 14 | ||||
-rw-r--r-- | platform/javascript/os_javascript.h | 1 |
5 files changed, 28 insertions, 9 deletions
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 8472c3ccab..8c7a904bca 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -49,8 +49,14 @@ def configure(env): ## Build type if (env["target"] == "release"): - env.Append(CCFLAGS=['-O3']) - env.Append(LINKFLAGS=['-O3']) + # Use -Os to prioritize optimizing for reduced file size. This is + # particularly valuable for the web platform because it directly + # decreases download time. + # -Os reduces file size by around 5 MiB over -O3. -Oz only saves about + # 100 KiB over -Os, which does not justify the negative impact on + # run-time performance. + env.Append(CCFLAGS=['-Os']) + env.Append(LINKFLAGS=['-Os']) elif (env["target"] == "release_debug"): env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index dc4bdc7efb..bca1851f40 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -138,13 +138,17 @@ } var actualCanvas = this.rtenv.canvas; - var context = false; + var testContext = false; + var testCanvas; try { - context = actualCanvas.getContext('webgl2') || actualCanvas.getContext('experimental-webgl2'); + testCanvas = document.createElement('canvas'); + testContext = testCanvas.getContext('webgl2') || testCanvas.getContext('experimental-webgl2'); } catch (e) {} - if (!context) { + if (!testContext) { throw new Error("WebGL 2 not available"); } + testCanvas = null; + testContext = null; // canvas can grab focus on click if (actualCanvas.tabIndex < 0) { diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index b738f37d1b..e85fe0800f 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) { FS.mkdir('/userfs'); FS.mount(IDBFS, {}, '/userfs'); FS.syncfs(true, function(err) { - Module['ccall']('main_after_fs_sync', null, ['string'], [err ? err.message : ""]) + ccall('main_after_fs_sync', null, ['string'], [err ? err.message : ""]) }); ); /* clang-format on */ diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index c598557738..b10ef821dd 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -566,7 +566,7 @@ void OS_JavaScript::set_css_cursor(const char *p_cursor) { /* clang-format off */ EM_ASM_({ - Module.canvas.style.cursor = Module.UTF8ToString($0); + Module.canvas.style.cursor = UTF8ToString($0); }, p_cursor); /* clang-format on */ } @@ -576,7 +576,7 @@ const char *OS_JavaScript::get_css_cursor() const { char cursor[16]; /* clang-format off */ EM_ASM_INT({ - Module.stringToUTF8(Module.canvas.style.cursor ? Module.canvas.style.cursor : 'auto', $0, 16); + stringToUTF8(Module.canvas.style.cursor ? Module.canvas.style.cursor : 'auto', $0, 16); }, cursor); /* clang-format on */ return cursor; @@ -782,6 +782,9 @@ void OS_JavaScript::set_cursor_shape(CursorShape p_shape) { set_css_cursor(godot2dom_cursor(cursor_shape)); } +void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { +} + void OS_JavaScript::main_loop_begin() { if (main_loop) @@ -789,7 +792,7 @@ void OS_JavaScript::main_loop_begin() { /* clang-format off */ EM_ASM_ARGS({ - const send_notification = Module.cwrap('send_notification', null, ['number']); + const send_notification = cwrap('send_notification', null, ['number']); const notifs = arguments; (['mouseover', 'mouseleave', 'focus', 'blur']).forEach(function(event, i) { Module.canvas.addEventListener(event, send_notification.bind(null, notifs[i])); @@ -986,6 +989,7 @@ bool OS_JavaScript::is_userfs_persistent() const { } OS_JavaScript::OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_user_data_dir_func) { + set_cmdline(p_execpath, get_cmdline_args()); main_loop = NULL; gl_extensions = NULL; @@ -998,6 +1002,10 @@ OS_JavaScript::OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_us idbfs_available = false; time_to_save_sync = -1; + + Vector<Logger *> loggers; + loggers.push_back(memnew(StdLogger)); + _set_logger(memnew(CompositeLogger(loggers))); } OS_JavaScript::~OS_JavaScript() { diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 2af90ef16b..ce4763ab64 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -128,6 +128,7 @@ public: virtual bool is_userfs_persistent() const; virtual void set_cursor_shape(CursorShape p_shape); + virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); void main_loop_begin(); bool main_loop_iterate(); |