diff options
author | Vaxry <[email protected]> | 2024-04-30 02:41:27 +0100 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-04-30 02:41:27 +0100 |
commit | 5edc32930d85f5f481160b938965c8bc329487e7 (patch) | |
tree | 3609cb2bebd1f72e17605022e2b9a2dd526377f6 /src/render/OpenGL.cpp | |
parent | 5e6f7b1cdb72b394ad8556bb232ac8a406d851b4 (diff) | |
download | Hyprland-5edc32930d85f5f481160b938965c8bc329487e7.tar.gz Hyprland-5edc32930d85f5f481160b938965c8bc329487e7.zip |
layerSurface: refactor/move to a memory-safe impl
Makes all the pointers smart to avoid memory issues
Refactors layerSurface code to live inside desktop/layersurface
Diffstat (limited to 'src/render/OpenGL.cpp')
-rw-r--r-- | src/render/OpenGL.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 78698505..31625b3b 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -5,6 +5,7 @@ #include "Shaders.hpp" #include <random> #include "../config/ConfigValue.hpp" +#include "../desktop/LayerSurface.hpp" inline void loadGLProc(void* pProc, const char* name) { void* proc = (void*)eglGetProcAddress(name); @@ -1453,7 +1454,7 @@ bool CHyprOpenGLImpl::preBlurQueued() { return !(!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE || !*PBLUR || !m_RenderData.pCurrentMonData->blurFBShouldRender); } -bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(SLayerSurface* pLayer, PHLWINDOW pWindow) { +bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWindow) { static auto PBLURNEWOPTIMIZE = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations"); static auto PBLURXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray"); @@ -1781,7 +1782,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(PHLWINDOW pWindow) { g_pHyprRenderer->m_bRenderingSnapshot = false; } -void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) { +void CHyprOpenGLImpl::makeLayerSnapshot(PHLLS pLayer) { // we trust the window is valid. const auto PMONITOR = g_pCompositor->getMonitorFromID(pLayer->monitorID); @@ -1864,38 +1865,35 @@ void CHyprOpenGLImpl::renderSnapshot(PHLWINDOW pWindow) { m_bEndFrame = false; } -void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { +void CHyprOpenGLImpl::renderSnapshot(PHLLS pLayer) { RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!"); - const auto PLAYER = *pLayer; - auto it = m_mLayerFramebuffers.begin(); - for (; it != m_mLayerFramebuffers.end(); it++) { - if (it->first == PLAYER) { - break; - } - } + if (!m_mLayerFramebuffers.contains(pLayer)) + return; - if (it == m_mLayerFramebuffers.end() || !it->second.m_cTex.m_iTexID) + const auto FBDATA = &m_mLayerFramebuffers.at(pLayer); + + if (!FBDATA->m_cTex.m_iTexID) return; - const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID); + const auto PMONITOR = g_pCompositor->getMonitorFromID(pLayer->monitorID); CBox layerBox; // some mafs to figure out the correct box // the originalClosedPos is relative to the monitor's pos - Vector2D scaleXY = Vector2D((PMONITOR->scale * PLAYER->realSize.value().x / (PLAYER->geometry.w * PMONITOR->scale)), - (PMONITOR->scale * PLAYER->realSize.value().y / (PLAYER->geometry.h * PMONITOR->scale))); + Vector2D scaleXY = Vector2D((PMONITOR->scale * pLayer->realSize.value().x / (pLayer->geometry.w * PMONITOR->scale)), + (PMONITOR->scale * pLayer->realSize.value().y / (pLayer->geometry.h * PMONITOR->scale))); layerBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x; layerBox.height = PMONITOR->vecTransformedSize.y * scaleXY.y; - layerBox.x = ((PLAYER->realPosition.value().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - (((PLAYER->geometry.x - PMONITOR->vecPosition.x) * PMONITOR->scale) * scaleXY.x); - layerBox.y = ((PLAYER->realPosition.value().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - (((PLAYER->geometry.y - PMONITOR->vecPosition.y) * PMONITOR->scale) * scaleXY.y); + layerBox.x = ((pLayer->realPosition.value().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - (((pLayer->geometry.x - PMONITOR->vecPosition.x) * PMONITOR->scale) * scaleXY.x); + layerBox.y = ((pLayer->realPosition.value().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - (((pLayer->geometry.y - PMONITOR->vecPosition.y) * PMONITOR->scale) * scaleXY.y); CRegion fakeDamage{0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y}; m_bEndFrame = true; - renderTextureInternalWithDamage(it->second.m_cTex, &layerBox, PLAYER->alpha.value(), &fakeDamage, 0); + renderTextureInternalWithDamage(FBDATA->m_cTex, &layerBox, pLayer->alpha.value(), &fakeDamage, 0); m_bEndFrame = false; } |