Skip to content

Commit

Permalink
renderer: use a render pass for render modif in client render
Browse files Browse the repository at this point in the history
fixes #8918
  • Loading branch information
vaxerski committed Jan 1, 2025
1 parent aff3408 commit 4e93b2d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/render/OpenGL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ struct SMonitorRenderData {

struct SCurrentRenderData {
PHLMONITORREF pMonitor;
PHLWORKSPACE pWorkspace = nullptr;
Mat3x3 projection;
Mat3x3 savedProjection;
Mat3x3 monitorProjection;
Expand Down
38 changes: 20 additions & 18 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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<Hyprlang::FLOAT>("decoration:dim_special");
static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
static auto PRENDERTEX = CConfigValue<Hyprlang::INT>("misc:disable_hyprland_logo");
static auto PBACKGROUNDCOLOR = CConfigValue<Hyprlang::INT>("misc:background_color");
static auto PXPMODE = CConfigValue<Hyprlang::INT>("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<Hyprlang::FLOAT>("decoration:dim_special");
static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
static auto PRENDERTEX = CConfigValue<Hyprlang::INT>("misc:disable_hyprland_logo");
static auto PBACKGROUNDCOLOR = CConfigValue<Hyprlang::INT>("misc:background_color");
static auto PXPMODE = CConfigValue<Hyprlang::INT>("render:xp_mode");

if (!pMonitor)
return;
Expand All @@ -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>(CRendererHintsPassElement::SData{RENDERMODIFDATA}));
x = CScopeGuard([] { g_pHyprRenderer->m_sRenderPass.add(makeShared<CRendererHintsPassElement>(CRendererHintsPassElement::SData{SRenderModifData{}})); });
}

if (!pWorkspace) {
// allow rendering without a workspace. In this case, just render layers.
Expand All @@ -828,8 +835,6 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
renderLayer(ls.lock(), pMonitor, time);
}

g_pHyprOpenGL->m_RenderData.renderModif = {};

return;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 19 additions & 0 deletions src/render/pass/RendererHintsPassElement.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
25 changes: 25 additions & 0 deletions src/render/pass/RendererHintsPassElement.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include "PassElement.hpp"
#include <optional>
#include "../OpenGL.hpp"

class CRendererHintsPassElement : public IPassElement {
public:
struct SData {
std::optional<SRenderModifData> 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;
};

0 comments on commit 4e93b2d

Please sign in to comment.