Send absolute screen coordinates to texture shaders.

This commit is contained in:
Felix Dick 2022-09-29 23:19:56 +02:00
parent e5dced8b3f
commit 6eb7d00386
2 changed files with 7 additions and 10 deletions

View file

@ -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));

View file

@ -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)))) {