1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

[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").
This commit is contained in:
Fabio Alessandrelli
2022-02-06 17:18:44 +01:00
parent 87f4bbd668
commit 6583797305
5 changed files with 23 additions and 13 deletions

View File

@@ -32,7 +32,6 @@
#define DEBUGGER_MARSHARLLS_H #define DEBUGGER_MARSHARLLS_H
#include "core/object/script_language.h" #include "core/object/script_language.h"
#include "servers/rendering_server.h"
struct DebuggerMarshalls { struct DebuggerMarshalls {
struct ScriptStackVariable { struct ScriptStackVariable {

View File

@@ -444,11 +444,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
} }
uint64_t loop_begin_usec = 0;
uint64_t loop_time_sec = 0;
while (is_peer_connected()) { while (is_peer_connected()) {
loop_begin_usec = OS::get_singleton()->get_ticks_usec();
flush_output(); flush_output();
peer->poll(); peer->poll();
@@ -475,7 +471,6 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
} else if (command == "continue") { } else if (command == "continue") {
script_debugger->set_depth(-1); script_debugger->set_depth(-1);
script_debugger->set_lines_left(-1); script_debugger->set_lines_left(-1);
DisplayServer::get_singleton()->window_move_to_foreground();
break; break;
} else if (command == "break") { } else if (command == "break") {
@@ -551,13 +546,6 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
OS::get_singleton()->delay_usec(10000); OS::get_singleton()->delay_usec(10000);
OS::get_singleton()->process_and_drop_events(); OS::get_singleton()->process_and_drop_events();
} }
// This is for the camera override to stay live even when the game is paused from the editor
loop_time_sec = (OS::get_singleton()->get_ticks_usec() - loop_begin_usec) / 1000000.0f;
RenderingServer::get_singleton()->sync();
if (RenderingServer::get_singleton()->has_changed()) {
RenderingServer::get_singleton()->draw(true, loop_time_sec * Engine::get_singleton()->get_time_scale());
}
} }
send_message("debug_exit", Array()); send_message("debug_exit", Array());

View File

@@ -129,6 +129,7 @@ void ScriptEditorDebugger::debug_continue() {
_clear_execution(); _clear_execution();
_put_msg("continue", Array()); _put_msg("continue", Array());
_put_msg("servers:foreground", Array());
} }
void ScriptEditorDebugger::update_tabs() { void ScriptEditorDebugger::update_tabs() {
@@ -834,6 +835,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
msg.push_back(cam->get_far()); msg.push_back(cam->get_far());
_put_msg("scene:override_camera_3D:transform", msg); _put_msg("scene:override_camera_3D:transform", msg);
} }
if (breaked) {
_put_msg("servers:draw", Array());
}
} }
const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20;

View File

@@ -395,8 +395,24 @@ void ServersDebugger::deinitialize() {
Error ServersDebugger::_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) { Error ServersDebugger::_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) {
ERR_FAIL_COND_V(!singleton, ERR_BUG); ERR_FAIL_COND_V(!singleton, ERR_BUG);
r_captured = true;
if (p_cmd == "memory") { if (p_cmd == "memory") {
singleton->_send_resource_usage(); 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 { } else {
r_captured = false; r_captured = false;
} }

View File

@@ -33,6 +33,8 @@
#include "core/debugger/debugger_marshalls.h" #include "core/debugger/debugger_marshalls.h"
#include "servers/rendering_server.h"
class ServersDebugger { class ServersDebugger {
public: public:
// Memory usage // Memory usage
@@ -108,6 +110,7 @@ private:
class ServersProfiler; class ServersProfiler;
class VisualProfiler; class VisualProfiler;
double last_draw_time = 0.0;
Ref<ServersProfiler> servers_profiler; Ref<ServersProfiler> servers_profiler;
Ref<VisualProfiler> visual_profiler; Ref<VisualProfiler> visual_profiler;