[mutter] clutter: Simplify framebuffer setup using ortho projection



commit 53f7b6c1499473ba3d9f7ad3f2c0ea9d2234a5d0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 16 10:27:42 2020 -0300

    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>

 clutter/clutter/clutter-blur.c        | 17 +++++------------
 clutter/clutter/clutter-paint-nodes.c | 11 ++++-------
 2 files changed, 9 insertions(+), 19 deletions(-)
---
diff --git a/clutter/clutter/clutter-blur.c b/clutter/clutter/clutter-blur.c
index 0531bdd455..8c8cde9ae3 100644
--- a/clutter/clutter/clutter-blur.c
+++ b/clutter/clutter/clutter-blur.c
@@ -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;
 }
 
diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c
index ac4181f412..965bceaf1f 100644
--- a/clutter/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter/clutter-paint-nodes.c
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]