| 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 "core/templates/hash_map.h" |
| 34 |
#include "main/performance.h" |
| 35 |
#include "scene/gui/control.h" |
| 36 |
#include "scene/gui/label.h" |
| 37 |
#include "scene/gui/split_container.h" |
| 38 |
#include "scene/gui/tree.h" |
| 39 |
|
| 40 |
class EditorPerformanceProfiler : public HSplitContainer { |
| 41 |
GDCLASS(EditorPerformanceProfiler, HSplitContainer); |
| 42 |
|
| 43 |
private: |
| 44 |
class Monitor { |
| 45 |
public: |
| 46 |
String name; |
| 47 |
String base; |
| 48 |
List<float> history; |
| 49 |
float max = 0.0f; |
| 50 |
TreeItem *item = nullptr; |
| 51 |
Performance::MonitorType type = Performance::MONITOR_TYPE_QUANTITY; |
| 52 |
int frame_index = 0; |
| 53 |
|
| 54 |
Monitor() {} |
| 55 |
Monitor(const String &p_name, const String &p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item); |
| 56 |
void reset(); |
| 57 |
}; |
| 58 |
|
| 59 |
HashMap<StringName, Monitor> monitors; |
| 60 |
|
| 61 |
HashMap<StringName, TreeItem *> base_map; |
| 62 |
Tree *monitor_tree = nullptr; |
| 63 |
Control *monitor_draw = nullptr; |
| 64 |
Label *info_message = nullptr; |
| 65 |
StringName marker_key; |
| 66 |
int marker_frame = 0; |
| 67 |
const int MARGIN = 4; |
| 68 |
const int POINT_SEPARATION = 5; |
| 69 |
const int MARKER_MARGIN = 2; |
| 70 |
|
| 71 |
String _format_label(float p_value, Performance::MonitorType p_type) const; |
| 72 |
void _update_monitor_value(Monitor *p_monitor, float p_value); |
| 73 |
void _monitor_select(); |
| 74 |
void _monitor_draw(); |
| 75 |
void _build_monitor_tree(); |
| 76 |
TreeItem *_get_monitor_base(const StringName &p_base_name); |
| 77 |
TreeItem *_create_monitor_item(const StringName &p_monitor_name, TreeItem *p_base); |
| 78 |
void _marker_input(const Ref<InputEvent> &p_event); |
| 79 |
|
| 80 |
protected: |
| 81 |
void _notification(int p_what); |
| 82 |
|
| 83 |
public: |
| 84 |
void reset(); |
| 85 |
void update_monitors(const Vector<StringName> &p_names, const PackedInt32Array &p_types); |
| 86 |
void add_profile_frame(const Vector<float> &p_values); |
| 87 |
List<float> *get_monitor_data(const StringName &p_name); |
| 88 |
EditorPerformanceProfiler(); |
| 89 |
}; |