aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/debug/HyprDebugOverlay.hpp
blob: 42cdac5539423b8d5d28f520a9c1b8cefad4c3e6 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once

#include "../defines.hpp"
#include "../helpers/Monitor.hpp"
#include "../render/Texture.hpp"
#include <cairo/cairo.h>
#include <map>
#include <deque>

class CHyprRenderer;

class CHyprMonitorDebugOverlay {
  public:
    int  draw(int offset);

    void renderData(PHLMONITOR pMonitor, float durationUs);
    void renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs);
    void frameData(PHLMONITOR pMonitor);

  private:
    std::deque<float>                              m_dLastFrametimes;
    std::deque<float>                              m_dLastRenderTimes;
    std::deque<float>                              m_dLastRenderTimesNoOverlay;
    std::deque<float>                              m_dLastAnimationTicks;
    std::chrono::high_resolution_clock::time_point m_tpLastFrame;
    PHLMONITORREF                                  m_pMonitor;
    CBox                                           m_wbLastDrawnBox;

    friend class CHyprRenderer;
};

class CHyprDebugOverlay {
  public:
    CHyprDebugOverlay();
    void draw();
    void renderData(PHLMONITOR, float durationUs);
    void renderDataNoOverlay(PHLMONITOR, float durationUs);
    void frameData(PHLMONITOR);

  private:
    std::map<PHLMONITORREF, CHyprMonitorDebugOverlay> m_mMonitorOverlays;

    cairo_surface_t*                                  m_pCairoSurface = nullptr;
    cairo_t*                                          m_pCairo        = nullptr;

    SP<CTexture>                                      m_pTexture;

    friend class CHyprMonitorDebugOverlay;
    friend class CHyprRenderer;
};

inline std::unique_ptr<CHyprDebugOverlay> g_pDebugOverlay;