diff options
author | vaxerski <[email protected]> | 2022-05-19 20:16:08 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-19 20:16:08 +0200 |
commit | 464c4aa3956fd4ec47d316dff3188c708edcc930 (patch) | |
tree | f69093d36e63a288edec5dab40f12dfbfbc5481b | |
parent | 146b189d54e51609634d9dc4b1ab47f9e3c91d49 (diff) | |
download | Hyprland-464c4aa3956fd4ec47d316dff3188c708edcc930.tar.gz Hyprland-464c4aa3956fd4ec47d316dff3188c708edcc930.zip |
fixed borders on no blur
-rw-r--r-- | src/render/OpenGL.cpp | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index e330456c..8051dc80 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -356,6 +356,17 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b glEnableVertexAttribArray(shader->posAttrib); glEnableVertexAttribArray(shader->texAttrib); + // stencil for when we want a border + if (border) { + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + + glEnable(GL_STENCIL_TEST); + + glStencilFunc(GL_ALWAYS, 1, -1); + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + } + if (pixman_region32_not_empty(m_RenderData.pDamage)) { PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { const auto RECT = RECTSARR[i]; @@ -364,10 +375,27 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b } } + if (border) { + glStencilFunc(GL_EQUAL, 1, -1); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + } + glDisableVertexAttribArray(shader->posAttrib); glDisableVertexAttribArray(shader->texAttrib); glBindTexture(tex.m_iTarget, 0); + + // if border draw + // we dont disable stencil here if we havent touched it. + // some other func might be using it. + if (border) { + auto BORDERCOL = m_pCurrentWindow->m_cRealBorderColor.col(); + BORDERCOL.a *= alpha / 255.f; + renderBorder(pBox, BORDERCOL, g_pConfigManager->getInt("general:border_size"), round); + glStencilMask(-1); + glStencilFunc(GL_ALWAYS, 1, 0xFF); + glDisable(GL_STENCIL_TEST); + } } // This probably isn't the fastest @@ -621,14 +649,6 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { pixman_region32_fini(&fakeDamage); - const auto PFRAMEBUFFER = &m_mWindowFramebuffers[pWindow]; - - glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y); - - PFRAMEBUFFER->alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); - - PFRAMEBUFFER->bind(); - clear(CColor(0,0,0,0)); // JIC timespec now; @@ -646,6 +666,21 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { g_pConfigManager->setInt("decoration:blur", BLURVAL); + // render onto the window fb + // we rendered onto the primary because it has a stencil, which we need for the borders etc + const auto PFRAMEBUFFER = &m_mWindowFramebuffers[pWindow]; + + glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y); + + PFRAMEBUFFER->alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); + + PFRAMEBUFFER->bind(); + + clear(CColor(0, 0, 0, 0)); // JIC + + wlr_box fullMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; + renderTexture(m_mMonitorRenderResources[m_RenderData.pMonitor].primaryFB.m_cTex, &fullMonBox, 255.f, 0); + // restore original fb #ifndef GLES2 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iCurrentOutputFb); @@ -690,6 +725,9 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) { // draw the layer g_pHyprRenderer->renderLayer(pLayer, PMONITOR, &now); + // TODO: WARN: + // revise if any stencil-requiring rendering is done to the layers. + // restore original fb #ifndef GLES2 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iCurrentOutputFb); |