Skip to content

Commit

Permalink
renderer: simplify blur enabling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Nov 17, 2024
1 parent fb91c25 commit 4f591e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/render/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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");

TRACY_GPU_ZONE("RenderTextureWithBlur");
Expand All @@ -2050,8 +2049,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, CBox* pBox, float

m_RenderData.renderModif.applyToRegion(texDamage);

if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) ||
(m_pCurrentWindow.lock() && (m_pCurrentWindow->m_sWindowData.noBlur.valueOrDefault() || m_pCurrentWindow->m_sWindowData.RGBX.valueOrDefault()))) {
if (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) {
renderTexture(tex, pBox, a, round, false, true);
return;
}
Expand Down
22 changes: 14 additions & 8 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ static void renderSurface(SP<CWLSurfaceResource> surface, int x, int y, void* da
}

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;
TRACY_GPU_ZONE("RenderSurface");

Expand Down Expand Up @@ -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
// 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->blur)
if (BLUR)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, surface, rounding, RDATA->blockBlurOptimization, RDATA->fadeAlpha);
else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA, rounding, false, true);
} else {
if (RDATA->blur && RDATA->popup)
if (BLUR && RDATA->popup)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, surface, rounding, true, RDATA->fadeAlpha);
else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA, rounding, false, true);
Expand Down Expand Up @@ -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
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.dontRound = pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN) || pWindow->m_sWindowData.noRounding.valueOrDefault();
Expand All @@ -599,7 +601,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
renderdata.alpha = pWindow->m_fActiveInactiveAlpha.value();
renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && !pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN);
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;

if (ignoreAllGeometry) {
Expand Down Expand Up @@ -715,7 +717,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
static CConfigValue PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups");
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 DA = g_pHyprOpenGL->m_RenderData.discardOpacity;
Expand All @@ -734,13 +736,15 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe
[](CPopup* popup, void* data) {
if (!popup->m_pWLSurface || !popup->m_pWLSurface->resource() || !popup->m_bMapped)
return;
auto pos = popup->coordsRelativeToParent();
auto rd = (SRenderData*)data;
Vector2D oldPos = {rd->x, rd->y};
const auto pos = popup->coordsRelativeToParent();
auto rd = (SRenderData*)data;
const Vector2D oldPos = {rd->x, rd->y};
rd->x += pos.x;
rd->y += pos.y;

popup->m_pWLSurface->resource()->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); },
data);

rd->x = oldPos.x;
rd->y = oldPos.y;
},
Expand Down Expand Up @@ -785,14 +789,16 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, timespec* tim
return;
}

static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");

TRACY_GPU_ZONE("RenderLayer");

const auto REALPOS = pLayer->realPosition.value();
const auto REALSIZ = pLayer->realSize.value();

SRenderData renderdata = {pMonitor, time, REALPOS.x, REALPOS.y};
renderdata.fadeAlpha = pLayer->alpha.value();
renderdata.blur = pLayer->forceBlur;
renderdata.blur = pLayer->forceBlur && *PBLUR;
renderdata.surface = pLayer->surface->resource();
renderdata.decorate = false;
renderdata.w = REALSIZ.x;
Expand Down

0 comments on commit 4f591e8

Please sign in to comment.