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
This commit is contained in:
parent
b4d491a4d2
commit
ea2ddaa9dd
@ -323,21 +323,18 @@ update_brightness_uniform (ShellBlurEffect *self)
|
|||||||
static void
|
static void
|
||||||
setup_projection_matrix (CoglFramebuffer *framebuffer,
|
setup_projection_matrix (CoglFramebuffer *framebuffer,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height)
|
||||||
float downscale_factor)
|
|
||||||
{
|
{
|
||||||
CoglMatrix projection;
|
CoglMatrix projection;
|
||||||
float downscaled_width = width / downscale_factor;
|
|
||||||
float downscaled_height = height / downscale_factor;
|
|
||||||
|
|
||||||
cogl_matrix_init_identity (&projection);
|
cogl_matrix_init_identity (&projection);
|
||||||
cogl_matrix_scale (&projection,
|
cogl_matrix_scale (&projection,
|
||||||
2.0 / downscaled_width,
|
2.0 / width,
|
||||||
-2.0 / downscaled_height,
|
-2.0 / height,
|
||||||
1.f);
|
1.f);
|
||||||
cogl_matrix_translate (&projection,
|
cogl_matrix_translate (&projection,
|
||||||
-downscaled_width / 2.0,
|
-width / 2.0,
|
||||||
-downscaled_height / 2.0,
|
-height / 2.0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
cogl_framebuffer_set_projection_matrix (framebuffer, &projection);
|
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->texture, cogl_object_unref);
|
||||||
g_clear_pointer (&data->framebuffer, cogl_object_unref);
|
g_clear_pointer (&data->framebuffer, cogl_object_unref);
|
||||||
|
|
||||||
data->texture =
|
float new_width = floorf (width / downscale_factor);
|
||||||
cogl_texture_2d_new_with_size (ctx,
|
float new_height = floorf (height / downscale_factor);
|
||||||
width / downscale_factor,
|
|
||||||
height / downscale_factor);
|
data->texture = cogl_texture_2d_new_with_size (ctx, new_width, new_height);
|
||||||
if (!data->texture)
|
if (!data->texture)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -371,7 +368,7 @@ update_fbo (FramebufferData *data,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_projection_matrix (data->framebuffer, width, height, downscale_factor);
|
setup_projection_matrix (data->framebuffer, new_width, new_height);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user