From ffc580dda98437fa457d389f231de082df327345 Mon Sep 17 00:00:00 2001 From: Flafy Date: Sun, 4 Dec 2022 22:57:41 +0200 Subject: [PATCH] blur xray for layers (#1158) * feat: apply blur_xray to non window surfaces * don't blur optimize bottom and background layers --- src/helpers/WLClasses.hpp | 1 + src/render/OpenGL.cpp | 4 ++-- src/render/OpenGL.hpp | 2 +- src/render/Renderer.cpp | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index c340a516..66581077 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -70,6 +70,7 @@ struct SRenderData { // for blurring bool blur = false; + bool blockBlurOptimization = false; // only for windows, not popups bool squishOversized = true; diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 021b8893..20457308 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -821,7 +821,7 @@ void CHyprOpenGLImpl::preWindowPass() { preBlurForCurrentMonitor(); } -void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, wlr_surface* pSurface, int round) { +void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, wlr_surface* pSurface, int round, bool blockBlurOptimization) { RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!"); static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; @@ -861,7 +861,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, } // vvv TODO: layered blur fbs? - const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && m_pCurrentWindow && (!m_pCurrentWindow->m_bIsFloating || *PBLURXRAY) && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && !g_pCompositor->isWorkspaceSpecial(m_pCurrentWindow->m_iWorkspaceID)); + const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && !blockBlurOptimization && ((m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating) || *PBLURXRAY) && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && (!m_pCurrentWindow || !g_pCompositor->isWorkspaceSpecial(m_pCurrentWindow->m_iWorkspaceID) )); CFramebuffer* POUTFB = nullptr; if (!USENEWOPTIMIZE) { diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index fabd3666..1d7e2128 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -82,7 +82,7 @@ public: void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0); void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false); void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false); - void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0); + void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false); void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0); void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 3fd33876..5f527830 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -42,7 +42,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); } else { if (RDATA->blur) - g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding); + g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, RDATA->blockBlurOptimization); else g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); } @@ -349,6 +349,7 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times renderdata.decorate = false; renderdata.w = pLayer->layerSurface->surface->current.width; renderdata.h = pLayer->layerSurface->surface->current.height; + renderdata.blockBlurOptimization = pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND; wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata); renderdata.squishOversized = false; // don't squish popups