From 2a5ae435e19e5ccc3a4d989497f062614307f104 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 23 Jan 2023 13:55:11 +0000 Subject: [PATCH] allow preblur for opaque surfaces if alpha not 1 --- src/render/OpenGL.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 4d24842b..a02b8dba 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -460,7 +460,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b bool allowCustomUV, bool allowDim) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); - + alpha = std::clamp(alpha, 0.f, 1.f); if (!pixman_region32_not_empty(m_RenderData.pDamage)) @@ -733,17 +733,18 @@ void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) { if (pWindow->m_sAdditionalConfigData.forceNoBlur) return false; - const auto PSURFACE = g_pXWaylandManager->getWindowSurface(pWindow); + const auto PSURFACE = g_pXWaylandManager->getWindowSurface(pWindow); - if (PSURFACE->opaque) - return false; - - pixman_region32_t inverseOpaque; - pixman_region32_init(&inverseOpaque); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const float A = pWindow->m_fAlpha.fl() * pWindow->m_fActiveInactiveAlpha.fl() * PWORKSPACE->m_fAlpha.fl(); if (A >= 1.f) { + if (PSURFACE->opaque) + return false; + + pixman_region32_t inverseOpaque; + pixman_region32_init(&inverseOpaque); + pixman_box32_t surfbox = {0, 0, PSURFACE->current.width, PSURFACE->current.height}; pixman_region32_copy(&inverseOpaque, &PSURFACE->current.opaque); pixman_region32_inverse(&inverseOpaque, &inverseOpaque, &surfbox); @@ -753,9 +754,9 @@ void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) { pixman_region32_fini(&inverseOpaque); return false; } - } - pixman_region32_fini(&inverseOpaque); + pixman_region32_fini(&inverseOpaque); + } return true; };