[mutter] clutter/stage: Do picking with float coordinates



commit 8c89ea5f0a24f3108c198247fb6e0cd44c979d1f
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Fri Oct 11 15:52:56 2019 +0800

    clutter/stage: Do picking with float coordinates
    
    Previously picking was done on an int (x,y) to address a particular pixel.
    While `int` was the minimum precision required, it was also an unnecessary
    type conversion.
    
    The callers (input events mainly) all provide float coordinates and the
    internal picking calculations also have always used floats. So it was
    inconsistent and unnecessary to drop to integer precision in between those.
    
    ABI break: This changes the parameter types for public function
    `clutter_stage_get_actor_at_pos`, but its documentation is already
    sufficiently vague to not need changing.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/844

 clutter/clutter/clutter-stage-private.h |  4 ++--
 clutter/clutter/clutter-stage.c         | 20 ++++++++++----------
 clutter/clutter/clutter-stage.h         |  4 ++--
 3 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h
index f32835141..ae28856f6 100644
--- a/clutter/clutter/clutter-stage-private.h
+++ b/clutter/clutter/clutter-stage-private.h
@@ -89,8 +89,8 @@ void clutter_stage_push_pick_clip (ClutterStage           *stage,
 void clutter_stage_pop_pick_clip (ClutterStage *stage);
 
 ClutterActor *_clutter_stage_do_pick (ClutterStage    *stage,
-                                      gint             x,
-                                      gint             y,
+                                      float            x,
+                                      float            y,
                                       ClutterPickMode  mode);
 
 ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage);
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 774ef5927..9435d0b14 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -552,10 +552,10 @@ is_inside_input_region (const graphene_point_t *point,
 }
 
 static gboolean
-pick_record_contains_pixel (ClutterStage     *stage,
+pick_record_contains_point (ClutterStage     *stage,
                             const PickRecord *rec,
-                            int               x,
-                            int               y)
+                            float             x,
+                            float             y)
 {
   const graphene_point_t point = GRAPHENE_POINT_INIT (x, y);
   ClutterStagePrivate *priv;
@@ -1676,8 +1676,8 @@ clutter_stage_get_redraw_clip_bounds (ClutterStage          *stage,
 
 static ClutterActor *
 _clutter_stage_do_pick_on_view (ClutterStage     *stage,
-                                gint              x,
-                                gint              y,
+                                float             x,
+                                float             y,
                                 ClutterPickMode   mode,
                                 ClutterStageView *view)
 {
@@ -1712,7 +1712,7 @@ _clutter_stage_do_pick_on_view (ClutterStage     *stage,
     {
       const PickRecord *rec = &g_array_index (priv->pick_stack, PickRecord, i);
 
-      if (rec->actor && pick_record_contains_pixel (stage, rec, x, y))
+      if (rec->actor && pick_record_contains_point (stage, rec, x, y))
         return rec->actor;
     }
 
@@ -1748,8 +1748,8 @@ clutter_stage_get_view_at (ClutterStage *stage,
 
 ClutterActor *
 _clutter_stage_do_pick (ClutterStage   *stage,
-                        gint            x,
-                        gint            y,
+                        float           x,
+                        float           y,
                         ClutterPickMode mode)
 {
   ClutterActor *actor = CLUTTER_ACTOR (stage);
@@ -2893,8 +2893,8 @@ clutter_stage_read_pixels (ClutterStage *stage,
 ClutterActor *
 clutter_stage_get_actor_at_pos (ClutterStage    *stage,
                                 ClutterPickMode  pick_mode,
-                                gint             x,
-                                gint             y)
+                                float            x,
+                                float            y)
 {
   g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
 
diff --git a/clutter/clutter/clutter-stage.h b/clutter/clutter/clutter-stage.h
index 9579f1676..2f6d582cb 100644
--- a/clutter/clutter/clutter-stage.h
+++ b/clutter/clutter/clutter-stage.h
@@ -201,8 +201,8 @@ gboolean        clutter_stage_event                             (ClutterStage
 CLUTTER_EXPORT
 ClutterActor *  clutter_stage_get_actor_at_pos                  (ClutterStage          *stage,
                                                                  ClutterPickMode        pick_mode,
-                                                                 gint                   x,
-                                                                 gint                   y);
+                                                                 float                  x,
+                                                                 float                  y);
 CLUTTER_EXPORT
 guchar *        clutter_stage_read_pixels                       (ClutterStage          *stage,
                                                                  gint                   x,


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