diff options
Diffstat (limited to 'platform/uwp')
-rw-r--r-- | platform/uwp/app.cpp | 4 | ||||
-rw-r--r-- | platform/uwp/app.h | 4 | ||||
-rw-r--r-- | platform/uwp/context_egl_uwp.cpp | 7 | ||||
-rw-r--r-- | platform/uwp/context_egl_uwp.h | 6 | ||||
-rw-r--r-- | platform/uwp/detect.py | 18 | ||||
-rw-r--r-- | platform/uwp/export/export.cpp | 85 | ||||
-rw-r--r-- | platform/uwp/export/export.h | 4 | ||||
-rw-r--r-- | platform/uwp/joypad_uwp.cpp | 4 | ||||
-rw-r--r-- | platform/uwp/joypad_uwp.h | 25 | ||||
-rw-r--r-- | platform/uwp/os_uwp.cpp | 58 | ||||
-rw-r--r-- | platform/uwp/os_uwp.h | 30 | ||||
-rw-r--r-- | platform/uwp/platform_config.h | 4 | ||||
-rw-r--r-- | platform/uwp/thread_uwp.cpp | 61 | ||||
-rw-r--r-- | platform/uwp/thread_uwp.h | 59 |
14 files changed, 121 insertions, 248 deletions
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp index 6090d13854..dc4238bdd4 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/uwp/app.h b/platform/uwp/app.h index 5cffe378b1..0b02527dae 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp index 2da6c5897a..bb2a14e9fc 100644 --- a/platform/uwp/context_egl_uwp.cpp +++ b/platform/uwp/context_egl_uwp.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -204,7 +204,8 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) : mEglContext(EGL_NO_CONTEXT), mEglSurface(EGL_NO_SURFACE), driver(p_driver), - window(p_window) {} + window(p_window), + vsync(false) {} ContextEGL_UWP::~ContextEGL_UWP() { cleanup(); diff --git a/platform/uwp/context_egl_uwp.h b/platform/uwp/context_egl_uwp.h index 6f333b8e6a..974faa3ac7 100644 --- a/platform/uwp/context_egl_uwp.h +++ b/platform/uwp/context_egl_uwp.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -35,7 +35,7 @@ #include <EGL/egl.h> -#include "core/error_list.h" +#include "core/error/error_list.h" #include "core/os/os.h" using namespace Windows::UI::Core; diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 669bfe6814..fda8fdec66 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -30,7 +30,6 @@ def get_opts(): def get_flags(): - return [ ("tools", False), ("xaudio2", True), @@ -39,7 +38,6 @@ def get_flags(): def configure(env): - env.msvc = True if env["bits"] != "default": @@ -65,12 +63,14 @@ def configure(env): env.Append(CCFLAGS=["/MD"]) env.Append(CPPDEFINES=["DEBUG_ENABLED"]) env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) + env.AppendUnique(CPPDEFINES=["WINDOWS_SUBSYSTEM_CONSOLE"]) elif env["target"] == "debug": env.Append(CCFLAGS=["/Zi"]) env.Append(CCFLAGS=["/MDd"]) - env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) + env.AppendUnique(CPPDEFINES=["WINDOWS_SUBSYSTEM_CONSOLE"]) env.Append(LINKFLAGS=["/DEBUG"]) ## Compiler configuration @@ -78,6 +78,9 @@ def configure(env): env["ENV"] = os.environ vc_base_path = os.environ["VCTOOLSINSTALLDIR"] if "VCTOOLSINSTALLDIR" in os.environ else os.environ["VCINSTALLDIR"] + # Force to use Unicode encoding + env.AppendUnique(CCFLAGS=["/utf-8"]) + # ANGLE angle_root = os.getenv("ANGLE_SRC_PATH") env.Prepend(CPPPATH=[angle_root + "/include"]) @@ -120,7 +123,9 @@ def configure(env): print("Compiled program architecture will be a x86 executable. (forcing bits=32).") else: print( - "Failed to detect MSVC compiler architecture version... Defaulting to 32-bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + "Failed to detect MSVC compiler architecture version... Defaulting to 32-bit executable settings" + " (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture" + " this build is compiled for. You should check your settings/compilation setup." ) env["bits"] = "32" @@ -160,7 +165,10 @@ def configure(env): env.Append(CPPFLAGS=["/AI", vc_base_path + "lib/x86/store/references"]) env.Append( - CCFLAGS='/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'.split() + CCFLAGS=( + '/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /WX-' + " /Zc:forScope /Gd /EHsc /nologo".split() + ) ) env.Append(CPPDEFINES=["_UNICODE", "UNICODE", ("WINAPI_FAMILY", "WINAPI_FAMILY_APP")]) env.Append(CXXFLAGS=["/ZW"]) diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index db42908f89..1aad2bfa1a 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -29,14 +29,15 @@ /*************************************************************************/ #include "export.h" -#include "core/bind/core_bind.h" + +#include "core/config/project_settings.h" +#include "core/core_bind.h" #include "core/crypto/crypto_core.h" #include "core/io/marshalls.h" #include "core/io/zip_io.h" -#include "core/object.h" +#include "core/object/class_db.h" #include "core/os/dir_access.h" #include "core/os/file_access.h" -#include "core/project_settings.h" #include "core/version.h" #include "editor/editor_export.h" #include "editor/editor_node.h" @@ -107,7 +108,7 @@ class AppxPackager { struct BlockHash { String base64_hash; - size_t compressed_size; + size_t compressed_size = 0; }; struct FileMeta { @@ -119,12 +120,10 @@ class AppxPackager { Vector<BlockHash> hashes; uLong file_crc32 = 0; ZPOS64_T zip_offset = 0; - - FileMeta() {} }; String progress_task; - FileAccess *package; + FileAccess *package = nullptr; Set<String> mime_types; @@ -249,7 +248,7 @@ void AppxPackager::make_content_types(const String &p_path) { Map<String, String> types; for (int i = 0; i < file_metadata.size(); i++) { - String ext = file_metadata[i].name.get_extension(); + String ext = file_metadata[i].name.get_extension().to_lower(); if (types.has(ext)) { continue; @@ -642,7 +641,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { }; bool _valid_resource_name(const String &p_name) const { - if (p_name.empty()) { + if (p_name.is_empty()) { return false; } if (p_name.ends_with(".")) { @@ -688,7 +687,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { } bool _valid_bgcolor(const String &p_color) const { - if (p_color.empty()) { + if (p_color.is_empty()) { return true; } if (p_color.begins_with("#") && p_color.is_valid_html_color()) { @@ -743,23 +742,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { // TODO: Add resource creation or image rescaling to enable other scales: // 1.25, 1.5, 2.0 - real_t scales[] = { 1.0 }; - bool valid_w = false; - bool valid_h = false; - - for (int i = 0; i < 1; i++) { - int w = ceil(p_width * scales[i]); - int h = ceil(p_height * scales[i]); - - if (w == p_image->get_width()) { - valid_w = true; - } - if (h == p_image->get_height()) { - valid_h = true; - } - } - - return valid_w && valid_h; + return p_width == p_image->get_width() && p_height == p_image->get_height(); } Vector<uint8_t> _fix_manifest(const Ref<EditorExportPreset> &p_preset, const Vector<uint8_t> &p_template, bool p_give_internet) const { @@ -777,10 +760,10 @@ class EditorExportPlatformUWP : public EditorExportPlatform { result = result.replace("$version_string$", version); Platform arch = (Platform)(int)p_preset->get("architecture/target"); - String architecture = arch == ARM ? "arm" : arch == X86 ? "x86" : "x64"; + String architecture = arch == ARM ? "arm" : (arch == X86 ? "x86" : "x64"); result = result.replace("$architecture$", architecture); - result = result.replace("$display_name$", String(p_preset->get("package/display_name")).empty() ? (String)ProjectSettings::get_singleton()->get("application/config/name") : String(p_preset->get("package/display_name"))); + result = result.replace("$display_name$", String(p_preset->get("package/display_name")).is_empty() ? (String)ProjectSettings::get_singleton()->get("application/config/name") : String(p_preset->get("package/display_name"))); result = result.replace("$publisher_display_name$", p_preset->get("package/publisher_display_name")); result = result.replace("$app_description$", p_preset->get("package/description")); @@ -799,7 +782,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { } String show_name_on_tiles = ""; - if (!name_on_tiles.empty()) { + if (!name_on_tiles.is_empty()) { show_name_on_tiles = "<uap:ShowNameOnTiles>\n" + name_on_tiles + " </uap:ShowNameOnTiles>"; } @@ -820,7 +803,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { } String rotation_preference = ""; - if (!rotations.empty()) { + if (!rotations.is_empty()) { rotation_preference = "<uap:InitialRotationPreference>\n" + rotations + " </uap:InitialRotationPreference>"; } @@ -854,7 +837,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { } String capabilities_string = "<Capabilities />"; - if (!capabilities_elements.empty()) { + if (!capabilities_elements.is_empty()) { capabilities_string = "<Capabilities>\n" + capabilities_elements + " </Capabilities>"; } @@ -977,7 +960,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { return true; } - static Error save_appx_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) { + static Error save_appx_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { AppxPackager *packager = (AppxPackager *)p_userdata; String dst_path = p_path.replace_first("res://", "game/"); @@ -985,24 +968,24 @@ class EditorExportPlatformUWP : public EditorExportPlatform { } public: - virtual String get_name() const { - return "Windows Universal"; + virtual String get_name() const override { + return "UWP"; } - virtual String get_os_name() const { + virtual String get_os_name() const override { return "UWP"; } - virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const { + virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override { List<String> list; list.push_back("appx"); return list; } - virtual Ref<Texture2D> get_logo() const { + virtual Ref<Texture2D> get_logo() const override { return logo; } - virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { + virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override { r_features->push_back("s3tc"); r_features->push_back("etc"); switch ((int)p_preset->get("architecture/target")) { @@ -1018,7 +1001,10 @@ public: } } - virtual void get_export_options(List<ExportOption> *r_options) { + virtual void get_export_options(List<ExportOption> *r_options) override { + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "architecture/target", PROPERTY_HINT_ENUM, "arm,x86,x64"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); @@ -1060,9 +1046,6 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_wide310x150"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square310x310"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); - // Capabilities const char **basic = uwp_capabilities; while (*basic) { @@ -1083,7 +1066,7 @@ public: } } - virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { + virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override { String err; bool valid = false; @@ -1193,10 +1176,10 @@ public: return valid; } - virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) { + virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override { String src_appx; - EditorProgress ep("export", "Exporting for Windows Universal", 7, true); + EditorProgress ep("export", "Exporting for UWP", 7, true); if (p_debug) { src_appx = p_preset->get("custom_template/debug"); @@ -1428,18 +1411,18 @@ public: args.push_back(cert_pass); args.push_back(p_path); - OS::get_singleton()->execute(signtool_path, args, true); + OS::get_singleton()->execute(signtool_path, args); #endif // WINDOWS_ENABLED return OK; } - virtual void get_platform_features(List<String> *r_features) { + virtual void get_platform_features(List<String> *r_features) override { r_features->push_back("pc"); r_features->push_back("UWP"); } - virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) override { } EditorExportPlatformUWP() { diff --git a/platform/uwp/export/export.h b/platform/uwp/export/export.h index 1a1555d8ee..bc23cad38c 100644 --- a/platform/uwp/export/export.h +++ b/platform/uwp/export/export.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index 4fdfde9673..5da90db49d 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h index 13f246a438..5df4a211ac 100644 --- a/platform/uwp/joypad_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -58,21 +58,12 @@ private: struct ControllerDevice { Windows::Gaming::Input::IGameController ^ controller_reference; - int id; - bool connected; - ControllerType type; - float ff_timestamp; - float ff_end_timestamp; - bool vibrating; - - ControllerDevice() { - id = -1; - connected = false; - type = ControllerType::GAMEPAD_CONTROLLER; - ff_timestamp = 0.0f; - ff_end_timestamp = 0.0f; - vibrating = false; - } + int id = -1; + bool connected = false; + ControllerType type = ControllerType::GAMEPAD_CONTROLLER; + float ff_timestamp = 0; + float ff_end_timestamp = 0; + bool vibrating = false; }; ControllerDevice controllers[MAX_CONTROLLERS]; diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 7bd67d3726..fa97948395 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -33,21 +33,17 @@ #include "os_uwp.h" +#include "core/config/project_settings.h" #include "core/io/marshalls.h" -#include "core/project_settings.h" -#include "drivers/gles2/rasterizer_gles2.h" #include "drivers/unix/ip_unix.h" #include "drivers/windows/dir_access_windows.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/mutex_windows.h" -#include "drivers/windows/rw_lock_windows.h" #include "drivers/windows/semaphore_windows.h" #include "main/main.h" #include "platform/windows/windows_terminal_logger.h" #include "servers/audio_server.h" -#include "servers/rendering/rendering_server_raster.h" -#include "servers/rendering/rendering_server_wrap_mt.h" -#include "thread_uwp.h" +#include "servers/rendering/rendering_server_default.h" #include <ppltasks.h> #include <wrl.h> @@ -132,9 +128,6 @@ void OS_UWP::initialize_core() { //RedirectIOToConsole(); - ThreadUWP::make_default(); - RWLockWindows::make_default(); - FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_FILESYSTEM); @@ -157,10 +150,6 @@ void OS_UWP::initialize_core() { cursor_shape = CURSOR_ARROW; } -bool OS_UWP::can_draw() const { - return !minimized; -}; - void OS_UWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) { window = p_window; } @@ -241,7 +230,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a set_video_mode(vm); - rendering_server = memnew(RenderingServerRaster); + rendering_server = memnew(RenderingServerDefault); // FIXME: Reimplement threaded rendering if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { rendering_server = memnew(RenderingServerWrapMT(rendering_server, false)); @@ -297,7 +286,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a void OS_UWP::set_clipboard(const String &p_text) { DataPackage ^ clip = ref new DataPackage(); clip->RequestedOperation = DataPackageOperation::Copy; - clip->SetText(ref new Platform::String((const wchar_t *)p_text.c_str())); + clip->SetText(ref new Platform::String((LPCWSTR)(p_text.utf16().get_data()))); Clipboard::SetContent(clip); }; @@ -347,8 +336,8 @@ void OS_UWP::finalize_core() { } void OS_UWP::alert(const String &p_alert, const String &p_title) { - Platform::String ^ alert = ref new Platform::String(p_alert.c_str()); - Platform::String ^ title = ref new Platform::String(p_title.c_str()); + Platform::String ^ alert = ref new Platform::String((LPCWSTR)(p_alert.utf16().get_data())); + Platform::String ^ title = ref new Platform::String((LPCWSTR)(p_title.utf16().get_data())); MessageDialog ^ msg = ref new MessageDialog(alert, title); @@ -535,11 +524,28 @@ void OS_UWP::delay_usec(uint32_t p_usec) const { uint64_t OS_UWP::get_ticks_usec() const { uint64_t ticks; - uint64_t time; + // This is the number of clock ticks since start QueryPerformanceCounter((LARGE_INTEGER *)&ticks); + // Divide by frequency to get the time in seconds - time = ticks * 1000000L / ticks_per_second; + // original calculation shown below is subject to overflow + // with high ticks_per_second and a number of days since the last reboot. + // time = ticks * 1000000L / ticks_per_second; + + // we can prevent this by either using 128 bit math + // or separating into a calculation for seconds, and the fraction + uint64_t seconds = ticks / ticks_per_second; + + // compiler will optimize these two into one divide + uint64_t leftover = ticks % ticks_per_second; + + // remainder + uint64_t time = (leftover * 1000000L) / ticks_per_second; + + // seconds + time += seconds * 1000000L; + // Subtract the time at game start to get // the time since the game started time -= ticks_start; @@ -626,7 +632,11 @@ void OS_UWP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c // TODO } -Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { +Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { + return FAILED; +}; + +Error OS_UWP::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { return FAILED; }; @@ -698,7 +708,7 @@ bool OS_UWP::has_virtual_keyboard() const { return UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch; } -void OS_UWP::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length, int p_cursor_start, int p_cursor_end) { +void OS_UWP::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, bool p_multiline, int p_max_input_length, int p_cursor_start, int p_cursor_end) { InputPane ^ pane = InputPane::GetForCurrentView(); pane->TryShow(); } @@ -722,7 +732,7 @@ static String format_error_message(DWORD id) { Error OS_UWP::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { String full_path = "game/" + p_path; - p_library_handle = (void *)LoadPackagedLibrary(full_path.c_str(), 0); + p_library_handle = (void *)LoadPackagedLibrary((LPCWSTR)(full_path.utf16().get_data()), 0); ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + full_path + ", error: " + format_error_message(GetLastError()) + "."); return OK; } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 95359c68b0..a4d3d6d52a 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -35,11 +35,11 @@ #include "core/input/input.h" #include "core/math/transform_2d.h" #include "core/os/os.h" -#include "core/ustring.h" +#include "core/string/ustring.h" #include "drivers/xaudio2/audio_driver_xaudio2.h" #include "joypad_uwp.h" #include "servers/audio_server.h" -#include "servers/rendering/rasterizer.h" +#include "servers/rendering/renderer_compositor.h" #include "servers/rendering_server.h" #include <fcntl.h> @@ -55,13 +55,13 @@ public: CHAR_EVENT_MESSAGE }; - bool alt, shift, control; - MessageType type; - bool pressed; - unsigned int keycode; - unsigned int physical_keycode; - unsigned int unicode; - bool echo; + bool alt = false, shift = false, control = false; + MessageType type = KEY_EVENT_MESSAGE; + bool pressed = false; + unsigned int keycode = 0; + unsigned int physical_keycode = 0; + unsigned int unicode = 0; + bool echo = false; CorePhysicalKeyStatus status; }; @@ -194,13 +194,13 @@ public: virtual TimeZoneInfo get_time_zone_info() const; virtual uint64_t get_unix_time() const; - virtual bool can_draw() const; virtual Error set_cwd(const String &p_cwd); virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); + virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); + virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr); virtual Error kill(const ProcessID &p_pid); virtual bool has_environment(const String &p_var) const; @@ -234,7 +234,7 @@ public: virtual bool has_touchscreen_ui_hint() const; virtual bool has_virtual_keyboard() const; - virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1); + virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1); virtual void hide_virtual_keyboard(); virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false); @@ -245,7 +245,7 @@ public: void run(); - virtual bool get_swap_ok_cancel() { return true; } + virtual bool get_swap_cancel_ok() { return true; } void input_event(const Ref<InputEvent> &p_event); diff --git a/platform/uwp/platform_config.h b/platform/uwp/platform_config.h index 09a16614e0..481f583f6f 100644 --- a/platform/uwp/platform_config.h +++ b/platform/uwp/platform_config.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/uwp/thread_uwp.cpp b/platform/uwp/thread_uwp.cpp deleted file mode 100644 index 8e7bb144be..0000000000 --- a/platform/uwp/thread_uwp.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************/ -/* thread_uwp.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "thread_uwp.h" - -#include "core/os/memory.h" - -Thread *ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback, void *p_user, const Settings &) { - ThreadUWP *thread = memnew(ThreadUWP); - - std::thread new_thread(p_callback, p_user); - std::swap(thread->thread, new_thread); - - return thread; -}; - -Thread::ID ThreadUWP::get_thread_id_func_uwp() { - return std::hash<std::thread::id>()(std::this_thread::get_id()); -}; - -void ThreadUWP::wait_to_finish_func_uwp(Thread *p_thread) { - ThreadUWP *tp = static_cast<ThreadUWP *>(p_thread); - tp->thread.join(); -}; - -Thread::ID ThreadUWP::get_id() const { - return std::hash<std::thread::id>()(thread.get_id()); -}; - -void ThreadUWP::make_default() { - create_func = create_func_uwp; - get_thread_id_func = get_thread_id_func_uwp; - wait_to_finish_func = wait_to_finish_func_uwp; -}; diff --git a/platform/uwp/thread_uwp.h b/platform/uwp/thread_uwp.h deleted file mode 100644 index 9b2a2590a8..0000000000 --- a/platform/uwp/thread_uwp.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* thread_uwp.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef THREAD_UWP_H -#define THREAD_UWP_H - -#ifdef UWP_ENABLED - -#include "core/os/thread.h" - -#include <thread> - -class ThreadUWP : public Thread { - std::thread thread; - - static Thread *create_func_uwp(ThreadCreateCallback p_callback, void *, const Settings &); - static ID get_thread_id_func_uwp(); - static void wait_to_finish_func_uwp(Thread *p_thread); - - ThreadUWP() {} - -public: - virtual ID get_id() const; - - static void make_default(); - - ~ThreadUWP() {} -}; - -#endif // UWP_ENABLED - -#endif // THREAD_UWP_H |