From d1ec314a03473124ffadf8dd8aea33c317dfc1d0 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 22 May 2023 22:06:40 +0200 Subject: [PATCH] groupbars: conserve VRAM by staticizing textures --- .../decorations/CHyprGroupBarDecoration.cpp | 12 +++++++++-- .../decorations/CHyprGroupBarDecoration.hpp | 21 ++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index c2a65f56..1db7952c 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -3,6 +3,11 @@ #include #include +// shared things to conserve VRAM +static std::deque> m_dpTitleTextures; +static CTexture m_tGradientActive; +static CTexture m_tGradientInactive; + CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) { m_pWindow = pWindow; } @@ -166,8 +171,11 @@ void CHyprGroupBarDecoration::clearUnusedTextures() { for (auto& tex : m_dpTitleTextures | std::views::reverse) { bool found = false; - for (auto& w : m_dwGroupMembers) { - if (tex->szContent == w->m_szTitle && tex->pWindowOwner == w) { + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_sGroupData.pNextWindow) + continue; + + if (tex->szContent == w->m_szTitle && tex->pWindowOwner == w.get()) { found = true; break; } diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 3a0fec27..d8b0f46a 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -33,21 +33,18 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration { virtual SWindowDecorationExtents getWindowDecorationReservedArea(); private: - SWindowDecorationExtents m_seExtents; + SWindowDecorationExtents m_seExtents; - CWindow* m_pWindow = nullptr; + CWindow* m_pWindow = nullptr; - Vector2D m_vLastWindowPos; - Vector2D m_vLastWindowSize; + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; - std::deque m_dwGroupMembers; - std::deque> m_dpTitleTextures; + std::deque m_dwGroupMembers; - CTitleTex* textureFromTitle(const std::string&); - void clearUnusedTextures(); - void invalidateTextures(); + CTitleTex* textureFromTitle(const std::string&); + void clearUnusedTextures(); + void invalidateTextures(); - void refreshGradients(); - CTexture m_tGradientActive; - CTexture m_tGradientInactive; + void refreshGradients(); }; \ No newline at end of file