diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-12-16 17:09:25 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-12-16 17:11:02 -0300 |
commit | 652c98a7beb8fc8a8aad5075a673caf21994a2ba (patch) | |
tree | caa203abb2bcdb839f6bc7568d7119aa948120db /servers/visual | |
parent | d03f35f1bc0ecf09d436ebb44356f8add5b95a3e (diff) |
Add epic hack so vsync can be toggled in run-time from script. Fixes #14458.
Call needs to be routed via visual server to reach the proper thread.
Diffstat (limited to 'servers/visual')
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 4 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.cpp | 10 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 6 |
4 files changed, 22 insertions, 0 deletions
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 6b527b5cd1..7bb7d04fcd 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -181,6 +181,10 @@ void VisualServerRaster::set_debug_generate_wireframes(bool p_generate) { VSG::storage->set_debug_generate_wireframes(p_generate); } +void VisualServerRaster::call_set_use_vsync(bool p_enable) { + OS::get_singleton()->_set_use_vsync(p_enable); +} + VisualServerRaster::VisualServerRaster() { VSG::canvas = memnew(VisualServerCanvas); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index a0e79e9d3e..716c1754e1 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -668,6 +668,8 @@ public: virtual bool has_os_feature(const String &p_feature) const; virtual void set_debug_generate_wireframes(bool p_generate); + virtual void call_set_use_vsync(bool p_enable); + VisualServerRaster(); ~VisualServerRaster(); diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index b86a0ae3f6..e55b7a9309 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -158,9 +158,19 @@ void VisualServerWrapMT::finish() { canvas_occluder_polygon_free_cached_ids(); } +void VisualServerWrapMT::set_use_vsync_callback(bool p_enable) { + + singleton_mt->call_set_use_vsync(p_enable); +} + +VisualServerWrapMT *VisualServerWrapMT::singleton_mt = NULL; + VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread) : command_queue(p_create_thread) { + singleton_mt = this; + OS::switch_vsync_function = set_use_vsync_callback; //as this goes to another thread, make sure it goes properly + visual_server = p_contained; create_thread = p_create_thread; thread = NULL; diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index cb6f67474e..0f24521f5d 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -64,6 +64,8 @@ class VisualServerWrapMT : public VisualServer { //#define DEBUG_SYNC + static VisualServerWrapMT *singleton_mt; + #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__)); #else @@ -584,6 +586,10 @@ public: virtual bool has_feature(Features p_feature) const { return visual_server->has_feature(p_feature); } virtual bool has_os_feature(const String &p_feature) const { return visual_server->has_os_feature(p_feature); } + FUNC1(call_set_use_vsync, bool) + + static void set_use_vsync_callback(bool p_enable); + VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread); ~VisualServerWrapMT(); |