[mutter/gbsneto/graphene-matrix: 5/42] clutter: Explicitly initiate CoglMatrices




commit 45ba22f8cead41b6353184ac75f96c5abc7c7dbe
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Sep 10 16:04:48 2020 -0300

    clutter: Explicitly initiate CoglMatrices
    
    Instead of relying on the macro. The macro will go away in the
    next commit as part of using graphene_matrix_t in the CoglMatrix
    structure.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 clutter/clutter/clutter-actor.c        | 25 ++++++++++++++++++++-----
 clutter/clutter/clutter-scroll-actor.c |  4 +++-
 2 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index b689bf033d..3559b4d64e 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -4418,7 +4418,7 @@ clutter_actor_remove_child_internal (ClutterActor                 *self,
   g_object_unref (child);
 }
 
-static const ClutterTransformInfo default_transform_info = {
+static ClutterTransformInfo default_transform_info = {
   0.0,                          /* rotation-x */
   0.0,                          /* rotation-y */
   0.0,                          /* rotation-z */
@@ -4432,12 +4432,27 @@ static const ClutterTransformInfo default_transform_info = {
   GRAPHENE_POINT_INIT_ZERO,     /* pivot */
   0.f,                          /* pivot-z */
 
-  COGL_MATRIX_INIT_IDENTITY,
+  { },
   FALSE,                        /* transform */
-  COGL_MATRIX_INIT_IDENTITY,
+  { },
   FALSE,                        /* child-transform */
 };
 
+static inline const ClutterTransformInfo *
+get_default_transform_info (void)
+{
+  static gsize initialized = FALSE;
+
+  if (G_UNLIKELY (g_once_init_enter (&initialized)))
+    {
+      cogl_matrix_init_identity (&default_transform_info.transform);
+      cogl_matrix_init_identity (&default_transform_info.child_transform);
+      g_once_init_leave (&initialized, TRUE);
+    }
+
+  return &default_transform_info;
+}
+
 /*< private >
  * _clutter_actor_get_transform_info_or_defaults:
  * @self: a #ClutterActor
@@ -4460,7 +4475,7 @@ _clutter_actor_get_transform_info_or_defaults (ClutterActor *self)
   if (info != NULL)
     return info;
 
-  return &default_transform_info;
+  return get_default_transform_info ();
 }
 
 static void
@@ -4497,7 +4512,7 @@ _clutter_actor_get_transform_info (ClutterActor *self)
     {
       info = g_slice_new (ClutterTransformInfo);
 
-      *info = default_transform_info;
+      *info = *get_default_transform_info ();
 
       g_object_set_qdata_full (G_OBJECT (self), quark_actor_transform_info,
                                info,
diff --git a/clutter/clutter/clutter-scroll-actor.c b/clutter/clutter/clutter-scroll-actor.c
index e06247dd4d..289c81686d 100644
--- a/clutter/clutter/clutter-scroll-actor.c
+++ b/clutter/clutter/clutter-scroll-actor.c
@@ -99,9 +99,11 @@ clutter_scroll_actor_set_scroll_to_internal (ClutterScrollActor     *self,
 {
   ClutterScrollActorPrivate *priv = self->priv;
   ClutterActor *actor = CLUTTER_ACTOR (self);
-  CoglMatrix m = COGL_MATRIX_INIT_IDENTITY;
+  CoglMatrix m;
   float dx, dy;
 
+  cogl_matrix_init_identity (&m);
+
   if (graphene_point_equal (&priv->scroll_to, point))
     return;
 


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