summaryrefslogtreecommitdiff
path: root/src/render/decorations/CHyprGroupBarDecoration.cpp
diff options
context:
space:
mode:
authorUjinT34 <41110182+UjinT34@users.noreply.github.com>2026-03-07 00:44:10 +0300
committerGitHub <noreply@github.com>2026-03-06 21:44:10 +0000
commit4152ac76d0813d9d0f67d2f04653a13fa6e17433 (patch)
treec341f1883cf5a182d32e4ad00192ba8786a9bb75 /src/render/decorations/CHyprGroupBarDecoration.cpp
parenta5858018d896e0e0f0db517f893cd9a0936dd881 (diff)
renderer: refactor Texture, Framebuffer and Renderbuffer (#13437)
Part 1 of the renderer refactors
Diffstat (limited to 'src/render/decorations/CHyprGroupBarDecoration.cpp')
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index beb5efcd..6ce69261 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -13,10 +13,10 @@
#include "../../layout/supplementary/DragController.hpp"
// shared things to conserve VRAM
-static SP<CTexture> m_tGradientActive = makeShared<CTexture>();
-static SP<CTexture> m_tGradientInactive = makeShared<CTexture>();
-static SP<CTexture> m_tGradientLockedActive = makeShared<CTexture>();
-static SP<CTexture> m_tGradientLockedInactive = makeShared<CTexture>();
+static SP<ITexture> m_tGradientActive;
+static SP<ITexture> m_tGradientInactive;
+static SP<ITexture> m_tGradientLockedActive;
+static SP<ITexture> m_tGradientLockedInactive;
constexpr int BAR_TEXT_PAD = 2;
@@ -24,7 +24,16 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(PHLWINDOW pWindow) : IHyprWindo
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
- if (m_tGradientActive->m_texID == 0 && *PENABLED && *PGRADIENTS)
+ if (!m_tGradientActive)
+ m_tGradientActive = g_pHyprRenderer->createTexture();
+ if (!m_tGradientInactive)
+ m_tGradientInactive = g_pHyprRenderer->createTexture();
+ if (!m_tGradientLockedActive)
+ m_tGradientLockedActive = g_pHyprRenderer->createTexture();
+ if (!m_tGradientLockedInactive)
+ m_tGradientLockedInactive = g_pHyprRenderer->createTexture();
+
+ if (!m_tGradientActive->ok() && *PENABLED && *PGRADIENTS)
refreshGroupBarGradients();
}
@@ -196,7 +205,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
if (*PGRADIENTS) {
const auto GRADIENTTEX = (m_dwGroupMembers[WINDOWINDEX] == Desktop::focusState()->window() ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive));
- if (GRADIENTTEX->m_texID) {
+ if (GRADIENTTEX->ok()) {
CTexPassElement::SRenderData data;
data.tex = GRADIENTTEX;
data.blur = blur;
@@ -234,7 +243,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
Vector2D{(m_barWidth - (*PTEXTPADDING * 2)) * pMonitor->m_scale, (*PTITLEFONTSIZE + 2L * BAR_TEXT_PAD) * pMonitor->m_scale}, pMonitor->m_scale))
.get();
- SP<CTexture> titleTex;
+ SP<ITexture> titleTex;
if (m_dwGroupMembers[WINDOWINDEX] == Desktop::focusState()->window())
titleTex = GROUPLOCKED ? pTitleTex->m_texLockedActive : pTitleTex->m_texActive;
else
@@ -307,7 +316,7 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
#undef RENDER_TEXT
}
-static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {
+static void renderGradientTo(SP<ITexture> tex, CGradientValueData* grad) {
if (!Desktop::focusState()->monitor())
return;
@@ -339,15 +348,7 @@ static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {
cairo_surface_flush(CAIROSURFACE);
// copy the data to an OpenGL texture we have
- const auto DATA = cairo_image_surface_get_data(CAIROSURFACE);
- tex->allocate();
- tex->bind();
- tex->setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- tex->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- tex->setTexParameter(GL_TEXTURE_SWIZZLE_R, GL_BLUE);
- tex->setTexParameter(GL_TEXTURE_SWIZZLE_B, GL_RED);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bufferSize.x, bufferSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
+ tex = g_pHyprRenderer->createTexture(CAIROSURFACE);
// delete cairo
cairo_destroy(CAIRO);
@@ -367,13 +368,11 @@ void refreshGroupBarGradients() {
auto* const GROUPCOLACTIVELOCKED = sc<CGradientValueData*>((PGROUPCOLACTIVELOCKED.ptr())->getData());
auto* const GROUPCOLINACTIVELOCKED = sc<CGradientValueData*>((PGROUPCOLINACTIVELOCKED.ptr())->getData());
- g_pHyprRenderer->makeEGLCurrent();
-
- if (m_tGradientActive->m_texID != 0) {
- m_tGradientActive->destroyTexture();
- m_tGradientInactive->destroyTexture();
- m_tGradientLockedActive->destroyTexture();
- m_tGradientLockedInactive->destroyTexture();
+ if (m_tGradientActive && m_tGradientActive->ok()) {
+ m_tGradientActive.reset();
+ m_tGradientInactive.reset();
+ m_tGradientLockedActive.reset();
+ m_tGradientLockedInactive.reset();
}
if (!*PENABLED || !*PGRADIENTS)