From 4e93b2def5f00f944abbd63a8258ee18bd99ff54 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 1 Jan 2025 14:11:21 +0100 Subject: [PATCH] renderer: use a render pass for render modif in client render fixes #8918 --- src/render/OpenGL.hpp | 1 - src/render/Renderer.cpp | 38 ++++++++++---------- src/render/pass/RendererHintsPassElement.cpp | 19 ++++++++++ src/render/pass/RendererHintsPassElement.hpp | 25 +++++++++++++ 4 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 src/render/pass/RendererHintsPassElement.cpp create mode 100644 src/render/pass/RendererHintsPassElement.hpp diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 0b72d438..e73a3119 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -110,7 +110,6 @@ struct SMonitorRenderData { struct SCurrentRenderData { PHLMONITORREF pMonitor; - PHLWORKSPACE pWorkspace = nullptr; Mat3x3 projection; Mat3x3 savedProjection; Mat3x3 monitorProjection; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 391492b0..9aa794b4 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -22,6 +22,7 @@ #include "pass/TexPassElement.hpp" #include "pass/ClearPassElement.hpp" #include "pass/RectPassElement.hpp" +#include "pass/RendererHintsPassElement.hpp" #include "pass/SurfacePassElement.hpp" #include "debug/Log.hpp" @@ -780,18 +781,12 @@ void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, PHLM } void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* time, const Vector2D& translate, const float& scale) { - static auto PDIMSPECIAL = CConfigValue("decoration:dim_special"); - static auto PBLURSPECIAL = CConfigValue("decoration:blur:special"); - static auto PBLUR = CConfigValue("decoration:blur:enabled"); - static auto PRENDERTEX = CConfigValue("misc:disable_hyprland_logo"); - static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); - static auto PXPMODE = CConfigValue("render:xp_mode"); - - SRenderModifData RENDERMODIFDATA; - if (translate != Vector2D{0, 0}) - RENDERMODIFDATA.modifs.emplace_back(std::make_pair<>(SRenderModifData::eRenderModifType::RMOD_TYPE_TRANSLATE, translate)); - if (scale != 1.f) - RENDERMODIFDATA.modifs.emplace_back(std::make_pair<>(SRenderModifData::eRenderModifType::RMOD_TYPE_SCALE, scale)); + static auto PDIMSPECIAL = CConfigValue("decoration:dim_special"); + static auto PBLURSPECIAL = CConfigValue("decoration:blur:special"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PRENDERTEX = CConfigValue("misc:disable_hyprland_logo"); + static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); + static auto PXPMODE = CConfigValue("render:xp_mode"); if (!pMonitor) return; @@ -805,7 +800,19 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA // todo: matrices are buggy atm for some reason, but probably would be preferable in the long run // g_pHyprOpenGL->saveMatrix(); // g_pHyprOpenGL->setMatrixScaleTranslate(translate, scale); - g_pHyprOpenGL->m_RenderData.renderModif = RENDERMODIFDATA; + + SRenderModifData RENDERMODIFDATA; + if (translate != Vector2D{0, 0}) + RENDERMODIFDATA.modifs.emplace_back(std::make_pair<>(SRenderModifData::eRenderModifType::RMOD_TYPE_TRANSLATE, translate)); + if (scale != 1.f) + RENDERMODIFDATA.modifs.emplace_back(std::make_pair<>(SRenderModifData::eRenderModifType::RMOD_TYPE_SCALE, scale)); + + CScopeGuard x([] {}); + + if (!RENDERMODIFDATA.modifs.empty()) { + g_pHyprRenderer->m_sRenderPass.add(makeShared(CRendererHintsPassElement::SData{RENDERMODIFDATA})); + x = CScopeGuard([] { g_pHyprRenderer->m_sRenderPass.add(makeShared(CRendererHintsPassElement::SData{SRenderModifData{}})); }); + } if (!pWorkspace) { // allow rendering without a workspace. In this case, just render layers. @@ -828,8 +835,6 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA renderLayer(ls.lock(), pMonitor, time); } - g_pHyprOpenGL->m_RenderData.renderModif = {}; - return; } @@ -933,7 +938,6 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA renderDragIcon(pMonitor, time); //g_pHyprOpenGL->restoreMatrix(); - g_pHyprOpenGL->m_RenderData.renderModif = {}; } void CHyprRenderer::renderLockscreen(PHLMONITOR pMonitor, timespec* now, const CBox& geometry) { @@ -1436,9 +1440,7 @@ void CHyprRenderer::renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace translate = Vector2D{}; } - g_pHyprOpenGL->m_RenderData.pWorkspace = pWorkspace; renderAllClientsForWorkspace(pMonitor, pWorkspace, now, translate, scale); - g_pHyprOpenGL->m_RenderData.pWorkspace = nullptr; } void CHyprRenderer::sendFrameEventsToWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now) { diff --git a/src/render/pass/RendererHintsPassElement.cpp b/src/render/pass/RendererHintsPassElement.cpp new file mode 100644 index 00000000..8ea79a27 --- /dev/null +++ b/src/render/pass/RendererHintsPassElement.cpp @@ -0,0 +1,19 @@ +#include "RendererHintsPassElement.hpp" +#include "../OpenGL.hpp" + +CRendererHintsPassElement::CRendererHintsPassElement(const CRendererHintsPassElement::SData& data_) : data(data_) { + ; +} + +void CRendererHintsPassElement::draw(const CRegion& damage) { + if (data.renderModif.has_value()) + g_pHyprOpenGL->m_RenderData.renderModif = *data.renderModif; +} + +bool CRendererHintsPassElement::needsLiveBlur() { + return false; +} + +bool CRendererHintsPassElement::needsPrecomputeBlur() { + return false; +} diff --git a/src/render/pass/RendererHintsPassElement.hpp b/src/render/pass/RendererHintsPassElement.hpp new file mode 100644 index 00000000..99ed0759 --- /dev/null +++ b/src/render/pass/RendererHintsPassElement.hpp @@ -0,0 +1,25 @@ +#pragma once +#include "PassElement.hpp" +#include +#include "../OpenGL.hpp" + +class CRendererHintsPassElement : public IPassElement { + public: + struct SData { + std::optional renderModif; + }; + + CRendererHintsPassElement(const SData& data); + virtual ~CRendererHintsPassElement() = default; + + virtual void draw(const CRegion& damage); + virtual bool needsLiveBlur(); + virtual bool needsPrecomputeBlur(); + + virtual const char* passName() { + return "CRendererHintsPassElement"; + } + + private: + SData data; +}; \ No newline at end of file