summaryrefslogtreecommitdiff
path: root/src/debug/Overlay.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-16 19:47:53 +0100
committerGitHub <noreply@github.com>2026-04-16 19:47:53 +0100
commitb5ea887f072fa055cf23ec389ed81e3ee4c5319a (patch)
tree7e160c3677e9829aa247a56dbc05df98fe084cea /src/debug/Overlay.hpp
parent66ea2e2c9ed4e9257521e6706fbd21feb7e3cc5b (diff)
debug/overlay: optimize rendering, cleanup and nicetify (#14097)
optimizes the rendering, drops direct cairo, fixes up api. Also improves the visuals etc of the overlay
Diffstat (limited to 'src/debug/Overlay.hpp')
-rw-r--r--src/debug/Overlay.hpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/debug/Overlay.hpp b/src/debug/Overlay.hpp
new file mode 100644
index 00000000..02f7f60f
--- /dev/null
+++ b/src/debug/Overlay.hpp
@@ -0,0 +1,88 @@
+#pragma once
+
+#include "../defines.hpp"
+#include "../render/Texture.hpp"
+#include "../helpers/time/Timer.hpp"
+#include <map>
+#include <deque>
+#include <string>
+#include <vector>
+
+namespace Render {
+ class IHyprRenderer;
+ class ITexture;
+}
+
+namespace Debug {
+
+ class CMonitorOverlay {
+ public:
+ int draw(int offset, bool& cacheUpdated);
+ const CBox& lastDrawnBox() const;
+
+ void renderData(PHLMONITOR pMonitor, float durationUs);
+ void renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs);
+ void frameData(PHLMONITOR pMonitor);
+
+ Vector2D size() const;
+
+ private:
+ struct STextLine {
+ std::string text;
+ CHyprColor color;
+ int fontSize = 10;
+ SP<Render::ITexture> texture;
+ };
+
+ struct SMetricData {
+ float avg = 0.F;
+ float min = 0.F;
+ float max = 0.F;
+ float var = 0.F;
+ };
+
+ void updateLine(size_t idx, const std::string& text, const CHyprColor& color, int fontSize, const std::string& fontFamily);
+ void rebuildCache();
+
+ std::deque<float> m_lastFrametimes;
+ std::deque<float> m_lastFPSPerSecond;
+ std::deque<float> m_lastRenderTimes;
+ std::deque<float> m_lastRenderTimesNoOverlay;
+ std::deque<float> m_lastAnimationTicks;
+ std::chrono::high_resolution_clock::time_point m_lastFrame;
+ std::chrono::high_resolution_clock::time_point m_fpsSecondStart;
+ size_t m_framesInCurrentSecond = 0;
+ PHLMONITORREF m_monitor;
+
+ std::vector<STextLine> m_cachedLines;
+ bool m_cacheValid = false;
+ CTimer m_cacheTimer;
+
+ CBox m_lastDrawnBox;
+
+ friend class Render::IHyprRenderer;
+ };
+
+ class COverlay {
+ public:
+ COverlay();
+ void draw();
+ void renderData(PHLMONITOR, float durationUs);
+ void renderDataNoOverlay(PHLMONITOR, float durationUs);
+ void frameData(PHLMONITOR);
+
+ private:
+ std::map<PHLMONITORREF, CMonitorOverlay> m_monitorOverlays;
+ CBox m_lastDrawnBox;
+ CTimer m_frameTimer;
+
+ void createWarningTexture(float maxW);
+ SP<Render::ITexture> m_warningTexture;
+ float m_warningTextureMaxW = 0;
+
+ friend class CHyprMonitorDebugOverlay;
+ friend class Render::IHyprRenderer;
+ };
+
+ UP<COverlay>& overlay();
+}