From b5ea887f072fa055cf23ec389ed81e3ee4c5319a Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:47:53 +0100 Subject: 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 --- src/debug/Overlay.hpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/debug/Overlay.hpp (limited to 'src/debug/Overlay.hpp') 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 +#include +#include +#include + +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 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 m_lastFrametimes; + std::deque m_lastFPSPerSecond; + std::deque m_lastRenderTimes; + std::deque m_lastRenderTimesNoOverlay; + std::deque 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 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 m_monitorOverlays; + CBox m_lastDrawnBox; + CTimer m_frameTimer; + + void createWarningTexture(float maxW); + SP m_warningTexture; + float m_warningTextureMaxW = 0; + + friend class CHyprMonitorDebugOverlay; + friend class Render::IHyprRenderer; + }; + + UP& overlay(); +} -- cgit v1.2.3