Skip to content

Commit

Permalink
rounded-corners: fix scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
taj-ny committed Dec 12, 2024
1 parent a4f2274 commit 05e7c39
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ BlurEffect::BlurEffect()
m_texture.textureSizeLocation = m_texture.shader->uniformLocation("textureSize");
m_texture.texStartPosLocation = m_texture.shader->uniformLocation("texStartPos");
m_texture.blurSizeLocation = m_texture.shader->uniformLocation("blurSize");
m_texture.scaleLocation = m_texture.shader->uniformLocation("scale");
m_texture.topCornerRadiusLocation = m_texture.shader->uniformLocation("topCornerRadius");
m_texture.bottomCornerRadiusLocation = m_texture.shader->uniformLocation("bottomCornerRadius");
m_texture.antialiasingLocation = m_texture.shader->uniformLocation("antialiasing");
Expand Down Expand Up @@ -958,9 +957,8 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg

m_texture.shader->setUniform(m_texture.mvpMatrixLocation, projectionMatrix);
m_texture.shader->setUniform(m_texture.textureSizeLocation, QVector2D(fakeBlurTexture->size().width(), fakeBlurTexture->size().height()));
m_texture.shader->setUniform(m_texture.texStartPosLocation, QVector2D(backgroundRect.x() - screenGeometry.x(), backgroundRect.y() - screenGeometry.y()));
m_texture.shader->setUniform(m_texture.blurSizeLocation, QVector2D(backgroundRect.width(), backgroundRect.height()));
m_texture.shader->setUniform(m_texture.scaleLocation, (float)viewport.scale());
m_texture.shader->setUniform(m_texture.texStartPosLocation, QVector2D(deviceBackgroundRect.x() - screenGeometry.x(), deviceBackgroundRect.y() - screenGeometry.y()));
m_texture.shader->setUniform(m_texture.blurSizeLocation, QVector2D(deviceBackgroundRect.width(), deviceBackgroundRect.height()));
m_texture.shader->setUniform(m_texture.topCornerRadiusLocation, topCornerRadius);
m_texture.shader->setUniform(m_texture.bottomCornerRadiusLocation, bottomCornerRadius);
m_texture.shader->setUniform(m_texture.antialiasingLocation, m_settings.roundedCorners.antialiasing);
Expand Down Expand Up @@ -1050,7 +1048,7 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg
m_upsamplePass.shader->setUniform(m_upsamplePass.topCornerRadiusLocation, topCornerRadius);
m_upsamplePass.shader->setUniform(m_upsamplePass.bottomCornerRadiusLocation, bottomCornerRadius);
m_upsamplePass.shader->setUniform(m_upsamplePass.antialiasingLocation, m_settings.roundedCorners.antialiasing);
m_upsamplePass.shader->setUniform(m_upsamplePass.blurSizeLocation, QVector2D(backgroundRect.width(), backgroundRect.height()));
m_upsamplePass.shader->setUniform(m_upsamplePass.blurSizeLocation, QVector2D(deviceBackgroundRect.width(), deviceBackgroundRect.height()));
m_upsamplePass.shader->setUniform(m_upsamplePass.opacityLocation, static_cast<float>(opacity));

projectionMatrix = viewport.projectionMatrix();
Expand Down
1 change: 0 additions & 1 deletion src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public Q_SLOTS:
int mvpMatrixLocation;
int textureSizeLocation;
int texStartPosLocation;
int scaleLocation;

int topCornerRadiusLocation;
int bottomCornerRadiusLocation;
Expand Down
3 changes: 1 addition & 2 deletions src/shaders/texture.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
uniform sampler2D texUnit;
uniform vec2 textureSize;
uniform vec2 texStartPos;
uniform float scale;

varying vec2 uv;

void main(void)
{
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize * scale;
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize;
gl_FragColor = roundedRectangle(uv * blurSize, texture2D(texUnit, tex).rgb);
}
3 changes: 1 addition & 2 deletions src/shaders/texture_core.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
uniform sampler2D texUnit;
uniform vec2 textureSize;
uniform vec2 texStartPos;
uniform float scale;

in vec2 uv;

out vec4 fragColor;

void main(void)
{
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize * scale;
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize;
fragColor = roundedRectangle(uv * blurSize, texture(texUnit, tex).rgb);
}

0 comments on commit 05e7c39

Please sign in to comment.