summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTerminalJack <TerminalJack@sbcglobal.net>2019-11-06 20:18:55 -0600
committerRĂ©mi Verschelde <rverschelde@gmail.com>2019-12-04 11:14:21 +0100
commite1dda5195cb2b8620a61740e8491cbb243aa653c (patch)
tree82a09611dfef0b3855b880f970ec9af7563f4fb1 /core
parent10481046e52cbb7a90dd084fc51633388ba7ea6e (diff)
Added support for vertical syncing via the Windows OS compositor (DWM.)
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp14
-rw-r--r--core/bind/core_bind.h3
-rw-r--r--core/os/os.cpp8
-rw-r--r--core/os/os.h10
4 files changed, 34 insertions, 1 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1544503045..4c8dcc20ea 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -584,6 +584,15 @@ bool _OS::is_vsync_enabled() const {
return OS::get_singleton()->is_vsync_enabled();
}
+void _OS::set_vsync_via_compositor(bool p_enable) {
+ OS::get_singleton()->set_vsync_via_compositor(p_enable);
+}
+
+bool _OS::is_vsync_via_compositor_enabled() const {
+
+ return OS::get_singleton()->is_vsync_via_compositor_enabled();
+}
+
_OS::PowerState _OS::get_power_state() {
return _OS::PowerState(OS::get_singleton()->get_power_state());
}
@@ -1335,6 +1344,9 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync);
ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled);
+ ClassDB::bind_method(D_METHOD("set_vsync_via_compositor", "enable"), &_OS::set_vsync_via_compositor);
+ ClassDB::bind_method(D_METHOD("is_vsync_via_compositor_enabled"), &_OS::is_vsync_via_compositor_enabled);
+
ClassDB::bind_method(D_METHOD("has_feature", "tag_name"), &_OS::has_feature);
ClassDB::bind_method(D_METHOD("get_power_state"), &_OS::get_power_state);
@@ -1349,6 +1361,7 @@ void _OS::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen"), "set_current_screen", "get_current_screen");
ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_enabled"), "set_use_vsync", "is_vsync_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_via_compositor"), "set_vsync_via_compositor", "is_vsync_via_compositor_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_screen_on"), "set_keep_screen_on", "is_keep_screen_on");
@@ -1371,6 +1384,7 @@ void _OS::_bind_methods() {
ADD_PROPERTY_DEFAULT("current_screen", 0);
ADD_PROPERTY_DEFAULT("exit_code", 0);
ADD_PROPERTY_DEFAULT("vsync_enabled", true);
+ ADD_PROPERTY_DEFAULT("vsync_via_compositor", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
ADD_PROPERTY_DEFAULT("keep_screen_on", true);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 18182860c6..d57da36ca5 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -345,6 +345,9 @@ public:
void set_use_vsync(bool p_enable);
bool is_vsync_enabled() const;
+ void set_vsync_via_compositor(bool p_enable);
+ bool is_vsync_via_compositor_enabled() const;
+
PowerState get_power_state();
int get_power_seconds_left();
int get_power_percent_left();
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 25889de1b3..2d61417b4f 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -572,6 +572,14 @@ bool OS::is_vsync_enabled() const {
return _use_vsync;
}
+void OS::set_vsync_via_compositor(bool p_enable) {
+ _vsync_via_compositor = p_enable;
+}
+
+bool OS::is_vsync_via_compositor_enabled() const {
+ return _vsync_via_compositor;
+}
+
OS::PowerState OS::get_power_state() {
return POWERSTATE_UNKNOWN;
}
diff --git a/core/os/os.h b/core/os/os.h
index 687ccaaba5..26db629d7c 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -60,6 +60,9 @@ class OS {
bool _allow_hidpi;
bool _allow_layered;
bool _use_vsync;
+ bool _vsync_via_compositor;
+
+ char *last_error;
void *_stack_bottom;
@@ -98,9 +101,10 @@ public:
bool maximized;
bool always_on_top;
bool use_vsync;
+ bool vsync_via_compositor;
bool layered;
float get_aspect() const { return (float)width / (float)height; }
- VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_always_on_top = false, bool p_use_vsync = false) {
+ VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_always_on_top = false, bool p_use_vsync = false, bool p_vsync_via_compositor = false) {
width = p_width;
height = p_height;
fullscreen = p_fullscreen;
@@ -109,6 +113,7 @@ public:
maximized = p_maximized;
always_on_top = p_always_on_top;
use_vsync = p_use_vsync;
+ vsync_via_compositor = p_vsync_via_compositor;
layered = false;
}
};
@@ -507,6 +512,9 @@ public:
//real, actual overridable function to switch vsync, which needs to be called from graphics thread if needed
virtual void _set_use_vsync(bool p_enable) {}
+ void set_vsync_via_compositor(bool p_enable);
+ bool is_vsync_via_compositor_enabled() const;
+
virtual OS::PowerState get_power_state();
virtual int get_power_seconds_left();
virtual int get_power_percent_left();