diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-03-07 21:21:23 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-07 18:21:23 +0000 |
| commit | 02f30ea15b349d1ed98b608ed06ec88c834592dd (patch) | |
| tree | 5148a3935c43b64f209f2b13e2a0b1bbe987444b /src/render/pass | |
| parent | b227efc8492468cc925014a6c8446a3d044b01e8 (diff) | |
renderer: refactor gl renderer (#13488)
Diffstat (limited to 'src/render/pass')
| -rw-r--r-- | src/render/pass/BorderPassElement.hpp | 1 | ||||
| -rw-r--r-- | src/render/pass/Pass.cpp | 44 | ||||
| -rw-r--r-- | src/render/pass/RectPassElement.hpp | 6 | ||||
| -rw-r--r-- | src/render/pass/SurfacePassElement.hpp | 3 | ||||
| -rw-r--r-- | src/render/pass/TexPassElement.hpp | 46 |
5 files changed, 77 insertions, 23 deletions
diff --git a/src/render/pass/BorderPassElement.hpp b/src/render/pass/BorderPassElement.hpp index 1a458fd5..6513b74a 100644 --- a/src/render/pass/BorderPassElement.hpp +++ b/src/render/pass/BorderPassElement.hpp @@ -13,6 +13,7 @@ class CBorderPassElement : public IPassElement { float lerp = 0.F, a = 1.F; int round = 0, borderSize = 1, outerRound = -1; float roundingPower = 2.F; + PHLWINDOWREF window; }; CBorderPassElement(const SBorderData& data_); diff --git a/src/render/pass/Pass.cpp b/src/render/pass/Pass.cpp index 901b4770..b7923a66 100644 --- a/src/render/pass/Pass.cpp +++ b/src/render/pass/Pass.cpp @@ -213,9 +213,15 @@ void CRenderPass::renderDebugData() { const auto pMonitor = g_pHyprRenderer->m_renderData.pMonitor; CBox box = {{}, pMonitor->m_transformedSize}; for (const auto& rg : m_occludedRegions) { - g_pHyprOpenGL->renderRect(box, Colors::RED.modifyA(0.1F), {.damage = &rg}); + CRectPassElement::SRectData data; + data.box = box; + data.color = Colors::RED.modifyA(0.1F); + g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), rg); } - g_pHyprOpenGL->renderRect(box, Colors::GREEN.modifyA(0.1F), {.damage = &m_totalLiveBlurRegion}); + CRectPassElement::SRectData data; + data.box = box; + data.color = Colors::GREEN.modifyA(0.1F); + g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), m_totalLiveBlurRegion); std::unordered_map<CWLSurfaceResource*, float> offsets; @@ -238,9 +244,12 @@ void CRenderPass::renderDebugData() { if (box.intersection(CBox{{}, pMonitor->m_size}).empty()) return; - static const auto FULL_REGION = CRegion{0, 0, INT32_MAX, INT32_MAX}; + static const auto FULL_REGION = CRegion{0, 0, INT32_MAX, INT32_MAX}; - g_pHyprOpenGL->renderRect(box, color, {.damage = &FULL_REGION}); + CRectPassElement::SRectData data; + data.box = box; + data.color = color; + g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), FULL_REGION); if (offsets.contains(surface.get())) box.translate(Vector2D{0.F, offsets[surface.get()]}); @@ -248,8 +257,16 @@ void CRenderPass::renderDebugData() { offsets[surface.get()] = 0; box = {box.pos(), texture->m_size}; - g_pHyprOpenGL->renderRect(box, CHyprColor{0.F, 0.F, 0.F, 0.2F}, {.damage = &FULL_REGION, .round = std::min(5.0, box.size().y)}); - g_pHyprOpenGL->renderTexture(texture, box, {}); + CRectPassElement::SRectData data2; + data.box = box; + data.color = color; + data.round = std::min(5.0, box.size().y); + g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data2), FULL_REGION); + + CTexPassElement::SRenderData texData; + texData.tex = texture; + texData.box = box; + g_pHyprRenderer->draw(makeUnique<CTexPassElement>(texData), {}); offsets[surface.get()] += texture->m_size.y; }; @@ -267,7 +284,10 @@ void CRenderPass::renderDebugData() { auto BOX = hlSurface->getSurfaceBoxGlobal(); if (BOX) { auto region = g_pSeatManager->m_state.pointerFocus->m_current.input.copy().scale(pMonitor->m_scale).translate(BOX->pos() - pMonitor->m_position); - g_pHyprOpenGL->renderRect(box, CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}, {.damage = ®ion}); + CRectPassElement::SRectData data; + data.box = box; + data.color = CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}; + g_pHyprRenderer->draw(makeUnique<CRectPassElement>(data), region); } } } @@ -280,7 +300,10 @@ void CRenderPass::renderDebugData() { if (tex) { box = CBox{{0.F, pMonitor->m_size.y - tex->m_size.y}, tex->m_size}.scale(pMonitor->m_scale); - g_pHyprOpenGL->renderTexture(tex, box, {}); + CTexPassElement::SRenderData texData; + texData.tex = tex; + texData.box = box; + g_pHyprRenderer->draw(makeUnique<CTexPassElement>(texData), {}); } std::string passStructure; @@ -297,7 +320,10 @@ void CRenderPass::renderDebugData() { 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); - g_pHyprOpenGL->renderTexture(tex, box, {}); + CTexPassElement::SRenderData texData; + texData.tex = tex; + texData.box = box; + g_pHyprRenderer->draw(makeUnique<CTexPassElement>(texData), {}); } } diff --git a/src/render/pass/RectPassElement.hpp b/src/render/pass/RectPassElement.hpp index b6d310ad..a61ab155 100644 --- a/src/render/pass/RectPassElement.hpp +++ b/src/render/pass/RectPassElement.hpp @@ -12,6 +12,12 @@ class CRectPassElement : public IPassElement { bool blur = false, xray = false; float blurA = 1.F; CBox clipBox; + + // internal + CBox modifiedBox; + float TOPLEFT[2]; + float FULLSIZE[2]; + CRegion drawRegion; }; CRectPassElement(const SRectData& data); diff --git a/src/render/pass/SurfacePassElement.hpp b/src/render/pass/SurfacePassElement.hpp index bd02417d..c76b475d 100644 --- a/src/render/pass/SurfacePassElement.hpp +++ b/src/render/pass/SurfacePassElement.hpp @@ -1,5 +1,6 @@ #pragma once #include "PassElement.hpp" +#include "TexPassElement.hpp" #include <optional> #include "../../helpers/time/Time.hpp" @@ -41,7 +42,7 @@ class CSurfacePassElement : public IPassElement { CBox clipBox = {}; // scaled coordinates - uint32_t discardMode = 0; + uint32_t discardMode = DISCARD_OPAQUE; float discardOpacity = 0.f; bool useNearestNeighbor = false; diff --git a/src/render/pass/TexPassElement.hpp b/src/render/pass/TexPassElement.hpp index 1ac3db0c..5b8c9757 100644 --- a/src/render/pass/TexPassElement.hpp +++ b/src/render/pass/TexPassElement.hpp @@ -6,22 +6,42 @@ class CWLSurfaceResource; class ITexture; class CSyncTimeline; +enum eDiscardMode : uint8_t { + DISCARD_OPAQUE = 1, + DISCARD_ALPHA = 1 << 1 +}; + class CTexPassElement : public IPassElement { public: struct SRenderData { - SP<ITexture> tex; - CBox box; - float a = 1.F; - float blurA = 1.F; - CRegion damage; - int round = 0; - float roundingPower = 2.0f; - bool flipEndFrame = false; - bool useMirrorProjection = false; - CBox clipBox; - bool blur = false; - std::optional<float> ignoreAlpha; - std::optional<bool> blockBlurOptimization; + SP<ITexture> tex; + CBox box; + float a = 1.F; + float blurA = 1.F; + float overallA = 1.F; + CRegion damage; + int round = 0; + float roundingPower = 2.0f; + bool flipEndFrame = false; + bool useMirrorProjection = false; + CBox clipBox; + bool blur = false; + std::optional<float> ignoreAlpha; + std::optional<bool> blockBlurOptimization; + bool cmBackToSRGB = false; + SP<CMonitor> cmBackToSRGBSource; + + bool discardActive = false; + bool allowCustomUV = false; + SP<CWLSurfaceResource> surface = nullptr; + + uint32_t discardMode = DISCARD_OPAQUE; + float discardOpacity = 0.f; + + CRegion clipRegion; + PHLLSREF currentLS; + + SP<ITexture> blurredBG; }; CTexPassElement(const SRenderData& data); |
