[mutter/wip/carlosg/unthrottled-wayland: 16/23] clutter: Also log overlap regions in ClutterPickContext/Stack
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/unthrottled-wayland: 16/23] clutter: Also log overlap regions in ClutterPickContext/Stack
- Date: Tue, 7 Dec 2021 18:56:11 +0000 (UTC)
commit 284cfa0969de9b2ec3c62785c18479a2afb8e8da
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jun 30 16:02:43 2021 +0200
clutter: Also log overlap regions in ClutterPickContext/Stack
These may be used for optimizations once we find the pick actor,
so picking can be avoided in areas we know didn't cross into
other actors. Nothing makes use of it yet though, just log these
so far.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
clutter/clutter/clutter-actor.c | 5 ++++-
clutter/clutter/clutter-pick-context.c | 14 ++++++++++++++
clutter/clutter/clutter-pick-context.h | 3 +++
clutter/clutter/clutter-pick-stack-private.h | 2 ++
clutter/clutter/clutter-pick-stack.c | 20 +++++++++++++++++++-
5 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 5368804d28..3da25d640d 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -3960,7 +3960,10 @@ clutter_actor_pick (ClutterActor *actor,
clutter_paint_volume_to_box (&priv->last_paint_volume, &box);
if (!clutter_pick_context_intersects_box (pick_context, &box))
- goto out;
+ {
+ clutter_pick_context_log_overlap (pick_context, actor);
+ goto out;
+ }
}
if (priv->enable_model_view_transform)
diff --git a/clutter/clutter/clutter-pick-context.c b/clutter/clutter/clutter-pick-context.c
index 2f054d318f..28e095bfa6 100644
--- a/clutter/clutter/clutter-pick-context.c
+++ b/clutter/clutter/clutter-pick-context.c
@@ -118,6 +118,20 @@ clutter_pick_context_log_pick (ClutterPickContext *pick_context,
clutter_pick_stack_log_pick (pick_context->pick_stack, box, actor);
}
+/**
+ * clutter_pick_context_log_overlap:
+ * @pick_context: a #ClutterPickContext
+ * @actor: a #ClutterActor
+ *
+ * Logs an overlapping actor into the pick stack.
+ */
+void
+clutter_pick_context_log_overlap (ClutterPickContext *pick_context,
+ ClutterActor *actor)
+{
+ clutter_pick_stack_log_overlap (pick_context->pick_stack, actor);
+}
+
/**
* clutter_pick_context_push_clip:
* @pick_context: a #ClutterPickContext
diff --git a/clutter/clutter/clutter-pick-context.h b/clutter/clutter/clutter-pick-context.h
index 5792be6b58..730db1a0a0 100644
--- a/clutter/clutter/clutter-pick-context.h
+++ b/clutter/clutter/clutter-pick-context.h
@@ -50,6 +50,9 @@ CLUTTER_EXPORT
void clutter_pick_context_log_pick (ClutterPickContext *pick_context,
const ClutterActorBox *box,
ClutterActor *actor);
+CLUTTER_EXPORT
+void clutter_pick_context_log_overlap (ClutterPickContext *pick_context,
+ ClutterActor *actor);
CLUTTER_EXPORT
void clutter_pick_context_push_clip (ClutterPickContext *pick_context,
diff --git a/clutter/clutter/clutter-pick-stack-private.h b/clutter/clutter/clutter-pick-stack-private.h
index 0523fcafe6..93181c3336 100644
--- a/clutter/clutter/clutter-pick-stack-private.h
+++ b/clutter/clutter/clutter-pick-stack-private.h
@@ -42,6 +42,8 @@ void clutter_pick_stack_seal (ClutterPickStack *pick_stack);
void clutter_pick_stack_log_pick (ClutterPickStack *pick_stack,
const ClutterActorBox *box,
ClutterActor *actor);
+void clutter_pick_stack_log_overlap (ClutterPickStack *pick_stack,
+ ClutterActor *actor);
void clutter_pick_stack_push_clip (ClutterPickStack *pick_stack,
const ClutterActorBox *box);
diff --git a/clutter/clutter/clutter-pick-stack.c b/clutter/clutter/clutter-pick-stack.c
index 87d3a3ca8d..c5bc87ccca 100644
--- a/clutter/clutter/clutter-pick-stack.c
+++ b/clutter/clutter/clutter-pick-stack.c
@@ -32,6 +32,7 @@ typedef struct
Record base;
ClutterActor *actor;
int clip_index;
+ gboolean is_overlap;
} PickRecord;
typedef struct
@@ -342,6 +343,7 @@ clutter_pick_stack_log_pick (ClutterPickStack *pick_stack,
g_assert (!pick_stack->sealed);
+ rec.is_overlap = FALSE;
rec.actor = actor;
rec.clip_index = pick_stack->current_clip_stack_top;
rec.base.rect = *box;
@@ -352,6 +354,21 @@ clutter_pick_stack_log_pick (ClutterPickStack *pick_stack,
g_array_append_val (pick_stack->vertices_stack, rec);
}
+void
+clutter_pick_stack_log_overlap (ClutterPickStack *pick_stack,
+ ClutterActor *actor)
+{
+ PickRecord rec = { 0 };
+
+ g_assert (!pick_stack->sealed);
+
+ rec.is_overlap = TRUE;
+ rec.actor = actor;
+ rec.clip_index = pick_stack->current_clip_stack_top;
+
+ g_array_append_val (pick_stack->vertices_stack, rec);
+}
+
void
clutter_pick_stack_push_clip (ClutterPickStack *pick_stack,
const ClutterActorBox *box)
@@ -428,7 +445,8 @@ clutter_pick_stack_search_actor (ClutterPickStack *pick_stack,
PickRecord *rec =
&g_array_index (pick_stack->vertices_stack, PickRecord, i);
- if (rec->actor && ray_intersects_record (pick_stack, rec, point, ray))
+ if (!rec->is_overlap && rec->actor &&
+ ray_intersects_record (pick_stack, rec, point, ray))
return rec->actor;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]