[mutter/gbsneto/graphene: 1/3] Replace ClutterRect by graphene_rect_t



commit 7df3606e657834dd67ea11c9d0754a575409f721
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Feb 20 12:23:04 2019 -0300

    Replace ClutterRect by graphene_rect_t
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/458

 clutter/clutter/clutter-actor.c                    |  18 +-
 clutter/clutter/clutter-autocleanups.h             |   1 -
 clutter/clutter/clutter-base-types.c               | 614 +--------------------
 clutter/clutter/clutter-deform-effect.c            |   6 +-
 clutter/clutter/clutter-drag-action.c              |  16 +-
 clutter/clutter/clutter-drag-action.h              |   6 +-
 clutter/clutter/clutter-graphene.c                 |  19 +
 clutter/clutter/clutter-input-focus.c              |   4 +-
 clutter/clutter/clutter-input-focus.h              |   4 +-
 clutter/clutter/clutter-input-method-private.h     |   4 +-
 clutter/clutter/clutter-input-method.c             |   6 +-
 clutter/clutter/clutter-input-method.h             |   4 +-
 clutter/clutter/clutter-offscreen-effect.c         |  12 +-
 clutter/clutter/clutter-offscreen-effect.h         |   2 +-
 clutter/clutter/clutter-private.h                  |   4 +-
 clutter/clutter/clutter-scroll-actor.c             |   8 +-
 clutter/clutter/clutter-scroll-actor.h             |   4 +-
 clutter/clutter/clutter-stage-private.h            |   6 +-
 clutter/clutter/clutter-stage.c                    |  12 +-
 clutter/clutter/clutter-text.c                     |  34 +-
 clutter/clutter/clutter-text.h                     |   2 +-
 clutter/clutter/clutter-types.h                    | 121 +---
 clutter/clutter/clutter-util.c                     |  10 +-
 clutter/clutter/cogl/clutter-stage-cogl.c          |  16 +-
 src/backends/meta-cursor-renderer.c                |  14 +-
 src/backends/meta-cursor-renderer.h                |   4 +-
 src/backends/meta-screen-cast-monitor-stream-src.c |  20 +-
 src/backends/meta-stage-private.h                  |   8 +-
 src/backends/meta-stage.c                          |  26 +-
 src/backends/native/meta-cursor-renderer-native.c  |  50 +-
 src/compositor/meta-shaped-texture-private.h       |   2 +-
 src/compositor/meta-shaped-texture.c               |  12 +-
 src/compositor/meta-surface-actor.c                |   4 +-
 src/compositor/meta-surface-actor.h                |   4 +-
 src/compositor/region-utils.c                      |   8 +-
 src/compositor/region-utils.h                      |   8 +-
 src/core/boxes-private.h                           |  14 +-
 src/core/boxes.c                                   |  36 +-
 src/core/display.c                                 |  12 +-
 src/wayland/meta-wayland-cursor-surface.c          |   6 +-
 src/wayland/meta-wayland-surface.c                 |   6 +-
 src/wayland/meta-wayland-surface.h                 |   4 +-
 src/wayland/meta-wayland-text-input-legacy.c       |   4 +-
 src/wayland/meta-wayland-text-input.c              |   4 +-
 44 files changed, 235 insertions(+), 944 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 9f77034a3..f6a849258 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -701,7 +701,7 @@ struct _ClutterActorPrivate
   ClutterAllocationFlags allocation_flags;
 
   /* clip, in actor coordinates */
-  ClutterRect clip;
+  graphene_rect_t clip;
 
   /* the cached transformation matrix; see apply_transform() */
   CoglMatrix transform;
@@ -5027,8 +5027,8 @@ clutter_actor_set_anchor_coord (ClutterActor      *self,
 }
 
 static void
-clutter_actor_set_clip_rect (ClutterActor      *self,
-                             const ClutterRect *clip)
+clutter_actor_set_clip_rect (ClutterActor          *self,
+                             const graphene_rect_t *clip)
 {
   ClutterActorPrivate *priv = self->priv;
   GObject *obj = G_OBJECT (self);
@@ -6945,7 +6945,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
    * ClutterActor:clip-rect:
    *
    * The visible region of the actor, in actor-relative coordinates,
-   * expressed as a #ClutterRect.
+   * expressed as a #graphene_rect_t.
    *
    * Setting this property to %NULL will unset the existing clip.
    *
@@ -6958,7 +6958,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
     g_param_spec_boxed ("clip-rect",
                         P_("Clip Rectangle"),
                         P_("The visible region of the actor"),
-                        CLUTTER_TYPE_RECT,
+                        GRAPHENE_TYPE_RECT,
                         G_PARAM_READWRITE |
                         G_PARAM_STATIC_STRINGS);
 
@@ -17853,9 +17853,9 @@ clutter_actor_get_paint_box (ClutterActor    *self,
 }
 
 static gboolean
-_clutter_actor_get_resource_scale_for_rect (ClutterActor *self,
-                                            ClutterRect  *bounding_rect,
-                                            float        *resource_scale)
+_clutter_actor_get_resource_scale_for_rect (ClutterActor    *self,
+                                            graphene_rect_t *bounding_rect,
+                                            float           *resource_scale)
 {
   ClutterActor *stage;
   float max_scale = 0;
@@ -17878,7 +17878,7 @@ static gboolean
 _clutter_actor_compute_resource_scale (ClutterActor *self,
                                        float        *resource_scale)
 {
-  ClutterRect bounding_rect;
+  graphene_rect_t bounding_rect;
   ClutterActorPrivate *priv = self->priv;
 
   if (CLUTTER_ACTOR_IN_DESTRUCTION (self) ||
diff --git a/clutter/clutter/clutter-autocleanups.h b/clutter/clutter/clutter-autocleanups.h
index 5d30c131f..c9b0da2cd 100644
--- a/clutter/clutter/clutter-autocleanups.h
+++ b/clutter/clutter/clutter-autocleanups.h
@@ -94,7 +94,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterMatrix, clutter_matrix_free)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintNode, clutter_paint_node_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintVolume, clutter_paint_volume_free)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathNode, clutter_path_node_free)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free)
 
 #endif /* __GI_SCANNER__ */
 
diff --git a/clutter/clutter/clutter-base-types.c b/clutter/clutter/clutter-base-types.c
index b4d660087..83920519b 100644
--- a/clutter/clutter/clutter-base-types.c
+++ b/clutter/clutter/clutter-base-types.c
@@ -68,7 +68,7 @@ clutter_geometry_free (ClutterGeometry *geometry)
  *
  * Since: 1.4
  *
- * Deprecated: 1.16: Use #ClutterRect and clutter_rect_union()
+ * Deprecated: 1.16: Use #graphene_rect_t and graphene_rect_union()
  */
 void
 clutter_geometry_union (const ClutterGeometry *geometry_a,
@@ -102,7 +102,7 @@ clutter_geometry_union (const ClutterGeometry *geometry_a,
  *
  * Since: 1.4
  *
- * Deprecated: 1.16: Use #ClutterRect and clutter_rect_intersection()
+ * Deprecated: 1.16: Use #graphene_rect_t and graphene_rect_intersection()
  */
 gboolean
 clutter_geometry_intersects (const ClutterGeometry *geometry0,
@@ -210,616 +210,6 @@ G_DEFINE_BOXED_TYPE (ClutterMargin, clutter_margin,
                      clutter_margin_copy,
                      clutter_margin_free)
 
-
-
-/*
- * ClutterRect
- */
-
-static const ClutterRect _clutter_rect_zero = CLUTTER_RECT_INIT_ZERO;
-
-static gboolean clutter_rect_progress (const GValue *a,
-                                       const GValue *b,
-                                       gdouble       progress,
-                                       GValue       *res);
-
-G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterRect, clutter_rect,
-                               clutter_rect_copy,
-                               clutter_rect_free,
-                               CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_rect_progress))
-
-static inline void
-clutter_rect_normalize_internal (ClutterRect *rect)
-{
-  if (rect->size.width >= 0.f && rect->size.height >= 0.f)
-    return;
-
-  if (rect->size.width < 0.f)
-    {
-      float size = fabsf (rect->size.width);
-
-      rect->origin.x -= size;
-      rect->size.width = size;
-    }
-
-  if (rect->size.height < 0.f)
-    {
-      float size = fabsf (rect->size.height);
-
-      rect->origin.y -= size;
-      rect->size.height = size;
-    }
-}
-
-/**
- * clutter_rect_zero:
- *
- * A #ClutterRect with #ClutterRect.origin set at (0, 0) and a size
- * of 0.
- *
- * The returned value can be used as a guard.
- *
- * Return value: a rectangle with origin in (0, 0) and a size of 0.
- *   The returned #ClutterRect is owned by Clutter and it should not
- *   be modified or freed.
- *
- * Since: 1.12
- */
-const ClutterRect *
-clutter_rect_zero (void)
-{
-  return &_clutter_rect_zero;
-}
-
-/**
- * clutter_rect_alloc: (constructor)
- *
- * Creates a new, empty #ClutterRect.
- *
- * You can use clutter_rect_init() to initialize the returned rectangle,
- * for instance:
- *
- * |[
- *   rect = clutter_rect_init (clutter_rect_alloc (), x, y, width, height);
- * ]|
- *
- * Return value: (transfer full): the newly allocated #ClutterRect.
- *   Use clutter_rect_free() to free its resources
- *
- * Since: 1.12
- */
-ClutterRect *
-clutter_rect_alloc (void)
-{
-  return g_slice_new0 (ClutterRect);
-}
-
-/**
- * clutter_rect_init:
- * @rect: a #ClutterRect
- * @x: X coordinate of the origin
- * @y: Y coordinate of the origin
- * @width: width of the rectangle
- * @height: height of the rectangle
- *
- * Initializes a #ClutterRect with the given origin and size.
- *
- * Return value: (transfer none): the updated rectangle
- *
- * Since: 1.12
- */
-ClutterRect *
-clutter_rect_init (ClutterRect *rect,
-                   float        x,
-                   float        y,
-                   float        width,
-                   float        height)
-{
-  g_return_val_if_fail (rect != NULL, NULL);
-
-  rect->origin.x = x;
-  rect->origin.y = y;
-
-  rect->size.width = width;
-  rect->size.height = height;
-
-  return rect;
-}
-
-/**
- * clutter_rect_copy:
- * @rect: a #ClutterRect
- *
- * Copies @rect into a new #ClutterRect instance.
- *
- * Return value: (transfer full): the newly allocate copy of @rect.
- *   Use clutter_rect_free() to free the associated resources
- *
- * Since: 1.12
- */
-ClutterRect *
-clutter_rect_copy (const ClutterRect *rect)
-{
-  if (rect != NULL)
-    {
-      ClutterRect *res;
-
-      res = g_slice_dup (ClutterRect, rect);
-      clutter_rect_normalize_internal (res);
-
-      return res;
-    }
-
-  return NULL;
-}
-
-/**
- * clutter_rect_free:
- * @rect: a #ClutterRect
- *
- * Frees the resources allocated by @rect.
- *
- * Since: 1.12
- */
-void
-clutter_rect_free (ClutterRect *rect)
-{
-  if (rect != NULL && rect != &_clutter_rect_zero)
-    g_slice_free (ClutterRect, rect);
-}
-
-/**
- * clutter_rect_equals:
- * @a: a #ClutterRect
- * @b: a #ClutterRect
- *
- * Checks whether @a and @b are equals.
- *
- * This function will normalize both @a and @b before comparing
- * their origin and size.
- *
- * Return value: %TRUE if the rectangles match in origin and size.
- *
- * Since: 1.12
- */
-gboolean
-clutter_rect_equals (ClutterRect *a,
-                     ClutterRect *b)
-{
-  if (a == b)
-    return TRUE;
-
-  if (a == NULL || b == NULL)
-    return FALSE;
-
-  clutter_rect_normalize_internal (a);
-  clutter_rect_normalize_internal (b);
-
-  return graphene_point_equal (&a->origin, &b->origin) &&
-         graphene_size_equal (&a->size, &b->size);
-}
-
-/**
- * clutter_rect_normalize:
- * @rect: a #ClutterRect
- *
- * Normalizes a #ClutterRect.
- *
- * A #ClutterRect is defined by the area covered by its size; this means
- * that a #ClutterRect with #ClutterRect.origin in [ 0, 0 ] and a
- * #ClutterRect.size of [ 10, 10 ] is equivalent to a #ClutterRect with
- * #ClutterRect.origin in [ 10, 10 ] and a #ClutterRect.size of [ -10, -10 ].
- *
- * This function is useful to ensure that a rectangle has positive width
- * and height; it will modify the passed @rect and normalize its size.
- *
- * Since: 1.12
- */
-ClutterRect *
-clutter_rect_normalize (ClutterRect *rect)
-{
-  g_return_val_if_fail (rect != NULL, NULL);
-
-  clutter_rect_normalize_internal (rect);
-
-  return rect;
-}
-
-/**
- * clutter_rect_get_center:
- * @rect: a #ClutterRect
- * @center: (out caller-allocates): a #graphene_point_t
- *
- * Retrieves the center of @rect, after normalizing the rectangle,
- * and updates @center with the correct coordinates.
- *
- * Since: 1.12
- */
-void
-clutter_rect_get_center (ClutterRect      *rect,
-                         graphene_point_t *center)
-{
-  g_return_if_fail (rect != NULL);
-  g_return_if_fail (center != NULL);
-
-  clutter_rect_normalize_internal (rect);
-
-  center->x = rect->origin.x + (rect->size.width / 2.0f);
-  center->y = rect->origin.y + (rect->size.height / 2.0f);
-}
-
-/**
- * clutter_rect_contains_point:
- * @rect: a #ClutterRect
- * @point: the point to check
- *
- * Checks whether @point is contained by @rect, after normalizing the
- * rectangle.
- *
- * Return value: %TRUE if the @point is contained by @rect.
- *
- * Since: 1.12
- */
-gboolean
-clutter_rect_contains_point (ClutterRect      *rect,
-                             graphene_point_t *point)
-{
-  g_return_val_if_fail (rect != NULL, FALSE);
-  g_return_val_if_fail (point != NULL, FALSE);
-
-  clutter_rect_normalize_internal (rect);
-
-  return (point->x >= rect->origin.x) &&
-         (point->y >= rect->origin.y) &&
-         (point->x <= (rect->origin.x + rect->size.width)) &&
-         (point->y <= (rect->origin.y + rect->size.height));
-}
-
-/**
- * clutter_rect_contains_rect:
- * @a: a #ClutterRect
- * @b: a #ClutterRect
- *
- * Checks whether @a contains @b.
- *
- * The first rectangle contains the second if the union of the
- * two #ClutterRect is equal to the first rectangle.
- *
- * Return value: %TRUE if the first rectangle contains the second.
- *
- * Since: 1.12
- */
-gboolean
-clutter_rect_contains_rect (ClutterRect *a,
-                            ClutterRect *b)
-{
-  ClutterRect res;
-
-  g_return_val_if_fail (a != NULL, FALSE);
-  g_return_val_if_fail (b != NULL, FALSE);
-
-  clutter_rect_union (a, b, &res);
-
-  return clutter_rect_equals (a, &res);
-}
-
-/**
- * clutter_rect_union:
- * @a: a #ClutterRect
- * @b: a #ClutterRect
- * @res: (out caller-allocates): a #ClutterRect
- *
- * Computes the smallest possible rectangle capable of fully containing
- * both @a and @b, and places it into @res.
- *
- * This function will normalize both @a and @b prior to computing their
- * union.
- *
- * Since: 1.12
- */
-void
-clutter_rect_union (ClutterRect *a,
-                    ClutterRect *b,
-                    ClutterRect *res)
-{
-  g_return_if_fail (a != NULL);
-  g_return_if_fail (b != NULL);
-  g_return_if_fail (res != NULL);
-
-  clutter_rect_normalize_internal (a);
-  clutter_rect_normalize_internal (b);
-
-  res->origin.x = MIN (a->origin.x, b->origin.x);
-  res->origin.y = MIN (a->origin.y, b->origin.y);
-
-  res->size.width = MAX (a->size.width, b->size.width);
-  res->size.height = MAX (a->size.height, b->size.height);
-}
-
-/**
- * clutter_rect_intersection:
- * @a: a #ClutterRect
- * @b: a #ClutterRect
- * @res: (out caller-allocates) (allow-none): a #ClutterRect, or %NULL
- *
- * Computes the intersection of @a and @b, and places it in @res, if @res
- * is not %NULL.
- *
- * This function will normalize both @a and @b prior to computing their
- * intersection.
- *
- * This function can be used to simply check if the intersection of @a and @b
- * is not empty, by using %NULL for @res.
- *
- * Return value: %TRUE if the intersection of @a and @b is not empty
- *
- * Since: 1.12
- */
-gboolean
-clutter_rect_intersection (ClutterRect *a,
-                           ClutterRect *b,
-                           ClutterRect *res)
-{
-  float x_1, y_1, x_2, y_2;
-
-  g_return_val_if_fail (a != NULL, FALSE);
-  g_return_val_if_fail (b != NULL, FALSE);
-
-  clutter_rect_normalize_internal (a);
-  clutter_rect_normalize_internal (b);
-
-  x_1 = MAX (a->origin.x, b->origin.x);
-  y_1 = MAX (a->origin.y, b->origin.y);
-  x_2 = MIN (a->origin.x + a->size.width, b->origin.x + b->size.width);
-  y_2 = MIN (a->origin.y + a->size.height, b->origin.y + b->size.height);
-
-  if (x_1 >= x_2 || y_1 >= y_2)
-    {
-      if (res != NULL)
-        clutter_rect_init (res, 0.f, 0.f, 0.f, 0.f);
-
-      return FALSE;
-    }
-
-  if (res != NULL)
-    clutter_rect_init (res, x_1, y_1, x_2 - x_1, y_2 - y_1);
-
-  return TRUE;
-}
-
-/**
- * clutter_rect_offset:
- * @rect: a #ClutterRect
- * @d_x: the horizontal offset value
- * @d_y: the vertical offset value
- *
- * Offsets the origin of @rect by the given values, after normalizing
- * the rectangle.
- *
- * Since: 1.12
- */
-void
-clutter_rect_offset (ClutterRect *rect,
-                     float        d_x,
-                     float        d_y)
-{
-  g_return_if_fail (rect != NULL);
-
-  clutter_rect_normalize_internal (rect);
-
-  rect->origin.x += d_x;
-  rect->origin.y += d_y;
-}
-
-/**
- * clutter_rect_inset:
- * @rect: a #ClutterRect
- * @d_x: an horizontal value; a positive @d_x will create an inset rectangle,
- *   and a negative value will create a larger rectangle
- * @d_y: a vertical value; a positive @d_x will create an inset rectangle,
- *   and a negative value will create a larger rectangle
- *
- * Normalizes the @rect and offsets its origin by the @d_x and @d_y values;
- * the size is adjusted by (2 * @d_x, 2 * @d_y).
- *
- * If @d_x and @d_y are positive the size of the rectangle is decreased; if
- * the values are negative, the size of the rectangle is increased.
- *
- * If the resulting rectangle has a negative width or height, the size is
- * set to 0.
- *
- * Since: 1.12
- */
-void
-clutter_rect_inset (ClutterRect *rect,
-                    float        d_x,
-                    float        d_y)
-{
-  g_return_if_fail (rect != NULL);
-
-  clutter_rect_normalize_internal (rect);
-
-  rect->origin.x += d_x;
-  rect->origin.y += d_y;
-
-  if (d_x >= 0.f)
-    rect->size.width -= (d_x * 2.f);
-  else
-    rect->size.width += (d_x * -2.f);
-
-  if (d_y >= 0.f)
-    rect->size.height -= (d_y * 2.f);
-  else
-    rect->size.height += (d_y * -2.f);
-
-  if (rect->size.width < 0.f)
-    rect->size.width = 0.f;
-
-  if (rect->size.height < 0.f)
-    rect->size.height = 0.f;
-}
-
-/**
- * clutter_rect_scale:
- * @rect: a #ClutterRect
- * @s_x: an horizontal scale value
- * @s_y: a vertical scale value
- *
- * Scale the rectangle coordinates and size by @s_x horizontally and
- * @s_y vertically.
- */
-void
-clutter_rect_scale (ClutterRect *rect,
-                    float        s_x,
-                    float        s_y)
-{
-  g_return_if_fail (rect != NULL);
-  g_return_if_fail (s_x > 0.f);
-  g_return_if_fail (s_y > 0.f);
-
-  clutter_rect_normalize_internal (rect);
-
-  rect->origin.x *= s_x;
-  rect->origin.y *= s_y;
-  rect->size.width *= s_x;
-  rect->size.height *= s_y;
-}
-
-/**
- * clutter_rect_clamp_to_pixel:
- * @rect: a #ClutterRect
- *
- * Rounds the origin of @rect downwards to the nearest integer, and recompute the
- * the size using the @rect origin and size rounded upwards to the nearest integer,
- * so that @rect is updated to the smallest rectangle capable of fully containing
- * the original, fractional rectangle in the coordinates space.
- *
- * Since: 1.12
- */
-void
-clutter_rect_clamp_to_pixel (ClutterRect *rect)
-{
-  float x2, y2;
-
-  g_return_if_fail (rect != NULL);
-
-  clutter_rect_normalize_internal (rect);
-
-  x2 = rect->origin.x + rect->size.width;
-  y2 = rect->origin.y + rect->size.height;
-
-  rect->origin.x = floorf (rect->origin.x);
-  rect->origin.y = floorf (rect->origin.y);
-
-  rect->size.width = ceilf (x2) - rect->origin.x;
-  rect->size.height = ceilf (y2) - rect->origin.y;
-}
-
-/**
- * clutter_rect_get_x:
- * @rect: a #ClutterRect
- *
- * Retrieves the X coordinate of the origin of @rect.
- *
- * Return value: the X coordinate of the origin of the rectangle
- *
- * Since: 1.12
- */
-float
-clutter_rect_get_x (ClutterRect *rect)
-{
-  g_return_val_if_fail (rect != NULL, 0.f);
-
-  clutter_rect_normalize_internal (rect);
-
-  return rect->origin.x;
-}
-
-/**
- * clutter_rect_get_y:
- * @rect: a #ClutterRect
- *
- * Retrieves the Y coordinate of the origin of @rect.
- *
- * Return value: the Y coordinate of the origin of the rectangle
- *
- * Since: 1.12
- */
-float
-clutter_rect_get_y (ClutterRect *rect)
-{
-  g_return_val_if_fail (rect != NULL, 0.f);
-
-  clutter_rect_normalize_internal (rect);
-
-  return rect->origin.y;
-}
-
-/**
- * clutter_rect_get_width:
- * @rect: a #ClutterRect
- *
- * Retrieves the width of @rect.
- *
- * Return value: the width of the rectangle
- *
- * Since: 1.12
- */
-float
-clutter_rect_get_width (ClutterRect *rect)
-{
-  g_return_val_if_fail (rect != NULL, 0.f);
-
-  clutter_rect_normalize_internal (rect);
-
-  return rect->size.width;
-}
-
-/**
- * clutter_rect_get_height:
- * @rect: a #ClutterRect
- *
- * Retrieves the height of @rect.
- *
- * Return value: the height of the rectangle
- *
- * Since: 1.12
- */
-float
-clutter_rect_get_height (ClutterRect *rect)
-{
-  g_return_val_if_fail (rect != NULL, 0.f);
-
-  clutter_rect_normalize_internal (rect);
-
-  return rect->size.height;
-}
-
-static gboolean
-clutter_rect_progress (const GValue *a,
-                       const GValue *b,
-                       gdouble       progress,
-                       GValue       *retval)
-{
-  const ClutterRect *rect_a = g_value_get_boxed (a);
-  const ClutterRect *rect_b = g_value_get_boxed (b);
-  ClutterRect res = CLUTTER_RECT_INIT_ZERO;
-
-#define INTERPOLATE(r_a,r_b,member,field,factor)     ((r_a)->member.field + (((r_b)->member.field - 
((r_a)->member.field)) * (factor)))
-
-  res.origin.x = INTERPOLATE (rect_a, rect_b, origin, x, progress);
-  res.origin.y = INTERPOLATE (rect_a, rect_b, origin, y, progress);
-
-  res.size.width = INTERPOLATE (rect_a, rect_b, size, width, progress);
-  res.size.height = INTERPOLATE (rect_a, rect_b, size, height, progress);
-
-#undef INTERPOLATE
-
-  g_value_set_boxed (retval, &res);
-
-  return TRUE;
-}
-
 /**
  * ClutterMatrix:
  *
diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c
index 05ee15f2b..6ffaeab52 100644
--- a/clutter/clutter/clutter-deform-effect.c
+++ b/clutter/clutter/clutter-deform-effect.c
@@ -177,7 +177,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect)
 
   if (priv->is_dirty)
     {
-      ClutterRect rect;
+      graphene_rect_t rect;
       gboolean mapped_buffer;
       CoglVertexP3T2C4 *verts;
       ClutterActor *actor;
@@ -193,8 +193,8 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect)
        */
       if (clutter_offscreen_effect_get_target_rect (effect, &rect))
         {
-          width = clutter_rect_get_width (&rect);
-          height = clutter_rect_get_height (&rect);
+          width = graphene_rect_get_width (&rect);
+          height = graphene_rect_get_height (&rect);
         }
       else
         clutter_actor_get_size (actor, &width, &height);
diff --git a/clutter/clutter/clutter-drag-action.c b/clutter/clutter/clutter-drag-action.c
index 54e991bf8..829889472 100644
--- a/clutter/clutter/clutter-drag-action.c
+++ b/clutter/clutter/clutter-drag-action.c
@@ -81,7 +81,7 @@ struct _ClutterDragActionPrivate
   gint y_drag_threshold;
   ClutterActor *drag_handle;
   ClutterDragAxis drag_axis;
-  ClutterRect drag_area;
+  graphene_rect_t drag_area;
 
   ClutterInputDevice *device;
   ClutterEventSequence *sequence;
@@ -542,7 +542,7 @@ clutter_drag_action_real_drag_motion (ClutterDragAction *action,
 
   if (action->priv->drag_area_set)
     {
-      ClutterRect *drag_area = &action->priv->drag_area;
+      graphene_rect_t *drag_area = &action->priv->drag_area;
 
       x = CLAMP (x, drag_area->origin.x, drag_area->origin.x + drag_area->size.width);
       y = CLAMP (y, drag_area->origin.y, drag_area->origin.y + drag_area->size.height);
@@ -811,7 +811,7 @@ clutter_drag_action_class_init (ClutterDragActionClass *klass)
     g_param_spec_boxed ("drag-area",
                        P_("Drag Area"),
                        P_("Constrains the dragging to a rectangle"),
-                       CLUTTER_TYPE_RECT,
+                       GRAPHENE_TYPE_RECT,
                        CLUTTER_PARAM_READWRITE);
 
   /**
@@ -1267,10 +1267,10 @@ clutter_drag_action_get_motion_coords (ClutterDragAction *action,
 /**
  * clutter_drag_action_get_drag_area:
  * @action: a #ClutterDragAction
- * @drag_area: (out caller-allocates): a #ClutterRect to be filled
+ * @drag_area: (out caller-allocates): a #graphene_rect_t to be filled
  *
  * Retrieves the "drag area" associated with @action, that
- * is a #ClutterRect that constrains the actor movements,
+ * is a #graphene_rect_t that constrains the actor movements,
  * in parents coordinates.
  *
  * Returns: %TRUE if the actor is actually constrained (and thus
@@ -1278,7 +1278,7 @@ clutter_drag_action_get_motion_coords (ClutterDragAction *action,
  */
 gboolean
 clutter_drag_action_get_drag_area (ClutterDragAction *action,
-                                  ClutterRect       *drag_area)
+                                   graphene_rect_t   *drag_area)
 {
   g_return_val_if_fail (CLUTTER_IS_DRAG_ACTION (action), FALSE);
 
@@ -1298,8 +1298,8 @@ clutter_drag_action_get_drag_area (ClutterDragAction *action,
  * If @drag_area is %NULL, the actor is not constrained.
  */
 void
-clutter_drag_action_set_drag_area (ClutterDragAction *action,
-                                  const ClutterRect *drag_area)
+clutter_drag_action_set_drag_area (ClutterDragAction     *action,
+                                   const graphene_rect_t *drag_area)
 {
   ClutterDragActionPrivate *priv;
 
diff --git a/clutter/clutter/clutter-drag-action.h b/clutter/clutter/clutter-drag-action.h
index c0df62238..6904dc5ed 100644
--- a/clutter/clutter/clutter-drag-action.h
+++ b/clutter/clutter/clutter-drag-action.h
@@ -141,11 +141,11 @@ void            clutter_drag_action_get_motion_coords  (ClutterDragAction *actio
 
 CLUTTER_EXPORT
 gboolean        clutter_drag_action_get_drag_area      (ClutterDragAction *action,
-                                                        ClutterRect       *drag_area);
+                                                        graphene_rect_t   *drag_area);
 
 CLUTTER_EXPORT
-void            clutter_drag_action_set_drag_area      (ClutterDragAction *action,
-                                                        const ClutterRect *drag_area);
+void            clutter_drag_action_set_drag_area      (ClutterDragAction     *action,
+                                                        const graphene_rect_t *drag_area);
 
 G_END_DECLS
 
diff --git a/clutter/clutter/clutter-graphene.c b/clutter/clutter/clutter-graphene.c
index 68aeb0c1a..93a6b4fdb 100644
--- a/clutter/clutter/clutter-graphene.c
+++ b/clutter/clutter/clutter-graphene.c
@@ -60,6 +60,23 @@ graphene_point3d_progress (const GValue *a,
   return TRUE;
 }
 
+static gboolean
+graphene_rect_progress (const GValue *a,
+                        const GValue *b,
+                        gdouble       progress,
+                        GValue       *retval)
+{
+  const graphene_rect_t *rect_a = g_value_get_boxed (a);
+  const graphene_rect_t *rect_b = g_value_get_boxed (b);
+  graphene_rect_t res;
+
+  graphene_rect_interpolate (rect_a, rect_b, progress, &res);
+
+  g_value_set_boxed (retval, &res);
+
+  return TRUE;
+}
+
 static gboolean
 graphene_size_progress (const GValue *a,
                         const GValue *b,
@@ -84,6 +101,8 @@ clutter_graphene_init (void)
                                            graphene_point_progress);
   clutter_interval_register_progress_func (GRAPHENE_TYPE_POINT3D,
                                            graphene_point3d_progress);
+  clutter_interval_register_progress_func (GRAPHENE_TYPE_RECT,
+                                           graphene_rect_progress);
   clutter_interval_register_progress_func (GRAPHENE_TYPE_SIZE,
                                            graphene_size_progress);
 }
diff --git a/clutter/clutter/clutter-input-focus.c b/clutter/clutter/clutter-input-focus.c
index d54494b0f..7a004f259 100644
--- a/clutter/clutter/clutter-input-focus.c
+++ b/clutter/clutter/clutter-input-focus.c
@@ -89,8 +89,8 @@ clutter_input_focus_reset (ClutterInputFocus *focus)
 }
 
 void
-clutter_input_focus_set_cursor_location (ClutterInputFocus *focus,
-                                         const ClutterRect *rect)
+clutter_input_focus_set_cursor_location (ClutterInputFocus     *focus,
+                                         const graphene_rect_t *rect)
 {
   ClutterInputFocusPrivate *priv;
 
diff --git a/clutter/clutter/clutter-input-focus.h b/clutter/clutter/clutter-input-focus.h
index 3f971fec4..65736a799 100644
--- a/clutter/clutter/clutter-input-focus.h
+++ b/clutter/clutter/clutter-input-focus.h
@@ -57,8 +57,8 @@ gboolean clutter_input_focus_is_focused (ClutterInputFocus *focus);
 CLUTTER_EXPORT
 void clutter_input_focus_reset (ClutterInputFocus *focus);
 CLUTTER_EXPORT
-void clutter_input_focus_set_cursor_location (ClutterInputFocus *focus,
-                                              const ClutterRect *rect);
+void clutter_input_focus_set_cursor_location (ClutterInputFocus     *focus,
+                                              const graphene_rect_t *rect);
 
 CLUTTER_EXPORT
 void clutter_input_focus_set_surrounding (ClutterInputFocus *focus,
diff --git a/clutter/clutter/clutter-input-method-private.h b/clutter/clutter/clutter-input-method-private.h
index e8ab2cabf..61e575e7e 100644
--- a/clutter/clutter/clutter-input-method-private.h
+++ b/clutter/clutter/clutter-input-method-private.h
@@ -26,8 +26,8 @@ ClutterInputFocus * clutter_input_method_get_focus (ClutterInputMethod *method);
 
 void clutter_input_method_reset               (ClutterInputMethod *method);
 
-void clutter_input_method_set_cursor_location (ClutterInputMethod *method,
-                                               const ClutterRect  *rect);
+void clutter_input_method_set_cursor_location (ClutterInputMethod    *method,
+                                               const graphene_rect_t *rect);
 void clutter_input_method_set_surrounding     (ClutterInputMethod *method,
                                                const gchar        *text,
                                                guint               cursor,
diff --git a/clutter/clutter/clutter-input-method.c b/clutter/clutter/clutter-input-method.c
index 344e19297..0fb093122 100644
--- a/clutter/clutter/clutter-input-method.c
+++ b/clutter/clutter/clutter-input-method.c
@@ -187,7 +187,7 @@ clutter_input_method_class_init (ClutterInputMethodClass *klass)
                   G_TYPE_FROM_CLASS (object_class),
                   G_SIGNAL_RUN_LAST,
                   0, NULL, NULL, NULL,
-                  G_TYPE_NONE, 1, CLUTTER_TYPE_RECT);
+                  G_TYPE_NONE, 1, GRAPHENE_TYPE_RECT);
 
   pspecs[PROP_CONTENT_HINTS] =
     g_param_spec_flags ("content-hints",
@@ -377,8 +377,8 @@ clutter_input_method_reset (ClutterInputMethod *im)
 }
 
 void
-clutter_input_method_set_cursor_location (ClutterInputMethod *im,
-                                          const ClutterRect  *rect)
+clutter_input_method_set_cursor_location (ClutterInputMethod    *im,
+                                          const graphene_rect_t *rect)
 {
   g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
 
diff --git a/clutter/clutter/clutter-input-method.h b/clutter/clutter/clutter-input-method.h
index ba1bc223a..92f960f0a 100644
--- a/clutter/clutter/clutter-input-method.h
+++ b/clutter/clutter/clutter-input-method.h
@@ -42,8 +42,8 @@ struct _ClutterInputMethodClass
 
   void (* reset) (ClutterInputMethod *im);
 
-  void (* set_cursor_location) (ClutterInputMethod          *im,
-                                const ClutterRect           *rect);
+  void (* set_cursor_location) (ClutterInputMethod    *im,
+                                const graphene_rect_t *rect);
   void (* set_surrounding) (ClutterInputMethod *im,
                             const gchar        *text,
                             guint               cursor,
diff --git a/clutter/clutter/clutter-offscreen-effect.c b/clutter/clutter/clutter-offscreen-effect.c
index 16768e801..f432e4b8a 100644
--- a/clutter/clutter/clutter-offscreen-effect.c
+++ b/clutter/clutter/clutter-offscreen-effect.c
@@ -684,7 +684,7 @@ clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect,
  */
 gboolean
 clutter_offscreen_effect_get_target_rect (ClutterOffscreenEffect *effect,
-                                          ClutterRect            *rect)
+                                          graphene_rect_t        *rect)
 {
   ClutterOffscreenEffectPrivate *priv;
 
@@ -696,11 +696,11 @@ clutter_offscreen_effect_get_target_rect (ClutterOffscreenEffect *effect,
   if (priv->texture == NULL)
     return FALSE;
 
-  clutter_rect_init (rect,
-                     priv->position.x,
-                     priv->position.y,
-                     cogl_texture_get_width (priv->texture),
-                     cogl_texture_get_height (priv->texture));
+  graphene_rect_init (rect,
+                      priv->position.x,
+                      priv->position.y,
+                      cogl_texture_get_width (priv->texture),
+                      cogl_texture_get_height (priv->texture));
 
   return TRUE;
 }
diff --git a/clutter/clutter/clutter-offscreen-effect.h b/clutter/clutter/clutter-offscreen-effect.h
index 07619441e..6ab1637ae 100644
--- a/clutter/clutter/clutter-offscreen-effect.h
+++ b/clutter/clutter/clutter-offscreen-effect.h
@@ -114,7 +114,7 @@ gboolean        clutter_offscreen_effect_get_target_size        (ClutterOffscree
 
 CLUTTER_EXPORT
 gboolean        clutter_offscreen_effect_get_target_rect        (ClutterOffscreenEffect *effect,
-                                                                 ClutterRect            *rect);
+                                                                 graphene_rect_t        *rect);
 
 G_END_DECLS
 
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index d257b4c63..f33c0fa9f 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -235,9 +235,9 @@ void  _clutter_util_fully_transform_vertices (const CoglMatrix         *modelvie
                                               int                       n_vertices);
 
 void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
-                                        ClutterRect                 *dest);
+                                        graphene_rect_t             *dest);
 
-void _clutter_util_rectangle_int_extents (const ClutterRect     *src,
+void _clutter_util_rectangle_int_extents (const graphene_rect_t *src,
                                           cairo_rectangle_int_t *dest);
 
 void _clutter_util_rectangle_offset (const cairo_rectangle_int_t *src,
diff --git a/clutter/clutter/clutter-scroll-actor.c b/clutter/clutter/clutter-scroll-actor.c
index 76f3af011..969ba5370 100644
--- a/clutter/clutter/clutter-scroll-actor.c
+++ b/clutter/clutter/clutter-scroll-actor.c
@@ -417,10 +417,10 @@ clutter_scroll_actor_scroll_to_point (ClutterScrollActor     *actor,
  * Since: 1.12
  */
 void
-clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor,
-                                     const ClutterRect  *rect)
+clutter_scroll_actor_scroll_to_rect (ClutterScrollActor    *actor,
+                                     const graphene_rect_t *rect)
 {
-  ClutterRect n_rect;
+  graphene_rect_t n_rect;
 
   g_return_if_fail (CLUTTER_IS_SCROLL_ACTOR (actor));
   g_return_if_fail (rect != NULL);
@@ -428,7 +428,7 @@ clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor,
   n_rect = *rect;
 
   /* normalize, so that we have a valid origin */
-  clutter_rect_normalize (&n_rect);
+  graphene_rect_normalize (&n_rect);
 
   clutter_scroll_actor_scroll_to_point (actor, &n_rect.origin);
 }
diff --git a/clutter/clutter/clutter-scroll-actor.h b/clutter/clutter/clutter-scroll-actor.h
index 4a4171495..e6a176521 100644
--- a/clutter/clutter/clutter-scroll-actor.h
+++ b/clutter/clutter/clutter-scroll-actor.h
@@ -89,8 +89,8 @@ CLUTTER_EXPORT
 void                    clutter_scroll_actor_scroll_to_point    (ClutterScrollActor     *actor,
                                                                  const graphene_point_t *point);
 CLUTTER_EXPORT
-void                    clutter_scroll_actor_scroll_to_rect     (ClutterScrollActor *actor,
-                                                                 const ClutterRect  *rect);
+void                    clutter_scroll_actor_scroll_to_rect     (ClutterScrollActor    *actor,
+                                                                 const graphene_rect_t *rect);
 
 G_END_DECLS
 
diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h
index b4255a475..e5d3b1d2d 100644
--- a/clutter/clutter/clutter-stage-private.h
+++ b/clutter/clutter/clutter-stage-private.h
@@ -124,9 +124,9 @@ gboolean                _clutter_stage_update_state     (ClutterStage      *stag
 
 void                    _clutter_stage_set_scale_factor (ClutterStage      *stage,
                                                          int                factor);
-gboolean                _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
-                                                                           ClutterRect  *rect,
-                                                                           float        *view_scale);
+gboolean                _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage    *stage,
+                                                                           graphene_rect_t *rect,
+                                                                           float           *view_scale);
 
 void            _clutter_stage_presented                (ClutterStage      *stage,
                                                          CoglFrameEvent     frame_event,
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 39e9defd4..4448433a2 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -4426,7 +4426,7 @@ clutter_stage_get_capture_final_size (ClutterStage          *stage,
 
   if (rect)
     {
-      ClutterRect capture_rect;
+      graphene_rect_t capture_rect;
 
       _clutter_util_rect_from_rectangle (rect, &capture_rect);
       if (!_clutter_stage_get_max_view_scale_factor_for_rect (stage,
@@ -4633,9 +4633,9 @@ clutter_stage_update_resource_scales (ClutterStage *stage)
 }
 
 gboolean
-_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
-                                                   ClutterRect  *rect,
-                                                   float        *view_scale)
+_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage    *stage,
+                                                   graphene_rect_t *rect,
+                                                   float           *view_scale)
 {
   ClutterStagePrivate *priv = stage->priv;
   float scale = 0.0f;
@@ -4645,12 +4645,12 @@ _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
     {
       ClutterStageView *view = l->data;
       cairo_rectangle_int_t view_layout;
-      ClutterRect view_rect;
+      graphene_rect_t view_rect;
 
       clutter_stage_view_get_layout (view, &view_layout);
       _clutter_util_rect_from_rectangle (&view_layout, &view_rect);
 
-      if (clutter_rect_intersection (&view_rect, rect, NULL))
+      if (graphene_rect_intersection (&view_rect, rect, NULL))
         scale = MAX (clutter_stage_view_get_scale (view), scale);
     }
 
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 1684a2bd2..3ad0d6152 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -157,7 +157,7 @@ struct _ClutterTextPrivate
   gint text_logical_y;
 
   /* Where to draw the cursor */
-  ClutterRect cursor_rect;
+  graphene_rect_t cursor_rect;
   ClutterColor cursor_color;
   guint cursor_size;
 
@@ -1304,7 +1304,7 @@ static inline void
 update_cursor_location (ClutterText *self)
 {
   ClutterTextPrivate *priv = self->priv;
-  ClutterRect rect;
+  graphene_rect_t rect;
   float x, y;
 
   if (!priv->editable)
@@ -1312,7 +1312,7 @@ update_cursor_location (ClutterText *self)
 
   rect = priv->cursor_rect;
   clutter_actor_get_transformed_position (CLUTTER_ACTOR (self), &x, &y);
-  clutter_rect_offset (&rect, x, y);
+  graphene_rect_offset (&rect, x, y);
   clutter_input_focus_set_cursor_location (priv->input_focus, &rect);
 }
 
@@ -1322,7 +1322,7 @@ clutter_text_ensure_cursor_position (ClutterText *self,
 {
   ClutterTextPrivate *priv = self->priv;
   gfloat x, y, cursor_height;
-  ClutterRect cursor_rect = CLUTTER_RECT_INIT_ZERO;
+  graphene_rect_t cursor_rect = GRAPHENE_RECT_INIT_ZERO;
   gint position;
 
   position = priv->position;
@@ -1345,23 +1345,23 @@ clutter_text_ensure_cursor_position (ClutterText *self,
                                             &x, &y,
                                             &cursor_height);
 
-  clutter_rect_init (&cursor_rect,
-                     x,
-                     y + CURSOR_Y_PADDING * scale,
-                     priv->cursor_size * scale,
-                     cursor_height - 2 * CURSOR_Y_PADDING * scale);
+  graphene_rect_init (&cursor_rect,
+                      x,
+                      y + CURSOR_Y_PADDING * scale,
+                      priv->cursor_size * scale,
+                      cursor_height - 2 * CURSOR_Y_PADDING * scale);
 
-  if (!clutter_rect_equals (&priv->cursor_rect, &cursor_rect))
+  if (!graphene_rect_equal (&priv->cursor_rect, &cursor_rect))
     {
       ClutterGeometry cursor_pos;
 
       priv->cursor_rect = cursor_rect;
 
       /* XXX:2.0 - remove */
-      cursor_pos.x = clutter_rect_get_x (&priv->cursor_rect);
-      cursor_pos.y = clutter_rect_get_y (&priv->cursor_rect);
-      cursor_pos.width = clutter_rect_get_width (&priv->cursor_rect);
-      cursor_pos.height = clutter_rect_get_height (&priv->cursor_rect);
+      cursor_pos.x = graphene_rect_get_x (&priv->cursor_rect);
+      cursor_pos.y = graphene_rect_get_y (&priv->cursor_rect);
+      cursor_pos.width = graphene_rect_get_width (&priv->cursor_rect);
+      cursor_pos.height = graphene_rect_get_height (&priv->cursor_rect);
       g_signal_emit (self, text_signals[CURSOR_EVENT], 0, &cursor_pos);
 
       g_signal_emit (self, text_signals[CURSOR_CHANGED], 0);
@@ -2712,7 +2712,7 @@ clutter_text_paint (ClutterActor *self)
 
       if (actor_width < text_width)
         {
-          gint cursor_x = clutter_rect_get_x (&priv->cursor_rect);
+          gint cursor_x = graphene_rect_get_x (&priv->cursor_rect);
 
           if (priv->position == -1)
             {
@@ -6780,8 +6780,8 @@ clutter_text_get_layout_offsets (ClutterText *self,
  * Since: 1.16
  */
 void
-clutter_text_get_cursor_rect (ClutterText *self,
-                              ClutterRect *rect)
+clutter_text_get_cursor_rect (ClutterText     *self,
+                              graphene_rect_t *rect)
 {
   g_return_if_fail (CLUTTER_IS_TEXT (self));
   g_return_if_fail (rect != NULL);
diff --git a/clutter/clutter/clutter-text.h b/clutter/clutter/clutter-text.h
index aa65ba2e6..5ca279f48 100644
--- a/clutter/clutter/clutter-text.h
+++ b/clutter/clutter/clutter-text.h
@@ -230,7 +230,7 @@ CLUTTER_EXPORT
 guint                 clutter_text_get_cursor_size      (ClutterText          *self);
 CLUTTER_EXPORT
 void                  clutter_text_get_cursor_rect      (ClutterText          *self,
-                                                         ClutterRect          *rect);
+                                                         graphene_rect_t      *rect);
 CLUTTER_EXPORT
 void                  clutter_text_set_selectable       (ClutterText          *self,
                                                          gboolean              selectable);
diff --git a/clutter/clutter/clutter-types.h b/clutter/clutter/clutter-types.h
index 5e713bda3..68bad6a11 100644
--- a/clutter/clutter/clutter-types.h
+++ b/clutter/clutter/clutter-types.h
@@ -44,7 +44,6 @@ G_BEGIN_DECLS
 #define CLUTTER_TYPE_MATRIX             (clutter_matrix_get_type ())
 #define CLUTTER_TYPE_PAINT_VOLUME       (clutter_paint_volume_get_type ())
 #define CLUTTER_TYPE_PERSPECTIVE        (clutter_perspective_get_type ())
-#define CLUTTER_TYPE_RECT               (clutter_rect_get_type ())
 
 typedef struct _ClutterActor                    ClutterActor;
 
@@ -81,7 +80,6 @@ typedef struct _ClutterGeometry                 ClutterGeometry; /* XXX:2.0 - re
 typedef struct _ClutterKnot                     ClutterKnot;
 typedef struct _ClutterMargin                   ClutterMargin;
 typedef struct _ClutterPerspective              ClutterPerspective;
-typedef struct _ClutterRect                     ClutterRect;
 
 typedef struct _ClutterAlpha                   ClutterAlpha;
 typedef struct _ClutterAnimation                ClutterAnimation;
@@ -131,123 +129,6 @@ typedef struct _ClutterShader                   ClutterShader; /* deprecated */
  */
 typedef struct _ClutterPaintVolume      ClutterPaintVolume;
 
-/**
- * ClutterRect:
- * @origin: the origin of the rectangle
- * @size: the size of the rectangle
- *
- * The location and size of a rectangle.
- *
- * The width and height of a #ClutterRect can be negative; Clutter considers
- * a rectangle with an origin of [ 0.0, 0.0 ] and a size of [ 10.0, 10.0 ] to
- * be equivalent to a rectangle with origin of [ 10.0, 10.0 ] and size of
- * [ -10.0, -10.0 ].
- *
- * Application code can normalize rectangles using clutter_rect_normalize():
- * this function will ensure that the width and height of a #ClutterRect are
- * positive values. All functions taking a #ClutterRect as an argument will
- * implicitly normalize it before computing eventual results. For this reason
- * it is safer to access the contents of a #ClutterRect by using the provided
- * API at all times, instead of directly accessing the structure members.
- *
- * Since: 1.12
- */
-struct _ClutterRect
-{
-  graphene_point_t origin;
-  graphene_size_t size;
-};
-
-/**
- * CLUTTER_RECT_INIT:
- * @x: the X coordinate
- * @y: the Y coordinate
- * @width: the width
- * @height: the height
- *
- * A simple macro for initializing a #ClutterRect when declaring it, e.g.:
- *
- * |[
- *   ClutterRect r = CLUTTER_RECT_INIT (100, 100, 200, 200);
- * ]|
- *
- * Since: 1.12
- */
-#define CLUTTER_RECT_INIT(x,y,width,height)     { { (x), (y) }, { (width), (height) } }
-
-/**
- * CLUTTER_RECT_INIT_ZERO:
- *
- * A simple macro for initializing a #ClutterRect to (0, 0, 0, 0) when
- * declaring it.
- *
- * Since: 1.12
- */
-#define CLUTTER_RECT_INIT_ZERO                  CLUTTER_RECT_INIT (0.f, 0.f, 0.f, 0.f)
-
-CLUTTER_EXPORT
-GType clutter_rect_get_type (void) G_GNUC_CONST;
-
-CLUTTER_EXPORT
-const ClutterRect *     clutter_rect_zero               (void);
-CLUTTER_EXPORT
-ClutterRect *           clutter_rect_alloc              (void);
-CLUTTER_EXPORT
-ClutterRect *           clutter_rect_init               (ClutterRect       *rect,
-                                                         float              x,
-                                                         float              y,
-                                                         float              width,
-                                                         float              height);
-CLUTTER_EXPORT
-ClutterRect *           clutter_rect_copy               (const ClutterRect *rect);
-CLUTTER_EXPORT
-void                    clutter_rect_free               (ClutterRect       *rect);
-CLUTTER_EXPORT
-gboolean                clutter_rect_equals             (ClutterRect       *a,
-                                                         ClutterRect       *b);
-
-CLUTTER_EXPORT
-ClutterRect *           clutter_rect_normalize          (ClutterRect       *rect);
-CLUTTER_EXPORT
-void                    clutter_rect_get_center         (ClutterRect       *rect,
-                                                         graphene_point_t  *center);
-CLUTTER_EXPORT
-gboolean                clutter_rect_contains_point     (ClutterRect       *rect,
-                                                         graphene_point_t  *point);
-CLUTTER_EXPORT
-gboolean                clutter_rect_contains_rect      (ClutterRect       *a,
-                                                         ClutterRect       *b);
-CLUTTER_EXPORT
-void                    clutter_rect_union              (ClutterRect       *a,
-                                                         ClutterRect       *b,
-                                                         ClutterRect       *res);
-CLUTTER_EXPORT
-gboolean                clutter_rect_intersection       (ClutterRect       *a,
-                                                         ClutterRect       *b,
-                                                         ClutterRect       *res);
-CLUTTER_EXPORT
-void                    clutter_rect_offset             (ClutterRect       *rect,
-                                                         float              d_x,
-                                                         float              d_y);
-CLUTTER_EXPORT
-void                    clutter_rect_inset              (ClutterRect       *rect,
-                                                         float              d_x,
-                                                         float              d_y);
-CLUTTER_EXPORT
-void                    clutter_rect_scale              (ClutterRect       *rect,
-                                                         float              s_x,
-                                                         float              s_y);
-CLUTTER_EXPORT
-void                    clutter_rect_clamp_to_pixel     (ClutterRect       *rect);
-CLUTTER_EXPORT
-float                   clutter_rect_get_x              (ClutterRect       *rect);
-CLUTTER_EXPORT
-float                   clutter_rect_get_y              (ClutterRect       *rect);
-CLUTTER_EXPORT
-float                   clutter_rect_get_width          (ClutterRect       *rect);
-CLUTTER_EXPORT
-float                   clutter_rect_get_height         (ClutterRect       *rect);
-
 /**
  * ClutterActorBox:
  * @x1: X coordinate of the top left corner
@@ -388,7 +269,7 @@ void             clutter_actor_box_scale          (ClutterActorBox       *box,
  * The rectangle containing an actor's bounding box, measured in pixels.
  *
  * You should not use #ClutterGeometry, or operate on its fields
- * directly; you should use #cairo_rectangle_int_t or #ClutterRect if you
+ * directly; you should use #cairo_rectangle_int_t or #graphene_rect_t  if you
  * need a rectangle type, depending on the precision required.
  *
  * Deprecated: 1.16
diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c
index c233ef273..885851240 100644
--- a/clutter/clutter/clutter-util.c
+++ b/clutter/clutter/clutter-util.c
@@ -108,9 +108,9 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
 
 void
 _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
-                                   ClutterRect                 *dest)
+                                   graphene_rect_t             *dest)
 {
-  *dest = (ClutterRect) {
+  *dest = (graphene_rect_t) {
     .origin = {
       .x = src->x,
       .y = src->y
@@ -123,12 +123,12 @@ _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
 }
 
 void
-_clutter_util_rectangle_int_extents (const  ClutterRect    *src,
+_clutter_util_rectangle_int_extents (const graphene_rect_t *src,
                                      cairo_rectangle_int_t *dest)
 {
-  ClutterRect tmp = *src;
+  graphene_rect_t tmp = *src;
 
-  clutter_rect_clamp_to_pixel (&tmp);
+  graphene_rect_round_extents (&tmp, &tmp);
 
   *dest = (cairo_rectangle_int_t) {
     .x = tmp.origin.x,
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c
index 4dd7a900e..ed8a04325 100644
--- a/clutter/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/clutter/cogl/clutter-stage-cogl.c
@@ -601,14 +601,14 @@ is_buffer_age_enabled (void)
 }
 
 static void
-scale_and_clamp_rect (const ClutterRect     *rect,
+scale_and_clamp_rect (const graphene_rect_t *rect,
                       float                  scale,
                       cairo_rectangle_int_t *dest)
 
 {
-  ClutterRect tmp = *rect;
+  graphene_rect_t tmp = *rect;
 
-  clutter_rect_scale (&tmp, scale, scale);
+  graphene_rect_scale (&tmp, scale, scale, &tmp);
   _clutter_util_rectangle_int_extents (&tmp, dest);
 }
 
@@ -675,12 +675,12 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
        * frames when starting up... */
       cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3)
     {
-      ClutterRect rect;
+      graphene_rect_t rect;
 
       may_use_clipped_redraw = TRUE;
 
       _clutter_util_rect_from_rectangle (&redraw_clip, &rect);
-      clutter_rect_offset (&rect, -view_rect.x, -view_rect.y);
+      graphene_rect_offset (&rect, -view_rect.x, -view_rect.y);
       scale_and_clamp_rect (&rect, fb_scale, &fb_clip_region);
 
       if (fb_scale != floorf (fb_scale))
@@ -718,7 +718,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
 
           if (valid_buffer_age (view_cogl, age))
             {
-              ClutterRect rect;
+              graphene_rect_t rect;
               cairo_rectangle_int_t damage_region;
 
               *current_fb_damage = fb_clip_region;
@@ -778,7 +778,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
     }
   else if (use_clipped_redraw)
     {
-      ClutterRect rect;
+      graphene_rect_t rect;
       cairo_rectangle_int_t scissor_rect;
       cairo_rectangle_int_t paint_rect;
 
@@ -824,7 +824,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
           may_use_clipped_redraw &&
           !clip_region_empty)
         {
-          ClutterRect rect;
+          graphene_rect_t rect;
           cairo_rectangle_int_t scissor_rect;
           cairo_rectangle_int_t paint_rect;
 
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index b1bcbc842..b342a98f3 100644
--- a/src/backends/meta-cursor-renderer.c
+++ b/src/backends/meta-cursor-renderer.c
@@ -85,7 +85,7 @@ meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
 
 static void
 align_cursor_position (MetaCursorRenderer *renderer,
-                       ClutterRect        *rect)
+                       graphene_rect_t    *rect)
 {
   MetaCursorRendererPrivate *priv =
     meta_cursor_renderer_get_instance_private (renderer);
@@ -104,10 +104,10 @@ align_cursor_position (MetaCursorRenderer *renderer,
   clutter_stage_view_get_layout (view, &view_layout);
   view_scale = clutter_stage_view_get_scale (view);
 
-  clutter_rect_offset (rect, -view_layout.x, -view_layout.y);
+  graphene_rect_offset (rect, -view_layout.x, -view_layout.y);
   rect->origin.x = floorf (rect->origin.x * view_scale) / view_scale;
   rect->origin.y = floorf (rect->origin.y * view_scale) / view_scale;
-  clutter_rect_offset (rect, view_layout.x, view_layout.y);
+  graphene_rect_offset (rect, view_layout.x, view_layout.y);
 }
 
 static void
@@ -118,7 +118,7 @@ queue_redraw (MetaCursorRenderer *renderer,
   MetaBackend *backend = meta_get_backend ();
   ClutterActor *stage = meta_backend_get_stage (backend);
   CoglTexture *texture;
-  ClutterRect rect = CLUTTER_RECT_INIT_ZERO;
+  graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO;
 
   /* During early initialization, we can have no stage */
   if (!stage)
@@ -211,7 +211,7 @@ meta_cursor_renderer_init (MetaCursorRenderer *renderer)
                                            NULL);
 }
 
-ClutterRect
+graphene_rect_t
 meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
                                      MetaCursorSprite   *cursor_sprite)
 {
@@ -224,14 +224,14 @@ meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
 
   texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
   if (!texture)
-    return (ClutterRect) CLUTTER_RECT_INIT_ZERO;
+    return (graphene_rect_t) GRAPHENE_RECT_INIT_ZERO;
 
   meta_cursor_sprite_get_hotspot (cursor_sprite, &hot_x, &hot_y);
   texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
   width = cogl_texture_get_width (texture);
   height = cogl_texture_get_height (texture);
 
-  return (ClutterRect) {
+  return (graphene_rect_t) {
     .origin = {
       .x = priv->current_x - (hot_x * texture_scale),
       .y = priv->current_y - (hot_y * texture_scale)
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
index cfa7bc995..852551355 100644
--- a/src/backends/meta-cursor-renderer.h
+++ b/src/backends/meta-cursor-renderer.h
@@ -76,8 +76,8 @@ void meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer    *ren
 gboolean meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer,
                                                        MetaCursorSprite   *cursor_sprite);
 
-ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
-                                                 MetaCursorSprite   *cursor_sprite);
+graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
+                                                     MetaCursorSprite   *cursor_sprite);
 
 void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
                                         MetaCursorSprite   *cursor_sprite);
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 0cf553482..729d0f50d 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -145,33 +145,33 @@ is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src)
   MetaMonitor *monitor;
   MetaLogicalMonitor *logical_monitor;
   MetaRectangle logical_monitor_layout;
-  ClutterRect logical_monitor_rect;
+  graphene_rect_t logical_monitor_rect;
   MetaCursorSprite *cursor_sprite;
 
   monitor = get_monitor (monitor_src);
   logical_monitor = meta_monitor_get_logical_monitor (monitor);
   logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
   logical_monitor_rect =
-    meta_rectangle_to_clutter_rect (&logical_monitor_layout);
+    meta_rectangle_to_graphene_rect (&logical_monitor_layout);
 
   cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
   if (cursor_sprite)
     {
-      ClutterRect cursor_rect;
+      graphene_rect_t cursor_rect;
 
       cursor_rect = meta_cursor_renderer_calculate_rect (cursor_renderer,
                                                          cursor_sprite);
-      return clutter_rect_intersection (&cursor_rect,
-                                        &logical_monitor_rect,
-                                        NULL);
+      return graphene_rect_intersection (&cursor_rect,
+                                         &logical_monitor_rect,
+                                         NULL);
     }
   else
     {
       graphene_point_t cursor_position;
 
       cursor_position = meta_cursor_renderer_get_position (cursor_renderer);
-      return clutter_rect_contains_point (&logical_monitor_rect,
-                                          &cursor_position);
+      return graphene_rect_contains_point (&logical_monitor_rect,
+                                           &cursor_position);
     }
 }
 
@@ -381,7 +381,7 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
   MetaMonitor *monitor;
   MetaLogicalMonitor *logical_monitor;
   MetaRectangle logical_monitor_layout;
-  ClutterRect logical_monitor_rect;
+  graphene_rect_t logical_monitor_rect;
   MetaRendererView *view;
   float view_scale;
   graphene_point_t cursor_position;
@@ -400,7 +400,7 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
   logical_monitor = meta_monitor_get_logical_monitor (monitor);
   logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
   logical_monitor_rect =
-    meta_rectangle_to_clutter_rect (&logical_monitor_layout);
+    meta_rectangle_to_graphene_rect (&logical_monitor_layout);
 
   view = meta_renderer_get_view_from_logical_monitor (renderer,
                                                       logical_monitor);
diff --git a/src/backends/meta-stage-private.h b/src/backends/meta-stage-private.h
index 963017688..428aec67f 100644
--- a/src/backends/meta-stage-private.h
+++ b/src/backends/meta-stage-private.h
@@ -48,10 +48,10 @@ MetaOverlay      *meta_stage_create_cursor_overlay   (MetaStage   *stage);
 void              meta_stage_remove_cursor_overlay   (MetaStage   *stage,
                                                      MetaOverlay *overlay);
 
-void              meta_stage_update_cursor_overlay   (MetaStage   *stage,
-                                                      MetaOverlay *overlay,
-                                                      CoglTexture *texture,
-                                                      ClutterRect *rect);
+void              meta_stage_update_cursor_overlay   (MetaStage       *stage,
+                                                      MetaOverlay     *overlay,
+                                                      CoglTexture     *texture,
+                                                      graphene_rect_t *rect);
 
 void meta_stage_set_active (MetaStage *stage,
                             gboolean   is_active);
diff --git a/src/backends/meta-stage.c b/src/backends/meta-stage.c
index 47922f1f3..b80431bff 100644
--- a/src/backends/meta-stage.c
+++ b/src/backends/meta-stage.c
@@ -55,8 +55,8 @@ struct _MetaOverlay
   CoglPipeline *pipeline;
   CoglTexture *texture;
 
-  ClutterRect current_rect;
-  ClutterRect previous_rect;
+  graphene_rect_t current_rect;
+  graphene_rect_t previous_rect;
   gboolean previous_is_valid;
 };
 
@@ -95,9 +95,9 @@ meta_overlay_free (MetaOverlay *overlay)
 }
 
 static void
-meta_overlay_set (MetaOverlay *overlay,
-                  CoglTexture *texture,
-                  ClutterRect *rect)
+meta_overlay_set (MetaOverlay     *overlay,
+                  CoglTexture     *texture,
+                  graphene_rect_t *rect)
 {
   if (overlay->texture != texture)
     {
@@ -135,7 +135,7 @@ meta_overlay_paint (MetaOverlay *overlay)
                                    (overlay->current_rect.origin.y +
                                     overlay->current_rect.size.height));
 
-  if (!clutter_rect_equals (&overlay->previous_rect, &overlay->current_rect))
+  if (!graphene_rect_equal (&overlay->previous_rect, &overlay->current_rect))
     {
       overlay->previous_rect = overlay->current_rect;
       overlay->previous_is_valid = TRUE;
@@ -297,9 +297,9 @@ meta_stage_new (MetaBackend *backend)
 }
 
 static void
-queue_redraw_clutter_rect (MetaStage   *stage,
-                           MetaOverlay *overlay,
-                           ClutterRect *rect)
+queue_redraw_clutter_rect (MetaStage       *stage,
+                           MetaOverlay     *overlay,
+                           graphene_rect_t *rect)
 {
   cairo_rectangle_int_t clip = {
     .x = floorf (rect->origin.x),
@@ -358,10 +358,10 @@ meta_stage_remove_cursor_overlay (MetaStage   *stage,
 }
 
 void
-meta_stage_update_cursor_overlay (MetaStage   *stage,
-                                  MetaOverlay *overlay,
-                                  CoglTexture *texture,
-                                  ClutterRect *rect)
+meta_stage_update_cursor_overlay (MetaStage       *stage,
+                                  MetaOverlay     *overlay,
+                                  CoglTexture     *texture,
+                                  graphene_rect_t *rect)
 {
   g_assert (meta_is_wayland_compositor () || texture == NULL);
 
diff --git a/src/backends/native/meta-cursor-renderer-native.c 
b/src/backends/native/meta-cursor-renderer-native.c
index 34e6f09c9..be10954ee 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -286,7 +286,7 @@ typedef struct
 {
   MetaCursorRendererNative *in_cursor_renderer_native;
   MetaLogicalMonitor *in_logical_monitor;
-  ClutterRect in_local_cursor_rect;
+  graphene_rect_t in_local_cursor_rect;
   MetaCursorSprite *in_cursor_sprite;
 
   gboolean out_painted;
@@ -306,7 +306,7 @@ update_monitor_crtc_cursor (MetaMonitor         *monitor,
     meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
   MetaCrtc *crtc;
   MetaMonitorTransform transform;
-  ClutterRect scaled_crtc_rect;
+  graphene_rect_t scaled_crtc_rect;
   float scale;
   int crtc_x, crtc_y;
   int crtc_width, crtc_height;
@@ -333,7 +333,7 @@ update_monitor_crtc_cursor (MetaMonitor         *monitor,
       crtc_height = monitor_crtc_mode->crtc_mode->height;
     }
 
-  scaled_crtc_rect = (ClutterRect) {
+  scaled_crtc_rect = (graphene_rect_t) {
     .origin = {
       .x = crtc_x / scale,
       .y = crtc_y / scale
@@ -347,9 +347,9 @@ update_monitor_crtc_cursor (MetaMonitor         *monitor,
   crtc = meta_output_get_assigned_crtc (monitor_crtc_mode->output);
 
   if (priv->has_hw_cursor &&
-      clutter_rect_intersection (&scaled_crtc_rect,
-                                 &data->in_local_cursor_rect,
-                                 NULL))
+      graphene_rect_intersection (&scaled_crtc_rect,
+                                  &data->in_local_cursor_rect,
+                                  NULL))
     {
       MetaGpuKms *gpu_kms;
       int kms_fd;
@@ -392,13 +392,13 @@ update_hw_cursor (MetaCursorRendererNative *native,
     meta_backend_get_monitor_manager (backend);
   GList *logical_monitors;
   GList *l;
-  ClutterRect rect;
+  graphene_rect_t rect;
   gboolean painted = FALSE;
 
   if (cursor_sprite)
     rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
   else
-    rect = (ClutterRect) CLUTTER_RECT_INIT_ZERO;
+    rect = GRAPHENE_RECT_INIT_ZERO;
 
   logical_monitors =
     meta_monitor_manager_get_logical_monitors (monitor_manager);
@@ -412,7 +412,7 @@ update_hw_cursor (MetaCursorRendererNative *native,
       data = (UpdateCrtcCursorData) {
         .in_cursor_renderer_native = native,
         .in_logical_monitor = logical_monitor,
-        .in_local_cursor_rect = (ClutterRect) {
+        .in_local_cursor_rect = (graphene_rect_t) {
           .origin = {
             .x = rect.origin.x - logical_monitor->rect.x,
             .y = rect.origin.y - logical_monitor->rect.y
@@ -487,7 +487,7 @@ cursor_over_transformed_logical_monitor (MetaCursorRenderer *renderer,
     meta_backend_get_monitor_manager (backend);
   GList *logical_monitors;
   GList *l;
-  ClutterRect cursor_rect;
+  graphene_rect_t cursor_rect;
 
   cursor_rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
 
@@ -497,17 +497,17 @@ cursor_over_transformed_logical_monitor (MetaCursorRenderer *renderer,
     {
       MetaLogicalMonitor *logical_monitor = l->data;
       MetaRectangle logical_monitor_layout;
-      ClutterRect logical_monitor_rect;
+      graphene_rect_t logical_monitor_rect;
       MetaMonitorTransform transform;
       GList *monitors, *l_mon;
 
       logical_monitor_layout =
         meta_logical_monitor_get_layout (logical_monitor);
       logical_monitor_rect =
-        meta_rectangle_to_clutter_rect (&logical_monitor_layout);
+        meta_rectangle_to_graphene_rect (&logical_monitor_layout);
 
-      if (!clutter_rect_intersection (&cursor_rect, &logical_monitor_rect,
-                                      NULL))
+      if (!graphene_rect_intersection (&cursor_rect, &logical_monitor_rect,
+                                       NULL))
         continue;
 
       monitors = meta_logical_monitor_get_monitors (logical_monitor);
@@ -545,7 +545,7 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer,
   MetaBackend *backend = priv->backend;
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
-  ClutterRect cursor_rect;
+  graphene_rect_t cursor_rect;
   GList *logical_monitors;
   GList *l;
   gboolean has_visible_crtc_sprite = FALSE;
@@ -564,12 +564,12 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer,
   for (l = logical_monitors; l; l = l->next)
     {
       MetaLogicalMonitor *logical_monitor = l->data;
-      ClutterRect logical_monitor_rect =
-        meta_rectangle_to_clutter_rect (&logical_monitor->rect);
+      graphene_rect_t logical_monitor_rect =
+        meta_rectangle_to_graphene_rect (&logical_monitor->rect);
 
-      if (!clutter_rect_intersection (&cursor_rect,
-                                      &logical_monitor_rect,
-                                      NULL))
+      if (!graphene_rect_intersection (&cursor_rect,
+                                       &logical_monitor_rect,
+                                       NULL))
         continue;
 
       if (calculate_cursor_crtc_sprite_scale (cursor_sprite,
@@ -692,7 +692,7 @@ calculate_cursor_sprite_gpus (MetaCursorRenderer *renderer,
   GList *gpus = NULL;
   GList *logical_monitors;
   GList *l;
-  ClutterRect cursor_rect;
+  graphene_rect_t cursor_rect;
 
   cursor_rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
 
@@ -702,16 +702,16 @@ calculate_cursor_sprite_gpus (MetaCursorRenderer *renderer,
     {
       MetaLogicalMonitor *logical_monitor = l->data;
       MetaRectangle logical_monitor_layout;
-      ClutterRect logical_monitor_rect;
+      graphene_rect_t logical_monitor_rect;
       GList *monitors, *l_mon;
 
       logical_monitor_layout =
         meta_logical_monitor_get_layout (logical_monitor);
       logical_monitor_rect =
-        meta_rectangle_to_clutter_rect (&logical_monitor_layout);
+        meta_rectangle_to_graphene_rect (&logical_monitor_layout);
 
-      if (!clutter_rect_intersection (&cursor_rect, &logical_monitor_rect,
-                                      NULL))
+      if (!graphene_rect_intersection (&cursor_rect, &logical_monitor_rect,
+                                       NULL))
         continue;
 
       monitors = meta_logical_monitor_get_monitors (logical_monitor);
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index 8b078229c..f281176b3 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -44,7 +44,7 @@ cairo_region_t * meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex)
 void meta_shaped_texture_set_transform (MetaShapedTexture    *stex,
                                         MetaMonitorTransform  transform);
 void meta_shaped_texture_set_viewport_src_rect (MetaShapedTexture *stex,
-                                                ClutterRect       *src_rect);
+                                                graphene_rect_t   *src_rect);
 void meta_shaped_texture_reset_viewport_src_rect (MetaShapedTexture *stex);
 void meta_shaped_texture_set_viewport_dst_size (MetaShapedTexture *stex,
                                                 int                dst_width,
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index e4410c5ce..fff5b30b2 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -91,7 +91,7 @@ struct _MetaShapedTexture
   gboolean size_invalid;
   MetaMonitorTransform transform;
   gboolean has_viewport_src_rect;
-  ClutterRect viewport_src_rect;
+  graphene_rect_t viewport_src_rect;
   gboolean has_viewport_dst_size;
   int viewport_dst_width;
   int viewport_dst_height;
@@ -864,8 +864,8 @@ meta_shaped_texture_update_area (MetaShapedTexture     *stex,
 
   if (stex->has_viewport_src_rect || stex->has_viewport_dst_size)
     {
-      ClutterRect viewport;
-      ClutterRect inverted_viewport;
+      graphene_rect_t viewport;
+      graphene_rect_t inverted_viewport;
       float dst_width;
       float dst_height;
       int inverted_dst_width;
@@ -877,7 +877,7 @@ meta_shaped_texture_update_area (MetaShapedTexture     *stex,
         }
       else
         {
-          viewport = (ClutterRect) {
+          viewport = (graphene_rect_t) {
             .origin.x = 0,
             .origin.y = 0,
             .size.width = stex->tex_width,
@@ -896,7 +896,7 @@ meta_shaped_texture_update_area (MetaShapedTexture     *stex,
           dst_height = (float) stex->tex_height;
         }
 
-      inverted_viewport = (ClutterRect) {
+      inverted_viewport = (graphene_rect_t) {
         .origin.x = -(viewport.origin.x * (dst_width / viewport.size.width)),
         .origin.y = -(viewport.origin.y * (dst_height / viewport.size.height)),
         .size.width = dst_width,
@@ -1041,7 +1041,7 @@ meta_shaped_texture_set_transform (MetaShapedTexture    *stex,
 
 void
 meta_shaped_texture_set_viewport_src_rect (MetaShapedTexture *stex,
-                                           ClutterRect       *src_rect)
+                                           graphene_rect_t       *src_rect)
 {
   if (!stex->has_viewport_src_rect ||
       stex->viewport_src_rect.origin.x != src_rect->origin.x ||
diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
index bf5a607ff..737d644ae 100644
--- a/src/compositor/meta-surface-actor.c
+++ b/src/compositor/meta-surface-actor.c
@@ -581,8 +581,8 @@ meta_surface_actor_set_transform (MetaSurfaceActor     *self,
 }
 
 void
-meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor  *self,
-                                          ClutterRect       *src_rect)
+meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor *self,
+                                          graphene_rect_t  *src_rect)
 {
   MetaSurfaceActorPrivate *priv =
     meta_surface_actor_get_instance_private (self);
diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h
index 1cffcf99c..08f7aea34 100644
--- a/src/compositor/meta-surface-actor.h
+++ b/src/compositor/meta-surface-actor.h
@@ -65,8 +65,8 @@ gboolean meta_surface_actor_is_unredirected (MetaSurfaceActor *actor);
 
 void meta_surface_actor_set_transform (MetaSurfaceActor     *self,
                                        MetaMonitorTransform  transform);
-void meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor  *self,
-                                               ClutterRect       *src_rect);
+void meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor *self,
+                                               graphene_rect_t  *src_rect);
 void meta_surface_actor_reset_viewport_src_rect (MetaSurfaceActor *self);
 void meta_surface_actor_set_viewport_dst_size (MetaSurfaceActor  *self,
                                                int                dst_width,
diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c
index 752af85c5..081f8a906 100644
--- a/src/compositor/region-utils.c
+++ b/src/compositor/region-utils.c
@@ -410,10 +410,10 @@ meta_region_transform (cairo_region_t       *region,
 }
 
 cairo_region_t *
-meta_region_crop_and_scale (cairo_region_t *region,
-                            ClutterRect    *src_rect,
-                            int             dst_width,
-                            int             dst_height)
+meta_region_crop_and_scale (cairo_region_t  *region,
+                            graphene_rect_t *src_rect,
+                            int              dst_width,
+                            int              dst_height)
 {
   int n_rects, i;
   cairo_rectangle_int_t *rects;
diff --git a/src/compositor/region-utils.h b/src/compositor/region-utils.h
index 84e4d83bc..745021b5b 100644
--- a/src/compositor/region-utils.h
+++ b/src/compositor/region-utils.h
@@ -111,9 +111,9 @@ cairo_region_t * meta_region_transform (cairo_region_t       *region,
                                         int                   width,
                                         int                   height);
 
-cairo_region_t * meta_region_crop_and_scale (cairo_region_t *region,
-                                             ClutterRect    *src_rect,
-                                             int             dst_width,
-                                             int             dst_height);
+cairo_region_t * meta_region_crop_and_scale (cairo_region_t  *region,
+                                             graphene_rect_t *src_rect,
+                                             int              dst_width,
+                                             int              dst_height);
 
 #endif /* __META_REGION_UTILS_H__ */
diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h
index 74f5c54b4..bfd76697f 100644
--- a/src/core/boxes-private.h
+++ b/src/core/boxes-private.h
@@ -252,10 +252,10 @@ void meta_rectangle_scale_double (const MetaRectangle  *rect,
                                   MetaRoundingStrategy  rounding_strategy,
                                   MetaRectangle        *dest);
 
-static inline ClutterRect
-meta_rectangle_to_clutter_rect (MetaRectangle *rect)
+static inline graphene_rect_t
+meta_rectangle_to_graphene_rect (MetaRectangle *rect)
 {
-  return (ClutterRect) {
+  return (graphene_rect_t) {
     .origin = {
       .x = rect->x,
       .y = rect->y
@@ -274,12 +274,12 @@ void meta_rectangle_transform (const MetaRectangle  *rect,
                                int                   height,
                                MetaRectangle        *dest);
 
-void meta_rectangle_from_clutter_rect (ClutterRect          *rect,
-                                       MetaRoundingStrategy  rounding_strategy,
-                                       MetaRectangle        *dest);
+void meta_rectangle_from_graphene_rect (const graphene_rect_t *rect,
+                                        MetaRoundingStrategy   rounding_strategy,
+                                        MetaRectangle         *dest);
 
 void meta_rectangle_crop_and_scale (const MetaRectangle *rect,
-                                    ClutterRect         *src_rect,
+                                    graphene_rect_t         *src_rect,
                                     int                  dst_width,
                                     int                  dst_height,
                                     MetaRectangle       *dest);
diff --git a/src/core/boxes.c b/src/core/boxes.c
index 25b709b5f..6b7b0bbaf 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -2042,11 +2042,11 @@ meta_rectangle_scale_double (const MetaRectangle  *rect,
                              MetaRoundingStrategy  rounding_strategy,
                              MetaRectangle        *dest)
 {
-  ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y,
-                                       rect->width, rect->height);
+  graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y,
+                                            rect->width, rect->height);
 
-  clutter_rect_scale (&tmp, scale, scale);
-  meta_rectangle_from_clutter_rect (&tmp, rounding_strategy, dest);
+  graphene_rect_scale (&tmp, scale, scale, &tmp);
+  meta_rectangle_from_graphene_rect (&tmp, rounding_strategy, dest);
 }
 
 void
@@ -2121,9 +2121,9 @@ meta_rectangle_transform (const MetaRectangle  *rect,
 }
 
 void
-meta_rectangle_from_clutter_rect (ClutterRect          *rect,
-                                  MetaRoundingStrategy  rounding_strategy,
-                                  MetaRectangle        *dest)
+meta_rectangle_from_graphene_rect (const graphene_rect_t *rect,
+                                   MetaRoundingStrategy   rounding_strategy,
+                                   MetaRectangle         *dest)
 {
   switch (rounding_strategy)
     {
@@ -2139,8 +2139,9 @@ meta_rectangle_from_clutter_rect (ClutterRect          *rect,
       break;
     case META_ROUNDING_STRATEGY_GROW:
       {
-        ClutterRect clamped = *rect;
-        clutter_rect_clamp_to_pixel (&clamped);
+        graphene_rect_t clamped = *rect;
+
+        graphene_rect_round_extents (&clamped, &clamped);
 
         *dest = (MetaRectangle) {
           .x = clamped.origin.x,
@@ -2155,18 +2156,19 @@ meta_rectangle_from_clutter_rect (ClutterRect          *rect,
 
 void
 meta_rectangle_crop_and_scale (const MetaRectangle *rect,
-                               ClutterRect         *src_rect,
+                               graphene_rect_t     *src_rect,
                                int                  dst_width,
                                int                  dst_height,
                                MetaRectangle       *dest)
 {
-  ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y,
-                                       rect->width, rect->height);
+  graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y,
+                                            rect->width, rect->height);
 
-  clutter_rect_scale (&tmp,
-                      src_rect->size.width / dst_width,
-                      src_rect->size.height / dst_height);
-  clutter_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y);
+  graphene_rect_scale (&tmp,
+                       src_rect->size.width / dst_width,
+                       src_rect->size.height / dst_height,
+                       &tmp);
+  graphene_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y);
 
-  meta_rectangle_from_clutter_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest);
+  meta_rectangle_from_graphene_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest);
 }
diff --git a/src/core/display.c b/src/core/display.c
index 71b0fb49d..c8b412ef9 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1540,7 +1540,7 @@ find_highest_logical_monitor_scale (MetaBackend      *backend,
     meta_backend_get_monitor_manager (backend);
   MetaCursorRenderer *cursor_renderer =
     meta_backend_get_cursor_renderer (backend);
-  ClutterRect cursor_rect;
+  graphene_rect_t cursor_rect;
   GList *logical_monitors;
   GList *l;
   float highest_scale = 0.0;
@@ -1553,12 +1553,12 @@ find_highest_logical_monitor_scale (MetaBackend      *backend,
   for (l = logical_monitors; l; l = l->next)
     {
       MetaLogicalMonitor *logical_monitor = l->data;
-      ClutterRect logical_monitor_rect =
-        meta_rectangle_to_clutter_rect (&logical_monitor->rect);
+      graphene_rect_t logical_monitor_rect =
+        meta_rectangle_to_graphene_rect (&logical_monitor->rect);
 
-      if (!clutter_rect_intersection (&cursor_rect,
-                                      &logical_monitor_rect,
-                                      NULL))
+      if (!graphene_rect_intersection (&cursor_rect,
+                                       &logical_monitor_rect,
+                                       NULL))
         continue;
 
       highest_scale = MAX (highest_scale, logical_monitor->scale);
diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c
index 7ce462ee7..d90cb36a7 100644
--- a/src/wayland/meta-wayland-cursor-surface.c
+++ b/src/wayland/meta-wayland-cursor-surface.c
@@ -187,17 +187,17 @@ meta_wayland_cursor_surface_is_on_logical_monitor (MetaWaylandSurfaceRole *role,
   MetaWaylandCursorSurfacePrivate *priv =
     meta_wayland_cursor_surface_get_instance_private (cursor_surface);
   graphene_point_t point;
-  ClutterRect logical_monitor_rect;
+  graphene_rect_t logical_monitor_rect;
 
   if (!priv->cursor_renderer)
     return FALSE;
 
   logical_monitor_rect =
-    meta_rectangle_to_clutter_rect (&logical_monitor->rect);
+    meta_rectangle_to_graphene_rect (&logical_monitor->rect);
 
   point = meta_cursor_renderer_get_position (priv->cursor_renderer);
 
-  return clutter_rect_contains_point (&logical_monitor_rect, &point);
+  return graphene_rect_contains_point (&logical_monitor_rect, &point);
 }
 
 static void
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 625a0d6c7..2acb921bb 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -273,7 +273,7 @@ surface_process_damage (MetaWaylandSurface *surface,
   cairo_region_t *scaled_region;
   cairo_region_t *transformed_region;
   cairo_region_t *viewport_region;
-  ClutterRect src_rect;
+  graphene_rect_t src_rect;
   MetaSurfaceActor *actor;
 
   /* If the client destroyed the buffer it attached before committing, but
@@ -302,7 +302,7 @@ surface_process_damage (MetaWaylandSurface *surface,
   scaled_region = meta_region_scale (surface_region, surface->scale);
   if (surface->viewport.has_src_rect)
     {
-      src_rect = (ClutterRect) {
+      src_rect = (graphene_rect_t) {
         .origin.x = surface->viewport.src_rect.origin.x * surface->scale,
         .origin.y = surface->viewport.src_rect.origin.y * surface->scale,
         .size.width = surface->viewport.src_rect.size.width * surface->scale,
@@ -311,7 +311,7 @@ surface_process_damage (MetaWaylandSurface *surface,
     }
   else
     {
-      src_rect = (ClutterRect) {
+      src_rect = (graphene_rect_t) {
         .size.width = surface_rect.width * surface->scale,
         .size.height = surface_rect.height * surface->scale,
       };
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index e244a3fdf..277bb0e64 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -110,7 +110,7 @@ struct _MetaWaylandPendingState
   gboolean has_new_buffer_transform;
   MetaMonitorTransform buffer_transform;
   gboolean has_new_viewport_src_rect;
-  ClutterRect viewport_src_rect;
+  graphene_rect_t viewport_src_rect;
   gboolean has_new_viewport_dst_size;
   int viewport_dst_width;
   int viewport_dst_height;
@@ -211,7 +211,7 @@ struct _MetaWaylandSurface
     gulong destroy_handler_id;
 
     gboolean has_src_rect;
-    ClutterRect src_rect;
+    graphene_rect_t src_rect;
 
     gboolean has_dst_size;
     int dst_width;
diff --git a/src/wayland/meta-wayland-text-input-legacy.c b/src/wayland/meta-wayland-text-input-legacy.c
index d4caa9aad..3ad48988a 100644
--- a/src/wayland/meta-wayland-text-input-legacy.c
+++ b/src/wayland/meta-wayland-text-input-legacy.c
@@ -475,7 +475,7 @@ text_input_commit_state (struct wl_client   *client,
 
   if (text_input->pending_state & META_WAYLAND_PENDING_STATE_INPUT_RECT)
     {
-      ClutterRect cursor_rect;
+      graphene_rect_t cursor_rect;
       float x1, y1, x2, y2;
       cairo_rectangle_int_t rect;
 
@@ -487,7 +487,7 @@ text_input_commit_state (struct wl_client   *client,
                                                      rect.y + rect.height,
                                                      &x2, &y2);
 
-      clutter_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1);
+      graphene_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1);
       clutter_input_focus_set_cursor_location (text_input->input_focus,
                                                &cursor_rect);
     }
diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c
index d63f489bd..ee9b895cb 100644
--- a/src/wayland/meta-wayland-text-input.c
+++ b/src/wayland/meta-wayland-text-input.c
@@ -573,7 +573,7 @@ text_input_commit_state (struct wl_client   *client,
 
   if (text_input->pending_state & META_WAYLAND_PENDING_STATE_INPUT_RECT)
     {
-      ClutterRect cursor_rect;
+      graphene_rect_t cursor_rect;
       float x1, y1, x2, y2;
       cairo_rectangle_int_t rect;
 
@@ -585,7 +585,7 @@ text_input_commit_state (struct wl_client   *client,
                                                      rect.y + rect.height,
                                                      &x2, &y2);
 
-      clutter_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1);
+      graphene_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1);
       clutter_input_focus_set_cursor_location (text_input->input_focus,
                                                &cursor_rect);
     }



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