Debian Codegraph @

editor/debugger/editor_visual_profiler.h

raw symbols SCIP
1 /**************************************************************************/
2 /* editor_visual_profiler.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 "scene/gui/box_container.h"
34 #include "scene/gui/button.h"
35 #include "scene/gui/check_box.h"
36 #include "scene/gui/label.h"
37 #include "scene/gui/option_button.h"
38 #include "scene/gui/spin_box.h"
39 #include "scene/gui/split_container.h"
40 #include "scene/gui/texture_rect.h"
41 #include "scene/gui/tree.h"
42
43 class ImageTexture;
44
45 class EditorVisualProfiler : public VBoxContainer {
46 GDCLASS(EditorVisualProfiler, VBoxContainer);
47
48 public:
49 struct Metric {
50 bool valid = false;
51
52 uint64_t frame_number = 0;
53
54 struct Area {
55 String name;
56 Color color_cache;
57 StringName fullpath_cache;
58 float cpu_time = 0;
59 float gpu_time = 0;
60 };
61
62 Vector<Area> areas;
63 };
64
65 enum DisplayTimeMode {
66 DISPLAY_FRAME_TIME,
67 DISPLAY_FRAME_PERCENT,
68 };
69
70 private:
71 Button *activate = nullptr;
72 Button *clear_button = nullptr;
73
74 TextureRect *graph = nullptr;
75 Ref<ImageTexture> graph_texture;
76 Vector<uint8_t> graph_image;
77 Tree *variables = nullptr;
78 HSplitContainer *h_split = nullptr;
79 CheckBox *frame_relative = nullptr;
80 CheckBox *linked = nullptr;
81
82 OptionButton *display_mode = nullptr;
83
84 SpinBox *cursor_metric_edit = nullptr;
85
86 Vector<Metric> frame_metrics;
87 int last_metric = -1;
88
89 int hover_metric = -1;
90
91 StringName selected_area;
92
93 bool updating_frame = false;
94
95 float graph_height_cpu = 1.0f;
96 float graph_height_gpu = 1.0f;
97
98 float graph_limit = 1000.0f / 60;
99
100 String cpu_name;
101 String gpu_name;
102
103 bool seeking = false;
104
105 Timer *frame_delay = nullptr;
106 Timer *plot_delay = nullptr;
107
108 void _update_button_text();
109
110 void _update_frame(bool p_focus_selected = false);
111
112 void _activate_pressed();
113 void _clear_pressed();
114 void _autostart_toggled(bool p_toggled_on);
115
116 String _get_time_as_text(float p_time);
117
118 //void _make_metric_ptrs(Metric &m);
119 void _item_selected();
120
121 void _update_plot();
122
123 void _graph_tex_mouse_exit();
124
125 void _graph_tex_draw();
126 void _graph_tex_input(const Ref<InputEvent> &p_ev);
127
128 int _get_cursor_index() const;
129
130 Color _get_color_from_signature(const StringName &p_signature) const;
131
132 void _cursor_metric_changed(double);
133
134 void _combo_changed(int);
135
136 protected:
137 void _notification(int p_what);
138 static void _bind_methods();
139
140 public:
141 void set_hardware_info(const String &p_cpu_name, const String &p_gpu_name);
142 void add_frame_metric(const Metric &p_metric);
143 void set_enabled(bool p_enable);
144 void set_profiling(bool p_profiling);
145 bool is_profiling();
146 bool is_seeking() { return seeking; }
147 void disable_seeking();
148
149 void clear();
150
151 Vector<Vector<String>> get_data_as_csv() const;
152
153 EditorVisualProfiler();
154 };