From 14195835ef1dd25e10b0d873ec75c004b238ccba Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 9 Nov 2023 22:11:42 +0000 Subject: opengl: switch to black-and-white for alpha mattes also fixes shadows on 10b --- src/render/decorations/CHyprDropShadowDecoration.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/render/decorations/CHyprDropShadowDecoration.cpp') diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index 5341dec9..68a82c3a 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -140,19 +140,26 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D windowBox.addExtents(SWindowDecorationExtents{m_eLastExtents * pMonitor->scale}.floor()).round(); - if (windowBox.width < 1 || windowBox.height < 1) { + if (windowBox.width < 1 || windowBox.height < 1) return; // prevent assert failed - } alphaFB.bind(); - g_pHyprOpenGL->clear(CColor(0, 0, 0, 0)); - g_pHyprOpenGL->renderRect(&windowBox, CColor(1.0, 1.0, 1.0, 1.0), ROUNDING * pMonitor->scale); + // build the matte + // 10-bit formats have dogshit alpha channels, so we have to use the matte to its fullest. + // first, clear with black (fully transparent) + g_pHyprOpenGL->clear(CColor(0, 0, 0, 1)); + + // render white shadow + g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, 1), a); + + // render black window box ("clip") + g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 1.0), ROUNDING * pMonitor->scale); alphaSwapFB.bind(); - g_pHyprOpenGL->clear(CColor(0, 0, 0, 0)); - g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, a); + // alpha swap just has the shadow color. It will be the "texture" to render. + g_pHyprOpenGL->clear(m_pWindow->m_cRealShadowColor.col()); LASTFB->bind(); -- cgit v1.2.3