| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 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 |
|
| 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 |
}; |