diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-03-07 00:44:10 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-06 21:44:10 +0000 |
| commit | 4152ac76d0813d9d0f67d2f04653a13fa6e17433 (patch) | |
| tree | c341f1883cf5a182d32e4ad00192ba8786a9bb75 /src/render/decorations | |
| parent | a5858018d896e0e0f0db517f893cd9a0936dd881 (diff) | |
renderer: refactor Texture, Framebuffer and Renderbuffer (#13437)
Part 1 of the renderer refactors
Diffstat (limited to 'src/render/decorations')
| -rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.cpp | 12 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.cpp | 47 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.hpp | 8 |
3 files changed, 33 insertions, 34 deletions
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index dd82abc5..5e1b6e8a 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -155,9 +155,9 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { g_pHyprOpenGL->m_renderData.currentWindow = m_window; // we'll take the liberty of using this as it should not be used rn - CFramebuffer& alphaFB = g_pHyprOpenGL->m_renderData.pCurrentMonData->mirrorFB; - CFramebuffer& alphaSwapFB = g_pHyprOpenGL->m_renderData.pCurrentMonData->mirrorSwapFB; - auto* LASTFB = g_pHyprOpenGL->m_renderData.currentFB; + auto alphaFB = g_pHyprOpenGL->m_renderData.pCurrentMonData->mirrorFB; + auto alphaSwapFB = g_pHyprOpenGL->m_renderData.pCurrentMonData->mirrorSwapFB; + auto LASTFB = g_pHyprOpenGL->m_renderData.currentFB; fullBox.scale(pMonitor->m_scale).round(); @@ -188,7 +188,7 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { g_pHyprOpenGL->m_renderData.damage.subtract(windowBox.copy().expand(-ROUNDING * pMonitor->m_scale)).intersect(saveDamage); g_pHyprOpenGL->m_renderData.renderModif.applyToRegion(g_pHyprOpenGL->m_renderData.damage); - alphaFB.bind(); + alphaFB->bind(); // build the matte // 10-bit formats have dogshit alpha channels, so we have to use the matte to its fullest. @@ -202,7 +202,7 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { g_pHyprOpenGL->renderRect(windowBox, CHyprColor(0, 0, 0, 1.0), {.round = (ROUNDING + 1 /* This fixes small pixel gaps. */) * pMonitor->m_scale, .roundingPower = ROUNDINGPOWER}); - alphaSwapFB.bind(); + alphaSwapFB->bind(); // alpha swap just has the shadow color. It will be the "texture" to render. g_pHyprOpenGL->renderRect(fullBox, PWINDOW->m_realShadowColor->value().stripA(), {.round = 0}); @@ -213,7 +213,7 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { g_pHyprOpenGL->pushMonitorTransformEnabled(true); g_pHyprOpenGL->setRenderModifEnabled(false); - g_pHyprOpenGL->renderTextureMatte(alphaSwapFB.getTexture(), monbox, alphaFB); + g_pHyprOpenGL->renderTextureMatte(alphaSwapFB->getTexture(), monbox, alphaFB); g_pHyprOpenGL->setRenderModifEnabled(true); g_pHyprOpenGL->popMonitorTransformEnabled(); 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) diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 3e5d3c2d..5c3f4ae5 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -12,10 +12,10 @@ class CTitleTex { CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale); ~CTitleTex() = default; - SP<CTexture> m_texActive; - SP<CTexture> m_texInactive; - SP<CTexture> m_texLockedActive; - SP<CTexture> m_texLockedInactive; + SP<ITexture> m_texActive; + SP<ITexture> m_texInactive; + SP<ITexture> m_texLockedActive; + SP<ITexture> m_texLockedInactive; std::string m_content; PHLWINDOWREF m_windowOwner; |
