diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 5 | ||||
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/GodotView.java | 2 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 32 | ||||
-rw-r--r-- | platform/iphone/export/export.cpp | 2 | ||||
-rw-r--r-- | platform/javascript/detect.py | 10 | ||||
-rw-r--r-- | platform/javascript/engine.js | 10 | ||||
-rw-r--r-- | platform/osx/export/export.cpp | 22 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 2 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 25 |
9 files changed, 82 insertions, 28 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 37f25cc839..b5b0afb9e0 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -828,7 +828,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC //@Override public boolean dispatchTouchEvent (MotionEvent event) { public boolean gotTouchEvent(final MotionEvent event) { - super.onTouchEvent(event); final int evcount = event.getPointerCount(); if (evcount == 0) return true; @@ -842,6 +841,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC arr[i * 3 + 1] = (int)event.getX(i); arr[i * 3 + 2] = (int)event.getY(i); } + final int pointer_idx = event.getPointerId(event.getActionIndex()); //System.out.printf("gaction: %d\n",event.getAction()); final int action = event.getAction() & MotionEvent.ACTION_MASK; @@ -862,13 +862,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC */ } break; case MotionEvent.ACTION_POINTER_UP: { - final int indexPointUp = event.getActionIndex(); - final int pointer_idx = event.getPointerId(indexPointUp); GodotLib.touch(4, pointer_idx, evcount, arr); //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; case MotionEvent.ACTION_POINTER_DOWN: { - int pointer_idx = event.getActionIndex(); GodotLib.touch(3, pointer_idx, evcount, arr); //System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java index ca4895a2be..0222758c2b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/src/org/godotengine/godot/GodotView.java @@ -110,7 +110,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { @Override public boolean onTouchEvent(MotionEvent event) { - + super.onTouchEvent(event); return activity.gotTouchEvent(event); }; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 93272a1000..23811f963a 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -444,25 +444,27 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> } touch.clear(); } - } break; - case 3: { // add tuchi - - ERR_FAIL_INDEX(p_pointer, p_points.size()); + case 3: { // add touch - TouchPos tp = p_points[p_pointer]; - touch.push_back(tp); + for (int i = 0; i < p_points.size(); i++) { + if (p_points[i].id == p_pointer) { + TouchPos tp = p_points[i]; + touch.push_back(tp); - Ref<InputEventScreenTouch> ev; - ev.instance(); + Ref<InputEventScreenTouch> ev; + ev.instance(); - ev->set_index(tp.id); - ev->set_pressed(true); - ev->set_position(tp.pos); - input->parse_input_event(ev); + ev->set_index(tp.id); + ev->set_pressed(true); + ev->set_position(tp.pos); + input->parse_input_event(ev); + break; + } + } } break; - case 4: { + case 4: { // remove touch for (int i = 0; i < touch.size(); i++) { if (touch[i].id == p_pointer) { @@ -474,10 +476,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> ev->set_position(touch[i].pos); input->parse_input_event(ev); touch.remove(i); - i--; + + break; } } - } break; } } diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 99d44f3b5e..e3119814f4 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -407,7 +407,7 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name); if (err) { memdelete(da); - String err_str = String("Failed to export loading screen: ") + loading_screen_file; + String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file; ERR_PRINT(err_str.utf8().get_data()); return err; } 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/osx/export/export.cpp b/platform/osx/export/export.cpp index 23ca1e3fb9..c4efa1f0ff 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -359,6 +359,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p } if (err == OK) { + print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks"); + err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks"); + } + + if (err == OK) { print_line("Creating " + tmp_app_path_name + "/Contents/Resources"); err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources"); } @@ -502,10 +507,23 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (use_dmg()) { String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck"; - err = save_pack(p_preset, pack_path); + Vector<SharedObject> shared_objects; + Error err = save_pack(p_preset, pack_path, &shared_objects); // see if we can code sign our new package String identity = p_preset->get("codesign/identity"); + + if (err == OK) { + DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + for (int i = 0; i < shared_objects.size(); i++) { + da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file()); + if (err == OK && identity != "") { + err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file()); + } + } + memdelete(da); + } + if (err == OK && identity != "") { ep.step("Code signing bundle", 2); @@ -582,7 +600,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p ERR_CONTINUE(file.empty()); zipOpenNewFileInZip(dst_pkg_zip, - (pkg_name + ".app/Contents/MacOS/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(), + (pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(), NULL, NULL, 0, diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 9423b6e1d6..3648d41604 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -139,6 +139,8 @@ public: virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false); + 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); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 19f33c814f..939f75859c 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -39,6 +39,8 @@ #include "servers/visual/visual_server_raster.h" #include "version_generated.gen.h" +#include <mach-o/dyld.h> + #include <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> #include <IOKit/IOCFPlugIn.h> @@ -49,6 +51,7 @@ #include <os/log.h> #endif +#include <dlfcn.h> #include <fcntl.h> #include <libproc.h> #include <stdio.h> @@ -1262,6 +1265,28 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) { [window release]; } +Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { + + String path = p_path; + + if (!FileAccess::exists(path)) { + //this code exists so gdnative can load .dylib files from within the executable path + path = get_executable_path().get_base_dir().plus_file(p_path.get_file()); + } + + if (!FileAccess::exists(path)) { + //this code exists so gdnative can load .dylib files from a standard macOS location + path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file()); + } + + p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); + if (!p_library_handle) { + ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror()); + ERR_FAIL_V(ERR_CANT_OPEN); + } + return OK; +} + void OS_OSX::set_cursor_shape(CursorShape p_shape) { if (cursor_shape == p_shape) |