[gnome-shell] blur-effect: Floor downscaled frambuffer sizes
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] blur-effect: Floor downscaled frambuffer sizes
- Date: Wed, 12 Feb 2020 14:15:58 +0000 (UTC)
commit ea2ddaa9ddaa643fce99d5eb6a948b0b0d3553fa
Author: Jonas Dreßler <verdre v0yd nl>
Date: Mon Feb 10 15:22:33 2020 +0100
blur-effect: Floor downscaled frambuffer sizes
Floor the downscaled size of the new framebuffer to make sure we don't
initialize a framebuffer with a floating point value that might be
interpreted wrong by `cogl_texture_2d_new_with_size` and end up with a
slightly wrong aspect ratio of the framebuffer.
This fixes situations where the widths or heights of downscaled
framebuffers sometimes miss some pixels at the border.
While at it, remove the `downscale_factor` argument from
`setup_projection_matrix` since that function doesn't need the initial
size of the actor anyway.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
src/shell-blur-effect.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/src/shell-blur-effect.c b/src/shell-blur-effect.c
index 7f1be6b1df..e40bb542a2 100644
--- a/src/shell-blur-effect.c
+++ b/src/shell-blur-effect.c
@@ -323,21 +323,18 @@ update_brightness_uniform (ShellBlurEffect *self)
static void
setup_projection_matrix (CoglFramebuffer *framebuffer,
float width,
- float height,
- float downscale_factor)
+ float height)
{
CoglMatrix projection;
- float downscaled_width = width / downscale_factor;
- float downscaled_height = height / downscale_factor;
cogl_matrix_init_identity (&projection);
cogl_matrix_scale (&projection,
- 2.0 / downscaled_width,
- -2.0 / downscaled_height,
+ 2.0 / width,
+ -2.0 / height,
1.f);
cogl_matrix_translate (&projection,
- -downscaled_width / 2.0,
- -downscaled_height / 2.0,
+ -width / 2.0,
+ -height / 2.0,
0);
cogl_framebuffer_set_projection_matrix (framebuffer, &projection);
@@ -355,10 +352,10 @@ update_fbo (FramebufferData *data,
g_clear_pointer (&data->texture, cogl_object_unref);
g_clear_pointer (&data->framebuffer, cogl_object_unref);
- data->texture =
- cogl_texture_2d_new_with_size (ctx,
- width / downscale_factor,
- height / downscale_factor);
+ float new_width = floorf (width / downscale_factor);
+ float new_height = floorf (height / downscale_factor);
+
+ data->texture = cogl_texture_2d_new_with_size (ctx, new_width, new_height);
if (!data->texture)
return FALSE;
@@ -371,7 +368,7 @@ update_fbo (FramebufferData *data,
return FALSE;
}
- setup_projection_matrix (data->framebuffer, width, height, downscale_factor);
+ setup_projection_matrix (data->framebuffer, new_width, new_height);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]