Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/objectdb_profiler/editor/objectdb_profiler_panel.h
11323 views
1
/**************************************************************************/
2
/* objectdb_profiler_panel.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "data_viewers/snapshot_view.h"
34
#include "snapshot_data.h"
35
36
#include "core/io/dir_access.h"
37
#include "core/templates/lru.h"
38
39
class TabContainer;
40
class Tree;
41
42
// UI loaded by the debugger.
43
class ObjectDBProfilerPanel : public Control {
44
GDCLASS(ObjectDBProfilerPanel, Control);
45
46
protected:
47
static constexpr int SNAPSHOT_CACHE_MAX_SIZE = 10;
48
49
enum OdbProfilerMenuOptions {
50
ODB_MENU_RENAME,
51
ODB_MENU_SHOW_IN_FOLDER,
52
ODB_MENU_DELETE,
53
};
54
55
struct PartialSnapshot {
56
int total_size;
57
Vector<uint8_t> data;
58
};
59
60
int next_request_id = 0;
61
bool awaiting_debug_break = false;
62
bool requested_break_for_snapshot = false;
63
64
Tree *snapshot_list = nullptr;
65
Button *take_snapshot = nullptr;
66
TabContainer *view_tabs = nullptr;
67
PopupMenu *rmb_menu = nullptr;
68
OptionButton *diff_button = nullptr;
69
HashMap<int, PartialSnapshot> partial_snapshots;
70
71
LocalVector<SnapshotView *> views;
72
Ref<GameStateSnapshotRef> current_snapshot;
73
Ref<GameStateSnapshotRef> diff_snapshot;
74
LRUCache<String, Ref<GameStateSnapshotRef>> snapshot_cache;
75
76
void _request_object_snapshot();
77
void _begin_object_snapshot();
78
void _on_debug_breaked(bool p_reallydid, bool p_can_debug, const String &p_reason, bool p_has_stackdump);
79
void _show_selected_snapshot();
80
void _on_snapshot_deselected();
81
Ref<DirAccess> _get_and_create_snapshot_storage_dir();
82
TreeItem *_add_snapshot_button(const String &p_snapshot_file_name, const String &p_full_file_path);
83
void _snapshot_rmb(const Vector2 &p_pos, MouseButton p_button);
84
void _rmb_menu_pressed(int p_tool, bool p_confirm_override);
85
void _update_view_tabs();
86
void _update_diff_items();
87
void _update_enabled_diff_items();
88
void _edit_snapshot_name();
89
void _view_tab_changed(int p_tab_idx);
90
String _to_mb(int p_x);
91
92
public:
93
ObjectDBProfilerPanel();
94
95
void receive_snapshot(int p_request_id);
96
void show_snapshot(const String &p_snapshot_file_name, const String &p_snapshot_diff_file_name);
97
void clear_snapshot(bool p_update_view_tabs = true);
98
Ref<GameStateSnapshotRef> get_snapshot(const String &p_snapshot_file_name);
99
void set_enabled(bool p_enabled);
100
void add_view(SnapshotView *p_to_add);
101
102
bool handle_debug_message(const String &p_message, const Array &p_data, int p_index);
103
};
104
105