From 6eb7d0038644fab09c8512ad34cdcbde1882ffc0 Mon Sep 17 00:00:00 2001 From: Felix Dick Date: Thu, 29 Sep 2022 23:19:56 +0200 Subject: [PATCH] Send absolute screen coordinates to texture shaders. --- src/render/OpenGL.cpp | 9 +++------ src/render/shaders/Textures.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 02100b38..29b479b6 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -334,15 +334,13 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_FALSE, glMatrix); glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f); - const auto TOPLEFT = Vector2D(round, round); - const auto BOTTOMRIGHT = Vector2D(box->width - round, box->height - round); + const auto TOPLEFT = Vector2D(box->x, box->y); const auto FULLSIZE = Vector2D(box->width, box->height); static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; // Rounded corners glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); - glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y); glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y); glUniform1f(m_RenderData.pCurrentMonData->m_shQUAD.radius, round); glUniform1i(m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample, (int)(*PMULTISAMPLEEDGES == 1 && round != 0)); @@ -438,9 +436,8 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; // Rounded corners - glUniform2f(shader->topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); - glUniform2f(shader->bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y); - glUniform2f(shader->fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y); + glUniform2f(shader->topLeft, pBox->x, pBox->y); + glUniform2f(shader->fullSize, pBox->width, pBox->height); glUniform1f(shader->radius, round); glUniform1i(shader->primitiveMultisample, (int)(*PMULTISAMPLEEDGES == 1 && round != 0 && !noAA)); diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp index 42bd0856..a7c53aea 100644 --- a/src/render/shaders/Textures.hpp +++ b/src/render/shaders/Textures.hpp @@ -6,10 +6,10 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar return R"#( // branchless baby! - vec2 bottomRight = fullSize - radius; - vec2 pixCoord = v_texcoord - vec2(0.5); - pixCoord *= (vec2(lessThan(pixCoord, vec2(0.0))) * vec2(-2.0) + vec2(1.0)) * fullSize; - pixCoord -= (bottomRight - topLeft) * vec2(0.5); + highp vec2 pixCoord = vec2(gl_FragCoord); + pixCoord -= (topLeft + fullSize / vec2(2.0)); + pixCoord *= (vec2(lessThan(pixCoord, vec2(0.0))) * vec2(-2.0) + vec2(1.0)); + pixCoord -= fullSize * vec2(0.5) - vec2(radius); if (all(greaterThan(pixCoord, vec2(0.0)))) {