summaryrefslogtreecommitdiff
path: root/src/render/pass
diff options
context:
space:
mode:
authorUjinT34 <41110182+UjinT34@users.noreply.github.com>2026-03-29 00:41:45 +0300
committerGitHub <noreply@github.com>2026-03-28 21:41:45 +0000
commit38a7f03cf0e5ee116794a78581634ba3dab508fa (patch)
tree969891411b2af4e437a183004018cfc359a3057e /src/render/pass
parentef2e8dfd5f7e6ee55fa7bc48e44974e64938d14a (diff)
renderer: refactor part 7: api fixes (#13631)
Part 7 of ujin's refactors --------- Co-authored-by: Vaxry <vaxry@vaxry.net>
Diffstat (limited to 'src/render/pass')
-rw-r--r--src/render/pass/Pass.cpp71
-rw-r--r--src/render/pass/Pass.hpp60
-rw-r--r--src/render/pass/PassElement.cpp4
-rw-r--r--src/render/pass/PassElement.hpp6
-rw-r--r--src/render/pass/RendererHintsPassElement.hpp5
-rw-r--r--src/render/pass/SurfacePassElement.hpp6
-rw-r--r--src/render/pass/TexPassElement.hpp8
-rw-r--r--src/render/pass/TextureMatteElement.hpp12
8 files changed, 91 insertions, 81 deletions
diff --git a/src/render/pass/Pass.cpp b/src/render/pass/Pass.cpp
index cbf6ea48..a097fd59 100644
--- a/src/render/pass/Pass.cpp
+++ b/src/render/pass/Pass.cpp
@@ -10,6 +10,10 @@
#include "../../render/Renderer.hpp"
#include "../../desktop/state/FocusState.hpp"
#include "../../protocols/core/Compositor.hpp"
+#include "RectPassElement.hpp"
+#include "macros.hpp"
+
+using namespace Render;
bool CRenderPass::empty() const {
return false;
@@ -213,15 +217,10 @@ void CRenderPass::renderDebugData() {
const auto pMonitor = g_pHyprRenderer->m_renderData.pMonitor;
CBox box = {{}, pMonitor->m_transformedSize};
for (const auto& rg : m_occludedRegions) {
- CRectPassElement::SRectData data;
- data.box = box;
- data.color = Colors::RED.modifyA(0.1F);
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), rg);
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{.box = box, .color = Colors::RED.modifyA(0.1F)}, rg);
}
- CRectPassElement::SRectData data;
- data.box = box;
- data.color = Colors::GREEN.modifyA(0.1F);
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), m_totalLiveBlurRegion);
+
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{.box = box, .color = Colors::GREEN.modifyA(0.1F)}, m_totalLiveBlurRegion);
std::unordered_map<CWLSurfaceResource*, float> offsets;
@@ -244,10 +243,7 @@ void CRenderPass::renderDebugData() {
if (box.intersection(CBox{{}, pMonitor->m_size}).empty())
return;
- CRectPassElement::SRectData data;
- data.box = box;
- data.color = color;
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), m_damage);
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{.box = box, .color = color}, m_damage);
if (offsets.contains(surface.get()))
box.translate(Vector2D{0.F, offsets[surface.get()]});
@@ -255,16 +251,16 @@ void CRenderPass::renderDebugData() {
offsets[surface.get()] = 0;
box = {box.pos(), texture->m_size};
- CRectPassElement::SRectData data2;
- data.box = box;
- data.color = color;
- data.round = std::min(5.0, box.size().y);
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data2), m_damage);
- CTexPassElement::SRenderData texData;
- texData.tex = texture;
- texData.box = box;
- g_pHyprRenderer->draw(makeUnique<CTexPassElement>(texData), m_damage);
+ g_pHyprRenderer->draw(
+ CRectPassElement::SRectData{
+ .box = box,
+ .color = color,
+ .round = std::min(5.0, box.size().y),
+ },
+ m_damage);
+
+ g_pHyprRenderer->draw(CTexPassElement::SRenderData{.tex = texture, .box = box}, m_damage);
offsets[surface.get()] += texture->m_size.y;
};
@@ -281,10 +277,7 @@ void CRenderPass::renderDebugData() {
if (hlSurface) {
auto BOX = hlSurface->getSurfaceBoxGlobal();
if (BOX) {
- CRectPassElement::SRectData data;
- data.box = box;
- data.color = CHyprColor{0.8F, 0.8F, 0.2F, 0.4F};
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), m_damage);
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{.box = box, .color = CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}}, m_damage);
}
}
}
@@ -295,13 +288,13 @@ void CRenderPass::renderDebugData() {
DISCARDED_ELEMENTS, pMonitor->m_pixelSize),
Colors::WHITE, 12);
- if (tex) {
- box = CBox{{0.F, pMonitor->m_size.y - tex->m_size.y}, tex->m_size}.scale(pMonitor->m_scale);
- CTexPassElement::SRenderData texData;
- texData.tex = tex;
- texData.box = box;
- g_pHyprRenderer->draw(makeUnique<CTexPassElement>(texData), m_damage);
- }
+ if (tex)
+ g_pHyprRenderer->draw(
+ CTexPassElement::SRenderData{
+ .tex = tex,
+ .box = CBox{{0.F, pMonitor->m_size.y - tex->m_size.y}, tex->m_size}.scale(pMonitor->m_scale),
+ },
+ m_damage);
std::string passStructure;
auto yn = [](const bool val) -> const char* { return val ? "yes" : "no"; };
@@ -315,13 +308,13 @@ void CRenderPass::renderDebugData() {
passStructure.pop_back();
tex = g_pHyprRenderer->renderText(passStructure, Colors::WHITE, 12);
- if (tex) {
- box = CBox{{pMonitor->m_size.x - tex->m_size.x, pMonitor->m_size.y - tex->m_size.y}, tex->m_size}.scale(pMonitor->m_scale);
- CTexPassElement::SRenderData texData;
- texData.tex = tex;
- texData.box = box;
- g_pHyprRenderer->draw(makeUnique<CTexPassElement>(texData), m_damage);
- }
+ if (tex)
+ g_pHyprRenderer->draw(
+ CTexPassElement::SRenderData{
+ .tex = tex,
+ .box = CBox{{pMonitor->m_size.x - tex->m_size.x, pMonitor->m_size.y - tex->m_size.y}, tex->m_size}.scale(pMonitor->m_scale),
+ },
+ m_damage);
}
float CRenderPass::oneBlurRadius() {
diff --git a/src/render/pass/Pass.hpp b/src/render/pass/Pass.hpp
index d407bf3c..5a85d067 100644
--- a/src/render/pass/Pass.hpp
+++ b/src/render/pass/Pass.hpp
@@ -3,40 +3,44 @@
#include "../../defines.hpp"
#include "PassElement.hpp"
-class ITexture;
+class CGradientValueData;
-class CRenderPass {
- public:
- bool empty() const;
- bool single() const;
+namespace Render {
+ class ITexture;
- void add(UP<IPassElement>&& elem);
- void clear();
- void removeAllOfType(const std::string& type);
+ class CRenderPass {
+ public:
+ bool empty() const;
+ bool single() const;
- CRegion render(const CRegion& damage_);
+ void add(UP<IPassElement>&& elem);
+ void clear();
+ void removeAllOfType(const std::string& type);
- private:
- CRegion m_damage;
- std::vector<CRegion> m_occludedRegions;
- CRegion m_totalLiveBlurRegion;
+ CRegion render(const CRegion& damage_);
- struct SPassElementData {
- CRegion elementDamage;
- UP<IPassElement> element;
- bool discard = false;
- };
+ private:
+ CRegion m_damage;
+ std::vector<CRegion> m_occludedRegions;
+ CRegion m_totalLiveBlurRegion;
+
+ struct SPassElementData {
+ CRegion elementDamage;
+ UP<IPassElement> element;
+ bool discard = false;
+ };
- std::vector<UP<SPassElementData>> m_passElements;
+ std::vector<UP<SPassElementData>> m_passElements;
- void simplify();
- float oneBlurRadius();
- void renderDebugData();
+ void simplify();
+ float oneBlurRadius();
+ void renderDebugData();
- struct {
- bool present = false;
- SP<ITexture> keyboardFocusText, pointerFocusText, lastWindowText;
- } m_debugData;
+ struct {
+ bool present = false;
+ SP<ITexture> keyboardFocusText, pointerFocusText, lastWindowText;
+ } m_debugData;
- friend class CHyprOpenGLImpl;
-};
+ friend class CHyprOpenGLImpl;
+ };
+}
diff --git a/src/render/pass/PassElement.cpp b/src/render/pass/PassElement.cpp
index 3ae52ef5..ae24680a 100644
--- a/src/render/pass/PassElement.cpp
+++ b/src/render/pass/PassElement.cpp
@@ -19,3 +19,7 @@ void IPassElement::discard() {
bool IPassElement::undiscardable() {
return false;
}
+
+std::vector<UP<IPassElement>> IPassElement::draw() {
+ return {};
+}
diff --git a/src/render/pass/PassElement.hpp b/src/render/pass/PassElement.hpp
index c262b36c..9b939f11 100644
--- a/src/render/pass/PassElement.hpp
+++ b/src/render/pass/PassElement.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "../../defines.hpp"
+#include <vector>
enum ePassElementType : uint8_t {
EK_UNKNOWN = 0,
@@ -14,13 +15,16 @@ enum ePassElementType : uint8_t {
EK_SURFACE,
EK_TEXTURE,
EK_TEXTURE_MATTE,
- EK_INNER_GLOW
+ EK_INNER_GLOW,
+ EK_CUSTOM,
};
class IPassElement {
public:
virtual ~IPassElement() = default;
+ virtual std::vector<UP<IPassElement>> draw();
+ //
virtual bool needsLiveBlur() = 0;
virtual bool needsPrecomputeBlur() = 0;
virtual const char* passName() = 0;
diff --git a/src/render/pass/RendererHintsPassElement.hpp b/src/render/pass/RendererHintsPassElement.hpp
index a5a429b5..0a24ff6d 100644
--- a/src/render/pass/RendererHintsPassElement.hpp
+++ b/src/render/pass/RendererHintsPassElement.hpp
@@ -1,12 +1,11 @@
#pragma once
#include "PassElement.hpp"
-#include <optional>
-#include "../OpenGL.hpp"
+#include "../types.hpp"
class CRendererHintsPassElement : public IPassElement {
public:
struct SData {
- std::optional<SRenderModifData> renderModif;
+ std::optional<Render::SRenderModifData> renderModif;
};
CRendererHintsPassElement(const SData& data);
diff --git a/src/render/pass/SurfacePassElement.hpp b/src/render/pass/SurfacePassElement.hpp
index c76b475d..ebf5561c 100644
--- a/src/render/pass/SurfacePassElement.hpp
+++ b/src/render/pass/SurfacePassElement.hpp
@@ -5,7 +5,9 @@
#include "../../helpers/time/Time.hpp"
class CWLSurfaceResource;
-class ITexture;
+namespace Render {
+ class ITexture;
+}
class CSyncTimeline;
class CSurfacePassElement : public IPassElement {
@@ -17,7 +19,7 @@ class CSurfacePassElement : public IPassElement {
void* data = nullptr;
SP<CWLSurfaceResource> surface = nullptr;
- SP<ITexture> texture = nullptr;
+ SP<Render::ITexture> texture = nullptr;
bool mainSurface = true;
double w = 0, h = 0;
int rounding = 0;
diff --git a/src/render/pass/TexPassElement.hpp b/src/render/pass/TexPassElement.hpp
index 5b8c9757..6c0cfab1 100644
--- a/src/render/pass/TexPassElement.hpp
+++ b/src/render/pass/TexPassElement.hpp
@@ -3,7 +3,9 @@
#include <optional>
class CWLSurfaceResource;
-class ITexture;
+namespace Render {
+ class ITexture;
+}
class CSyncTimeline;
enum eDiscardMode : uint8_t {
@@ -14,7 +16,7 @@ enum eDiscardMode : uint8_t {
class CTexPassElement : public IPassElement {
public:
struct SRenderData {
- SP<ITexture> tex;
+ SP<Render::ITexture> tex;
CBox box;
float a = 1.F;
float blurA = 1.F;
@@ -41,7 +43,7 @@ class CTexPassElement : public IPassElement {
CRegion clipRegion;
PHLLSREF currentLS;
- SP<ITexture> blurredBG;
+ SP<Render::ITexture> blurredBG;
};
CTexPassElement(const SRenderData& data);
diff --git a/src/render/pass/TextureMatteElement.hpp b/src/render/pass/TextureMatteElement.hpp
index bf3bb4bf..03526a57 100644
--- a/src/render/pass/TextureMatteElement.hpp
+++ b/src/render/pass/TextureMatteElement.hpp
@@ -2,15 +2,17 @@
#include "PassElement.hpp"
#include "../Framebuffer.hpp"
-class ITexture;
+namespace Render {
+ class ITexture;
+}
class CTextureMatteElement : public IPassElement {
public:
struct STextureMatteData {
- CBox box;
- SP<ITexture> tex;
- SP<IFramebuffer> fb;
- bool disableTransformAndModify = false;
+ CBox box;
+ SP<Render::ITexture> tex;
+ SP<Render::IFramebuffer> fb;
+ bool disableTransformAndModify = false;
};
CTextureMatteElement(const STextureMatteData& data_);