From ed349e84d26f35a6ef20019f7315ddfd85d1e7ee Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 16 Apr 2026 13:57:27 +0100 Subject: notifications: optimize rendering (#14088) drop cairo, use proper gpu rendering --- src/debug/HyprNotificationOverlay.hpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/debug/HyprNotificationOverlay.hpp') diff --git a/src/debug/HyprNotificationOverlay.hpp b/src/debug/HyprNotificationOverlay.hpp index c2ecbfe0..e8cbf56a 100644 --- a/src/debug/HyprNotificationOverlay.hpp +++ b/src/debug/HyprNotificationOverlay.hpp @@ -7,8 +7,6 @@ #include -#include - enum eIconBackend : uint8_t { ICONS_BACKEND_NONE = 0, ICONS_BACKEND_NF, @@ -27,6 +25,19 @@ static const std::array ICONS_COLORS = {CHyprColor{1. CHyprColor{0, 0, 0, 1.0}}; struct SNotification { + struct SRenderCache { + SP textTex; + SP iconTex; + + Vector2D textSize = {}; + Vector2D iconSize = {}; + + PHLMONITORREF monitor; + std::string fontFamily; + int fontSizePx = -1; + eIconBackend iconBackend = ICONS_BACKEND_NONE; + } cache; + std::string text = ""; CHyprColor color; CTimer started; @@ -46,18 +57,16 @@ class CHyprNotificationOverlay { bool hasAny(); private: + void ensureNotificationCache(SNotification& notif, PHLMONITOR pMonitor, const std::string& fontFamily); + eIconBackend iconBackendForFont(const std::string& fontFamily); CBox drawNotifications(PHLMONITOR pMonitor); CBox m_lastDamage; std::vector> m_notifications; - cairo_surface_t* m_cairoSurface = nullptr; - cairo_t* m_cairo = nullptr; - - PHLMONITORREF m_lastMonitor; - Vector2D m_lastSize = Vector2D(-1, -1); - - SP m_texture; + std::string m_cachedIconBackendFontFamily; + eIconBackend m_cachedIconBackend = ICONS_BACKEND_NONE; + bool m_iconBackendValid = false; }; inline UP g_pHyprNotificationOverlay; -- cgit v1.2.3