1// Graph is a simple, thread-safe class to draw debug informations about FPS, CPU time per frame, Ping, etc.
2// It's not optimized, so should be used only as debugging tool
3
4#ifndef GRAPH_H
5#define GRAPH_H
6
7#include <framework/global.h>
8
9enum GraphType {
10 GRAPH_TOTAL_FRAME_TIME = 0,
11 GRAPH_CPU_FRAME_TIME = 1,
12 GRAPH_GPU_CALLS = 2,
13 GRAPH_GPU_DRAWS = 3,
14 GRAPH_PROCESSING_POLL = 4,
15 GRAPH_GRAPHICS_POLL = 5,
16 GRAPH_DISPATCHER_EVENTS = 6,
17 GRAPH_GRAPHICS_EVENTS = 7,
18 GRAPH_LATENCY = 8,
19 GRAPH_LAST = GRAPH_LATENCY
20};
21
22class Graph
23{
24 static constexpr int MAX_CAPACITY = 512;
25public:
26 Graph(const std::string& name, size_t capacity = 100);
27
28 void draw(const Rect& dest);
29
30 void clear();
31 void addValue(int value, bool ignoreSmallValues = false);
32
33private:
34 std::string m_name;
35 size_t m_capacity;
36 size_t m_ignores = 0;
37 std::deque<int> m_values;
38 std::mutex m_mutex;
39};
40
41extern Graph g_graphs[GRAPH_LAST + 1];
42
43#endif