summaryrefslogtreecommitdiff
path: root/src/render/decorations/CHyprDropShadowDecoration.cpp
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/decorations/CHyprDropShadowDecoration.cpp
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/decorations/CHyprDropShadowDecoration.cpp')
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp
index 2d4eaba2..44a42d25 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.cpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.cpp
@@ -4,6 +4,7 @@
#include "../../config/ConfigValue.hpp"
#include "../pass/ShadowPassElement.hpp"
#include "../Renderer.hpp"
+#include "../pass/RectPassElement.hpp"
#include "../pass/TextureMatteElement.hpp"
CHyprDropShadowDecoration::CHyprDropShadowDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_window(pWindow) {
@@ -233,50 +234,50 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) {
g_pHyprRenderer->disableScissor();
if (data.ignoreWindow) {
- // we'll take the liberty of using this as it should not be used rn
- const auto alphaFB = g_pHyprRenderer->m_renderData.pMonitor->m_mirrorFB;
- const auto alphaSwapFB = g_pHyprRenderer->m_renderData.pMonitor->m_mirrorSwapFB;
- const auto LASTFB = g_pHyprRenderer->m_renderData.currentFB;
+ const auto alphaFB = g_pHyprRenderer->m_renderData.pMonitor->resources()->getUnusedWorkBuffer();
+ const auto alphaSwapFB = g_pHyprRenderer->m_renderData.pMonitor->resources()->getUnusedWorkBuffer();
CBox monbox = {0, 0, pMonitor->m_transformedSize.x, pMonitor->m_transformedSize.y};
- alphaFB->bind();
+ auto guard = g_pHyprRenderer->bindTempFB(alphaFB); // store current FB inside guard
+ // TODO not needed for 8bpc and 16fp?
// build the matte
// 10-bit formats have dogshit alpha channels, so we have to use the matte to its fullest.
// first, clear region of interest with black (fully transparent)
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(CRectPassElement::SRectData{.box = data.fullBox, .color = CHyprColor(0, 0, 0, 1), .round = 0}), monbox);
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{.box = data.fullBox, .color = CHyprColor(0, 0, 0, 1), .round = 0}, monbox);
// render white shadow with the alpha of the shadow color (otherwise we clear with alpha later and shit it to 2 bit)
drawShadowInternal(data.fullBox, data.rounding * pMonitor->m_scale, data.roundingPower, data.size * pMonitor->m_scale,
CHyprColor(1, 1, 1, PWINDOW->m_realShadowColor->value().a), a);
// render black window box ("clip")
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(CRectPassElement::SRectData{
- .box = data.windowBox,
- .color = CHyprColor(0, 0, 0, 1),
- .round = (data.rounding + 1 /* This fixes small pixel gaps. */) * pMonitor->m_scale,
- .roundingPower = data.roundingPower,
- }),
- monbox);
+ g_pHyprRenderer->draw(
+ CRectPassElement::SRectData{
+ .box = data.windowBox,
+ .color = CHyprColor(0, 0, 0, 1),
+ .round = (data.rounding + 1 /* This fixes small pixel gaps. */) * pMonitor->m_scale,
+ .roundingPower = data.roundingPower,
+ },
+ monbox);
- alphaSwapFB->bind();
+ g_pHyprRenderer->bindFB(alphaSwapFB);
// alpha swap just has the shadow color. It will be the "texture" to render.
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(CRectPassElement::SRectData{.box = data.fullBox, .color = PWINDOW->m_realShadowColor->value().stripA(), .round = 0}),
- monbox);
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{.box = data.fullBox, .color = PWINDOW->m_realShadowColor->value().stripA(), .round = 0}, monbox);
- LASTFB->bind();
+ guard.reset(); // restore FB
g_pHyprRenderer->pushMonitorTransformEnabled(true);
g_pHyprRenderer->m_renderData.renderModif.enabled = false;
- g_pHyprRenderer->draw(makeUnique<CTextureMatteElement>(CTextureMatteElement::STextureMatteData{
- .box = monbox,
- .tex = alphaSwapFB->getTexture(),
- .fb = alphaFB,
- }),
- {});
+ g_pHyprRenderer->draw(
+ CTextureMatteElement::STextureMatteData{
+ .box = monbox,
+ .tex = alphaSwapFB->getTexture(),
+ .fb = alphaFB,
+ },
+ {});
g_pHyprRenderer->m_renderData.renderModif.enabled = true;
g_pHyprRenderer->popMonitorTransformEnabled();
@@ -303,13 +304,12 @@ void CHyprDropShadowDecoration::drawShadowInternal(const CBox& box, int round, f
color.a *= a;
if (*PSHADOWSHARP)
- g_pHyprRenderer->draw(makeUnique<CRectPassElement>(CRectPassElement::SRectData{
- .box = box,
- .color = color,
- .round = round,
- .roundingPower = roundingPower,
- }),
- {});
+ g_pHyprRenderer->draw(CRectPassElement::SRectData{
+ .box = box,
+ .color = color,
+ .round = round,
+ .roundingPower = roundingPower,
+ });
else
g_pHyprRenderer->drawShadow(box, round, roundingPower, range, color, 1.F);
}