From 16afa2c42200e7a7d8b45602f584986094c92721 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Jul 2022 20:57:59 +0200 Subject: fix border rendering on certain windows oversized subsurfaces had a tendency to be above borders, now they wont be --- src/render/Renderer.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index e3e67a65..6823d5d3 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -40,12 +40,6 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding); else g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); - - if (RDATA->decorate) { - auto col = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor.col(); - col.a *= RDATA->fadeAlpha * RDATA->alpha / 255.f; - g_pHyprOpenGL->renderBorder(&windowBox, col, rounding); - } } else { if (RDATA->surface && wlr_surface_is_xdg_surface(RDATA->surface)) { @@ -241,6 +235,19 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata); + if (renderdata.decorate) { + static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; + + float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding; + + auto col = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor.col(); + col.a *= renderdata.fadeAlpha * renderdata.alpha / 255.f; + + wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; + + g_pHyprOpenGL->renderBorder(&windowBox, col, rounding); + } + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); } -- cgit v1.2.3 From cb2989cec50dc15ff0dab16888b38a25f2d4f081 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Jul 2022 21:10:16 +0200 Subject: fix fade corner artifacts --- src/render/shaders/Textures.hpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/render') diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp index d01e7775..13cdc92a 100644 --- a/src/render/shaders/Textures.hpp +++ b/src/render/shaders/Textures.hpp @@ -34,8 +34,7 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar distances = distances / 4.0; - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; + )#" + colorVarName + R"#( = )#" + colorVarName + R"#( * distances; } } } else if (pixCoord[1] > bottomRight[1]) { @@ -66,8 +65,7 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar distances = distances / 4.0; - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; + )#" + colorVarName + R"#( = )#" + colorVarName + R"#( * distances; } } } @@ -102,8 +100,7 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar distances = distances / 4.0; - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; + )#" + colorVarName + R"#( = )#" + colorVarName + R"#( * distances; } } } else if (pixCoord[1] > bottomRight[1]) { @@ -134,8 +131,7 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar distances = distances / 4.0; - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; + )#" + colorVarName + R"#( = )#" + colorVarName + R"#( * distances; } } } @@ -176,11 +172,13 @@ void main() { return; } + vec4 pixColor = v_color; + vec2 pixCoord = fullSize * v_texcoord; - )#" + ROUNDED_SHADER_FUNC("v_color") + R"#( + )#" + ROUNDED_SHADER_FUNC("pixColor") + R"#( - gl_FragColor = v_color; + gl_FragColor = pixColor; })#"; inline const std::string TEXVERTSRC = R"#( -- cgit v1.2.3 From f5bd30569ff16764ade82bdcebb828584318d76a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Jul 2022 23:29:42 +0200 Subject: fix borders on scaled --- src/render/Renderer.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 6823d5d3..a7ad4607 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -245,6 +245,8 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; + scaleBox(&windowBox, pMonitor->scale); + g_pHyprOpenGL->renderBorder(&windowBox, col, rounding); } -- cgit v1.2.3 From 90d07d7b520d3ea8d01dd248d16dcd96937f431c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 18 Jul 2022 12:39:57 +0200 Subject: fix shadows on unmanaged and noborder --- src/render/decorations/CHyprDropShadowDecoration.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/render') diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index 40051942..a03181c0 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -53,6 +53,9 @@ void CHyprDropShadowDecoration::draw(SMonitor* pMonitor, float a) { if (!g_pCompositor->windowValidMapped(m_pWindow)) return; + if (m_pWindow->m_cRealShadowColor.col() == CColor(0, 0, 0, 0)) + return; // don't draw invisible shadows + static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; static auto *const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue; static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; -- cgit v1.2.3 From 10a83853ac1785d4dabcef3920ebc5a74fc7707f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:16:01 +0200 Subject: added ls noprocess --- src/render/Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a7ad4607..c8154348 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -508,7 +508,7 @@ void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::listvecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y}; for (auto& ls : layerSurfaces) { - if (ls->fadingOut || ls->readyToDelete || !ls->layerSurface) + if (ls->fadingOut || ls->readyToDelete || !ls->layerSurface || ls->noProcess) continue; const auto PLAYER = ls->layerSurface; -- cgit v1.2.3 From 0281caa8e0e3287404d838a8e4143f8456bb7723 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 19 Jul 2022 13:36:54 +0200 Subject: fix ASan error --- src/render/OpenGL.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 07e4dfff..2123ece1 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -388,14 +388,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b glVertexAttribPointer(shader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); - if (allowCustomUV && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) { - const float verts[] = { - m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right - m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left - m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right - m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left - }; + const float verts[] = { + m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right + m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left + m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right + m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left + }; + if (allowCustomUV && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) { glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, verts); } else { glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); -- cgit v1.2.3 From e6b151b6c37d72515e1c8e15886f32335ae956c3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 12:06:14 +0200 Subject: fix memory read after free in damageSurface --- src/render/Renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index c8154348..79b3a8b5 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -652,12 +652,12 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) { pixman_region32_translate(&damageBox, -lx, -ly); } - pixman_region32_fini(&damageBox); - static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; if (*PLOGDAMAGE) Debug::log(LOG, "Damage: Surface (extents): xy: %d, %d wh: %d, %d", damageBox.extents.x1, damageBox.extents.y1, damageBox.extents.x2 - damageBox.extents.x1, damageBox.extents.y2 - damageBox.extents.y1); + + pixman_region32_fini(&damageBox); } void CHyprRenderer::damageWindow(CWindow* pWindow) { -- cgit v1.2.3 From 9463e3eb0a3ee0d46ae156144346df38c170c94b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 16:28:05 +0200 Subject: fix transformed snapshots a bit --- src/render/OpenGL.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 2123ece1..91d6b0c5 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -698,7 +698,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { // this is temporary, doesnt mess with the actual wlr damage pixman_region32_t fakeDamage; pixman_region32_init(&fakeDamage); - pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecPixelSize.x, (int)PMONITOR->vecPixelSize.y); + pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y); begin(PMONITOR, &fakeDamage, true); @@ -715,6 +715,8 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { const auto BLURVAL = g_pConfigManager->getInt("decoration:blur"); g_pConfigManager->setInt("decoration:blur", 0); + m_bEndFrame = true; + g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, !pWindow->m_bX11DoesntWantBorders, RENDER_PASS_ALL); g_pConfigManager->setInt("decoration:blur", BLURVAL); @@ -731,8 +733,10 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { clear(CColor(0, 0, 0, 0)); // JIC - wlr_box fullMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; + wlr_box fullMonBox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y}; + renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &fullMonBox, 255.f, 0); + m_bEndFrame = false; // restore original fb #ifndef GLES2 @@ -757,7 +761,7 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) { // this is temporary, doesnt mess with the actual wlr damage pixman_region32_t fakeDamage; pixman_region32_init(&fakeDamage); - pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecPixelSize.x, (int)PMONITOR->vecPixelSize.y); + pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y); begin(PMONITOR, &fakeDamage, true); @@ -774,9 +778,13 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) { timespec now; clock_gettime(CLOCK_MONOTONIC, &now); + m_bEndFrame = true; + // draw the layer g_pHyprRenderer->renderLayer(pLayer, PMONITOR, &now); + m_bEndFrame = false; + // TODO: WARN: // revise if any stencil-requiring rendering is done to the layers. @@ -815,13 +823,15 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) { // the originalClosedPos is relative to the monitor's pos Vector2D scaleXY = Vector2D((PMONITOR->scale * PWINDOW->m_vRealSize.vec().x / (PWINDOW->m_vOriginalClosedSize.x * PMONITOR->scale)), (PMONITOR->scale * PWINDOW->m_vRealSize.vec().y / (PWINDOW->m_vOriginalClosedSize.y * PMONITOR->scale))); - windowBox.width = PMONITOR->vecPixelSize.x * scaleXY.x; - windowBox.height = PMONITOR->vecPixelSize.y * scaleXY.y; + // TODO: this is wrong on scaled. + + windowBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x; + windowBox.height = PMONITOR->vecTransformedSize.y * scaleXY.y; windowBox.x = ((PWINDOW->m_vRealPosition.vec().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.x * PMONITOR->scale) * scaleXY.x); windowBox.y = ((PWINDOW->m_vRealPosition.vec().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.y * PMONITOR->scale) * scaleXY.y); pixman_region32_t fakeDamage; - pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); + pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y); renderTextureInternalWithDamage(it->second.m_cTex, &windowBox, PWINDOW->m_fAlpha.fl(), &fakeDamage, 0); @@ -844,10 +854,10 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID); - wlr_box windowBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; + wlr_box windowBox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y}; pixman_region32_t fakeDamage; - pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); + pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y); renderTextureInternalWithDamage(it->second.m_cTex, &windowBox, PLAYER->alpha.fl(), &fakeDamage, 0); -- cgit v1.2.3