renderer: simplify blur enabling logic

This commit is contained in:
Vaxry 2024-11-17 16:42:30 +00:00
parent fb91c2550f
commit 4f591e807a
2 changed files with 15 additions and 11 deletions

View file

@ -2036,7 +2036,6 @@ bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWin
void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, CBox* pBox, float a, SP<CWLSurfaceResource> pSurface, int round, bool blockBlurOptimization, float blurA) { void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, CBox* pBox, float a, SP<CWLSurfaceResource> pSurface, int round, bool blockBlurOptimization, float blurA) {
RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!"); RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!");
static auto PBLURENABLED = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
static auto PNOBLUROVERSIZED = CConfigValue<Hyprlang::INT>("decoration:no_blur_on_oversized"); static auto PNOBLUROVERSIZED = CConfigValue<Hyprlang::INT>("decoration:no_blur_on_oversized");
TRACY_GPU_ZONE("RenderTextureWithBlur"); TRACY_GPU_ZONE("RenderTextureWithBlur");
@ -2050,8 +2049,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, CBox* pBox, float
m_RenderData.renderModif.applyToRegion(texDamage); m_RenderData.renderModif.applyToRegion(texDamage);
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || if (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) {
(m_pCurrentWindow.lock() && (m_pCurrentWindow->m_sWindowData.noBlur.valueOrDefault() || m_pCurrentWindow->m_sWindowData.RGBX.valueOrDefault()))) {
renderTexture(tex, pBox, a, round, false, true); renderTexture(tex, pBox, a, round, false, true);
return; return;
} }

View file

@ -174,6 +174,7 @@ static void renderSurface(SP<CWLSurfaceResource> surface, int x, int y, void* da
} }
const auto RDATA = (SRenderData*)data; const auto RDATA = (SRenderData*)data;
const bool BLUR = RDATA->blur && !TEXTURE->m_bOpaque;
const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow && g_pInputManager->dragMode == MBIND_RESIZE; const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow && g_pInputManager->dragMode == MBIND_RESIZE;
TRACY_GPU_ZONE("RenderSurface"); TRACY_GPU_ZONE("RenderSurface");
@ -270,12 +271,12 @@ static void renderSurface(SP<CWLSurfaceResource> surface, int x, int y, void* da
// is a subsurface that does NOT cover the entire frame. In such cases, we probably should fall back // is a subsurface that does NOT cover the entire frame. In such cases, we probably should fall back
// to what we do for misaligned surfaces (blur the entire thing and then render shit without blur) // to what we do for misaligned surfaces (blur the entire thing and then render shit without blur)
if (RDATA->surfaceCounter == 0 && !RDATA->popup) { if (RDATA->surfaceCounter == 0 && !RDATA->popup) {
if (RDATA->blur) if (BLUR)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, surface, rounding, RDATA->blockBlurOptimization, RDATA->fadeAlpha); g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, surface, rounding, RDATA->blockBlurOptimization, RDATA->fadeAlpha);
else else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA, rounding, false, true); g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA, rounding, false, true);
} else { } else {
if (RDATA->blur && RDATA->popup) if (BLUR && RDATA->popup)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, surface, rounding, true, RDATA->fadeAlpha); g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, surface, rounding, true, RDATA->fadeAlpha);
else else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA, rounding, false, true); g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA, rounding, false, true);
@ -591,6 +592,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
// whether to use m_fMovingToWorkspaceAlpha, only if fading out into an invisible ws // whether to use m_fMovingToWorkspaceAlpha, only if fading out into an invisible ws
const bool USE_WORKSPACE_FADE_ALPHA = pWindow->m_iMonitorMovedFrom != -1 && !g_pCompositor->isWorkspaceVisible(pWindow->m_pWorkspace); const bool USE_WORKSPACE_FADE_ALPHA = pWindow->m_iMonitorMovedFrom != -1 && !g_pCompositor->isWorkspaceVisible(pWindow->m_pWorkspace);
const bool DONT_BLUR = pWindow->m_sWindowData.noBlur.valueOrDefault() || pWindow->m_sWindowData.RGBX.valueOrDefault() || pWindow->opaque();
renderdata.surface = pWindow->m_pWLSurface->resource(); renderdata.surface = pWindow->m_pWLSurface->resource();
renderdata.dontRound = pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN) || pWindow->m_sWindowData.noRounding.valueOrDefault(); renderdata.dontRound = pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN) || pWindow->m_sWindowData.noRounding.valueOrDefault();
@ -599,7 +601,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
renderdata.alpha = pWindow->m_fActiveInactiveAlpha.value(); renderdata.alpha = pWindow->m_fActiveInactiveAlpha.value();
renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && !pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN); renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && !pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN);
renderdata.rounding = ignoreAllGeometry || renderdata.dontRound ? 0 : pWindow->rounding() * pMonitor->scale; renderdata.rounding = ignoreAllGeometry || renderdata.dontRound ? 0 : pWindow->rounding() * pMonitor->scale;
renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later renderdata.blur = !ignoreAllGeometry && *PBLUR && !DONT_BLUR;
renderdata.pWindow = pWindow; renderdata.pWindow = pWindow;
if (ignoreAllGeometry) { if (ignoreAllGeometry) {
@ -715,7 +717,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
static CConfigValue PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups"); static CConfigValue PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups");
static CConfigValue PBLURIGNOREA = CConfigValue<Hyprlang::FLOAT>("decoration:blur:popups_ignorealpha"); static CConfigValue PBLURIGNOREA = CConfigValue<Hyprlang::FLOAT>("decoration:blur:popups_ignorealpha");
renderdata.blur = *PBLURPOPUPS; renderdata.blur = *PBLURPOPUPS && *PBLUR;
const auto DM = g_pHyprOpenGL->m_RenderData.discardMode; const auto DM = g_pHyprOpenGL->m_RenderData.discardMode;
const auto DA = g_pHyprOpenGL->m_RenderData.discardOpacity; const auto DA = g_pHyprOpenGL->m_RenderData.discardOpacity;
@ -734,13 +736,15 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
[](CPopup* popup, void* data) { [](CPopup* popup, void* data) {
if (!popup->m_pWLSurface || !popup->m_pWLSurface->resource() || !popup->m_bMapped) if (!popup->m_pWLSurface || !popup->m_pWLSurface->resource() || !popup->m_bMapped)
return; return;
auto pos = popup->coordsRelativeToParent(); const auto pos = popup->coordsRelativeToParent();
auto rd = (SRenderData*)data; auto rd = (SRenderData*)data;
Vector2D oldPos = {rd->x, rd->y}; const Vector2D oldPos = {rd->x, rd->y};
rd->x += pos.x; rd->x += pos.x;
rd->y += pos.y; rd->y += pos.y;
popup->m_pWLSurface->resource()->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); }, popup->m_pWLSurface->resource()->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); },
data); data);
rd->x = oldPos.x; rd->x = oldPos.x;
rd->y = oldPos.y; rd->y = oldPos.y;
}, },
@ -785,6 +789,8 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, timespec* tim
return; return;
} }
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
TRACY_GPU_ZONE("RenderLayer"); TRACY_GPU_ZONE("RenderLayer");
const auto REALPOS = pLayer->realPosition.value(); const auto REALPOS = pLayer->realPosition.value();
@ -792,7 +798,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, timespec* tim
SRenderData renderdata = {pMonitor, time, REALPOS.x, REALPOS.y}; SRenderData renderdata = {pMonitor, time, REALPOS.x, REALPOS.y};
renderdata.fadeAlpha = pLayer->alpha.value(); renderdata.fadeAlpha = pLayer->alpha.value();
renderdata.blur = pLayer->forceBlur; renderdata.blur = pLayer->forceBlur && *PBLUR;
renderdata.surface = pLayer->surface->resource(); renderdata.surface = pLayer->surface->resource();
renderdata.decorate = false; renderdata.decorate = false;
renderdata.w = REALSIZ.x; renderdata.w = REALSIZ.x;