clutter: Simplify framebuffer setup using ortho projection

Setting an ortho projection gives us pretty much the same result as
manually calculating the projection matrix. The ortho projection is
actually more "complete" than the custom projection we've been using,
as it also considers z-near and z-far, but in practice the generated
pixels are exactly equal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1642>
This commit is contained in:
Georges Basile Stavracas Neto 2020-12-16 10:27:42 -03:00
parent 95e0bf34e9
commit 53f7b6c149
2 changed files with 9 additions and 19 deletions

View File

@ -222,7 +222,6 @@ create_fbo (ClutterBlur *blur,
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
graphene_matrix_t projection;
float scaled_height;
float scaled_width;
float height;
@ -250,17 +249,11 @@ create_fbo (ClutterBlur *blur,
return FALSE;
}
graphene_matrix_init_translate (&projection,
&GRAPHENE_POINT3D_INIT (-scaled_width / 2.f,
-scaled_height / 2.f,
0.f));
graphene_matrix_scale (&projection,
2.f / scaled_width,
-2.f / scaled_height,
1.f);
cogl_framebuffer_set_projection_matrix (pass->framebuffer, &projection);
cogl_framebuffer_orthographic (pass->framebuffer,
0.0, 0.0,
scaled_width,
scaled_height,
0.0, 1.0);
return TRUE;
}

View File

@ -1901,7 +1901,6 @@ clutter_blur_node_new (unsigned int width,
{
g_autoptr (CoglOffscreen) offscreen = NULL;
g_autoptr (GError) error = NULL;
graphene_matrix_t projection;
ClutterLayerNode *layer_node;
ClutterBlurNode *blur_node;
CoglTexture2D *tex_2d;
@ -1945,12 +1944,10 @@ clutter_blur_node_new (unsigned int width,
0,
clutter_blur_get_texture (blur));
graphene_matrix_init_translate (&projection,
&GRAPHENE_POINT3D_INIT (-(width / 2.f),
-(height / 2.f),
0.f));
graphene_matrix_scale (&projection, 2.f / width, -2.f / height, 1.f);
cogl_framebuffer_set_projection_matrix (layer_node->offscreen, &projection);
cogl_framebuffer_orthographic (layer_node->offscreen,
0.0, 0.0,
width, height,
0.0, 1.0);
out:
return (ClutterPaintNode *) blur_node;