From 65837973051e2aea43019fb5c20ec4a1debf0bcb Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sun, 6 Feb 2022 17:18:44 +0100 Subject: [Debugger] Move servers-related behaviours to ServersDebugger. Forcing draw during debug break is now handled by ServersDebugger, and only happens when the proper message is sent from the EditorDebugger ("servers:draw"). In a similar way, briging the window in foreground is now also handled by ServersDebugger upon receiving "servers:foreground" which is sent by the EditorDebugger when resuming from a break ("continue"). --- servers/debugger/servers_debugger.cpp | 16 ++++++++++++++++ servers/debugger/servers_debugger.h | 3 +++ 2 files changed, 19 insertions(+) (limited to 'servers/debugger') diff --git a/servers/debugger/servers_debugger.cpp b/servers/debugger/servers_debugger.cpp index a0f415eb94..d1391937d9 100644 --- a/servers/debugger/servers_debugger.cpp +++ b/servers/debugger/servers_debugger.cpp @@ -395,8 +395,24 @@ void ServersDebugger::deinitialize() { Error ServersDebugger::_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) { ERR_FAIL_COND_V(!singleton, ERR_BUG); + r_captured = true; if (p_cmd == "memory") { singleton->_send_resource_usage(); + } else if (p_cmd == "draw") { // Forced redraw. + // For camera override to stay live when the game is paused from the editor. + double delta = 0.0; + if (singleton->last_draw_time) { + delta = (OS::get_singleton()->get_ticks_usec() - singleton->last_draw_time) / 1000000.0; + } + singleton->last_draw_time = OS::get_singleton()->get_ticks_usec(); + RenderingServer::get_singleton()->sync(); + if (RenderingServer::get_singleton()->has_changed()) { + RenderingServer::get_singleton()->draw(true, delta); + } + } else if (p_cmd == "foreground") { + singleton->last_draw_time = 0.0; + DisplayServer::get_singleton()->window_move_to_foreground(); + singleton->servers_profiler->skip_frame(); } else { r_captured = false; } diff --git a/servers/debugger/servers_debugger.h b/servers/debugger/servers_debugger.h index 3a020e0633..d1c55dc690 100644 --- a/servers/debugger/servers_debugger.h +++ b/servers/debugger/servers_debugger.h @@ -33,6 +33,8 @@ #include "core/debugger/debugger_marshalls.h" +#include "servers/rendering_server.h" + class ServersDebugger { public: // Memory usage @@ -108,6 +110,7 @@ private: class ServersProfiler; class VisualProfiler; + double last_draw_time = 0.0; Ref servers_profiler; Ref visual_profiler; -- cgit v1.2.3