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
This commit is contained in:
Daniel van Vugt 2019-10-11 15:52:56 +08:00 committed by Georges Basile Stavracas Neto
parent 8cfa8dc0c1
commit 8c89ea5f0a
3 changed files with 14 additions and 14 deletions

View File

@ -89,8 +89,8 @@ void clutter_stage_push_pick_clip (ClutterStage *stage,
void clutter_stage_pop_pick_clip (ClutterStage *stage); void clutter_stage_pop_pick_clip (ClutterStage *stage);
ClutterActor *_clutter_stage_do_pick (ClutterStage *stage, ClutterActor *_clutter_stage_do_pick (ClutterStage *stage,
gint x, float x,
gint y, float y,
ClutterPickMode mode); ClutterPickMode mode);
ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage); ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage);

View File

@ -552,10 +552,10 @@ is_inside_input_region (const graphene_point_t *point,
} }
static gboolean static gboolean
pick_record_contains_pixel (ClutterStage *stage, pick_record_contains_point (ClutterStage *stage,
const PickRecord *rec, const PickRecord *rec,
int x, float x,
int y) float y)
{ {
const graphene_point_t point = GRAPHENE_POINT_INIT (x, y); const graphene_point_t point = GRAPHENE_POINT_INIT (x, y);
ClutterStagePrivate *priv; ClutterStagePrivate *priv;
@ -1676,8 +1676,8 @@ clutter_stage_get_redraw_clip_bounds (ClutterStage *stage,
static ClutterActor * static ClutterActor *
_clutter_stage_do_pick_on_view (ClutterStage *stage, _clutter_stage_do_pick_on_view (ClutterStage *stage,
gint x, float x,
gint y, float y,
ClutterPickMode mode, ClutterPickMode mode,
ClutterStageView *view) 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); 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; return rec->actor;
} }
@ -1748,8 +1748,8 @@ clutter_stage_get_view_at (ClutterStage *stage,
ClutterActor * ClutterActor *
_clutter_stage_do_pick (ClutterStage *stage, _clutter_stage_do_pick (ClutterStage *stage,
gint x, float x,
gint y, float y,
ClutterPickMode mode) ClutterPickMode mode)
{ {
ClutterActor *actor = CLUTTER_ACTOR (stage); ClutterActor *actor = CLUTTER_ACTOR (stage);
@ -2893,8 +2893,8 @@ clutter_stage_read_pixels (ClutterStage *stage,
ClutterActor * ClutterActor *
clutter_stage_get_actor_at_pos (ClutterStage *stage, clutter_stage_get_actor_at_pos (ClutterStage *stage,
ClutterPickMode pick_mode, ClutterPickMode pick_mode,
gint x, float x,
gint y) float y)
{ {
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL); g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);

View File

@ -201,8 +201,8 @@ gboolean clutter_stage_event (ClutterStage
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterActor * clutter_stage_get_actor_at_pos (ClutterStage *stage, ClutterActor * clutter_stage_get_actor_at_pos (ClutterStage *stage,
ClutterPickMode pick_mode, ClutterPickMode pick_mode,
gint x, float x,
gint y); float y);
CLUTTER_EXPORT CLUTTER_EXPORT
guchar * clutter_stage_read_pixels (ClutterStage *stage, guchar * clutter_stage_read_pixels (ClutterStage *stage,
gint x, gint x,