[mutter] cullable: Factor out untransformed check into a vfunc



commit 56ce25360c0849566c1a795021c765954f0bd4e1
Author: Robert Mader <robert mader posteo de>
Date:   Mon Feb 3 18:36:13 2020 +0100

    cullable: Factor out untransformed check into a vfunc
    
    Some cullable implementation may have extra information about their
    expected size. The main example here are surface actors which can be scaled
    by geometry scale.
    
    Add an API to overwrite the default size / untransformed check for such cases.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036

 src/compositor/clutter-utils.c     | 17 -----------------
 src/compositor/clutter-utils.h     |  3 ---
 src/compositor/meta-cullable.c     | 29 ++++++++++++++++++++++++++++-
 src/compositor/meta-cullable.h     |  2 ++
 src/compositor/meta-window-group.c |  2 +-
 5 files changed, 31 insertions(+), 22 deletions(-)
---
diff --git a/src/compositor/clutter-utils.c b/src/compositor/clutter-utils.c
index a399cd477..949d99ba1 100644
--- a/src/compositor/clutter-utils.c
+++ b/src/compositor/clutter-utils.c
@@ -110,23 +110,6 @@ meta_actor_vertices_are_untransformed (graphene_point3d_t *verts,
   return TRUE;
 }
 
-/* Check if an actor is "untransformed" - which actually means transformed by
- * at most a integer-translation. The integer translation, if any, is returned.
- */
-gboolean
-meta_actor_is_untransformed (ClutterActor *actor,
-                             int          *x_origin,
-                             int          *y_origin)
-{
-  gfloat widthf, heightf;
-  graphene_point3d_t verts[4];
-
-  clutter_actor_get_size (actor, &widthf, &heightf);
-  clutter_actor_get_abs_allocation_vertices (actor, verts);
-
-  return meta_actor_vertices_are_untransformed (verts, widthf, heightf, x_origin, y_origin);
-}
-
 /**
  * meta_actor_painting_untransformed:
  * @paint_width: the width of the painted area
diff --git a/src/compositor/clutter-utils.h b/src/compositor/clutter-utils.h
index d0513393e..a1fe6b739 100644
--- a/src/compositor/clutter-utils.h
+++ b/src/compositor/clutter-utils.h
@@ -28,9 +28,6 @@ gboolean meta_actor_vertices_are_untransformed (graphene_point3d_t *verts,
                                                 float               heightf,
                                                 int                *x_origin,
                                                 int                *y_origin);
-gboolean meta_actor_is_untransformed (ClutterActor *actor,
-                                      int          *x_origin,
-                                      int          *y_origin);
 
 gboolean meta_actor_painting_untransformed (CoglFramebuffer *fb,
                                             int              paint_width,
diff --git a/src/compositor/meta-cullable.c b/src/compositor/meta-cullable.c
index 5cdc03a6d..9f4f0a642 100644
--- a/src/compositor/meta-cullable.c
+++ b/src/compositor/meta-cullable.c
@@ -100,7 +100,7 @@ meta_cullable_cull_out_children (MetaCullable   *cullable,
       if (needs_culling && clutter_actor_has_effects (child))
         needs_culling = FALSE;
 
-      if (needs_culling && !meta_actor_is_untransformed (child, NULL, NULL))
+      if (needs_culling && !meta_cullable_is_untransformed (META_CULLABLE (child)))
         needs_culling = FALSE;
 
       if (needs_culling)
@@ -149,9 +149,23 @@ meta_cullable_reset_culling_children (MetaCullable *cullable)
     }
 }
 
+static gboolean
+meta_cullable_default_is_untransformed (MetaCullable *cullable)
+{
+  float width, height;
+  graphene_point3d_t verts[4];
+
+  clutter_actor_get_size (CLUTTER_ACTOR (cullable), &width, &height);
+  clutter_actor_get_abs_allocation_vertices (CLUTTER_ACTOR (cullable), verts);
+
+  return meta_actor_vertices_are_untransformed (verts, width, height,
+                                                NULL, NULL);
+}
+
 static void
 meta_cullable_default_init (MetaCullableInterface *iface)
 {
+  iface->is_untransformed = meta_cullable_default_is_untransformed;
 }
 
 /**
@@ -186,6 +200,19 @@ meta_cullable_cull_out (MetaCullable   *cullable,
   META_CULLABLE_GET_IFACE (cullable)->cull_out (cullable, unobscured_region, clip_region);
 }
 
+/**
+ * meta_cullable_is_untransformed:
+ * @cullable: The #MetaCullable
+ *
+ * Check if a cullable is "untransformed" - which actually means transformed by
+ * at most a integer-translation.
+ */
+gboolean
+meta_cullable_is_untransformed (MetaCullable *cullable)
+{
+  return META_CULLABLE_GET_IFACE (cullable)->is_untransformed (cullable);
+}
+
 /**
  * meta_cullable_reset_culling:
  * @cullable: The #MetaCullable
diff --git a/src/compositor/meta-cullable.h b/src/compositor/meta-cullable.h
index fc1720c8d..471681da3 100644
--- a/src/compositor/meta-cullable.h
+++ b/src/compositor/meta-cullable.h
@@ -39,12 +39,14 @@ struct _MetaCullableInterface
   void (* cull_out)      (MetaCullable   *cullable,
                           cairo_region_t *unobscured_region,
                           cairo_region_t *clip_region);
+  gboolean (* is_untransformed) (MetaCullable *cullable);
   void (* reset_culling) (MetaCullable  *cullable);
 };
 
 void meta_cullable_cull_out (MetaCullable   *cullable,
                              cairo_region_t *unobscured_region,
                              cairo_region_t *clip_region);
+gboolean meta_cullable_is_untransformed (MetaCullable *cullable);
 void meta_cullable_reset_culling (MetaCullable *cullable);
 
 /* Utility methods for implementations */
diff --git a/src/compositor/meta-window-group.c b/src/compositor/meta-window-group.c
index 76ba88e61..cca22b87d 100644
--- a/src/compositor/meta-window-group.c
+++ b/src/compositor/meta-window-group.c
@@ -89,7 +89,7 @@ meta_window_group_paint (ClutterActor        *actor,
                                               screen_height,
                                               &paint_x_origin,
                                               &paint_y_origin) ||
-          !meta_actor_is_untransformed (actor, NULL, NULL))
+          !meta_cullable_is_untransformed (META_CULLABLE (actor)))
         {
           CLUTTER_ACTOR_CLASS (meta_window_group_parent_class)->paint (actor,
                                                                        paint_context);


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