[mutter/gbsneto/graphene-matrix: 1/7] shaped-texture: Use graphene APIs




commit 99866c93f799a26638573feb16ed61a34478f8a6
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Sep 11 19:07:06 2020 -0300

    shaped-texture: Use graphene APIs
    
    This is a slightly delicate port; much like the ClutterActor port,
    using graphene required swapping the order of operations upside down.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 src/compositor/meta-shaped-texture.c | 76 +++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 36 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 8bbbffa84f..2637a63fe4 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -288,20 +288,14 @@ get_base_pipeline (MetaShapedTexture *stex,
   cogl_pipeline_set_layer_wrap_mode_t (pipeline, 1,
                                        COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
 
-  cogl_matrix_init_identity (&matrix);
-
-  if (!stex->is_y_inverted)
-    {
-      cogl_matrix_scale (&matrix, 1, -1, 1);
-      cogl_matrix_translate (&matrix, 0, -1, 0);
-      cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
-    }
+  graphene_matrix_init_identity (&matrix);
 
   if (stex->transform != META_MONITOR_TRANSFORM_NORMAL)
     {
       graphene_euler_t euler;
 
-      cogl_matrix_translate (&matrix, 0.5, 0.5, 0.0);
+      graphene_matrix_translate (&matrix,
+                                 &GRAPHENE_POINT3D_INIT (-0.5, -0.5, 0.0));
       switch (stex->transform)
         {
         case META_MONITOR_TRANSFORM_90:
@@ -335,40 +329,50 @@ get_base_pipeline (MetaShapedTexture *stex,
         case META_MONITOR_TRANSFORM_NORMAL:
           g_assert_not_reached ();
         }
-      cogl_matrix_rotate_euler (&matrix, &euler);
-      cogl_matrix_translate (&matrix, -0.5, -0.5, 0.0);
+      graphene_matrix_rotate_euler (&matrix, &euler);
+      graphene_matrix_translate (&matrix,
+                                 &GRAPHENE_POINT3D_INIT (0.5, 0.5, 0.0));
     }
 
   if (stex->has_viewport_src_rect)
     {
       float scaled_tex_width = stex->tex_width / (float) stex->buffer_scale;
       float scaled_tex_height = stex->tex_height / (float) stex->buffer_scale;
+      graphene_point3d_t p;
+
+      graphene_point3d_init (&p,
+                             stex->viewport_src_rect.origin.x /
+                             stex->viewport_src_rect.size.width,
+                             stex->viewport_src_rect.origin.y /
+                             stex->viewport_src_rect.size.height,
+                             0);
+      graphene_matrix_translate (&matrix, &p);
 
       if (meta_monitor_transform_is_rotated (stex->transform))
         {
-          cogl_matrix_scale (&matrix,
-                             stex->viewport_src_rect.size.width /
-                             scaled_tex_height,
-                             stex->viewport_src_rect.size.height /
-                             scaled_tex_width,
-                             1);
+          graphene_matrix_scale (&matrix,
+                                 stex->viewport_src_rect.size.width /
+                                 scaled_tex_height,
+                                 stex->viewport_src_rect.size.height /
+                                 scaled_tex_width,
+                                 1);
         }
       else
         {
-          cogl_matrix_scale (&matrix,
-                             stex->viewport_src_rect.size.width /
-                             scaled_tex_width,
-                             stex->viewport_src_rect.size.height /
-                             scaled_tex_height,
-                             1);
+          graphene_matrix_scale (&matrix,
+                                 stex->viewport_src_rect.size.width /
+                                 scaled_tex_width,
+                                 stex->viewport_src_rect.size.height /
+                                 scaled_tex_height,
+                                 1);
         }
+    }
 
-      cogl_matrix_translate (&matrix,
-                             stex->viewport_src_rect.origin.x /
-                             stex->viewport_src_rect.size.width,
-                             stex->viewport_src_rect.origin.y /
-                             stex->viewport_src_rect.size.height,
-                             0);
+  if (!stex->is_y_inverted)
+    {
+      graphene_matrix_translate (&matrix, &GRAPHENE_POINT3D_INIT (0, -1, 0));
+      graphene_matrix_scale (&matrix, 1, -1, 1);
+      cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
     }
 
   cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
@@ -1403,13 +1407,13 @@ get_image_via_offscreen (MetaShapedTexture     *stex,
     }
 
   cogl_framebuffer_push_matrix (fb);
-  cogl_matrix_init_identity (&projection_matrix);
-  cogl_matrix_scale (&projection_matrix,
-                     1.0 / (image_width / 2.0),
-                     -1.0 / (image_height / 2.0), 0);
-  cogl_matrix_translate (&projection_matrix,
-                         -(image_width / 2.0),
-                         -(image_height / 2.0), 0);
+  graphene_matrix_init_translate (&projection_matrix,
+                                  &GRAPHENE_POINT3D_INIT (-(image_width / 2.0),
+                                                          -(image_height / 2.0),
+                                                          0));
+  graphene_matrix_scale (&projection_matrix,
+                         1.0 / (image_width / 2.0),
+                         -1.0 / (image_height / 2.0), 0);
 
   cogl_framebuffer_set_projection_matrix (fb, &projection_matrix);
 


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