[mutter/wip/carlosg/unthrottled-wayland: 12/14] 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: 12/14] clutter: Also log overlap regions in ClutterPickContext/Stack
- Date: Sat, 17 Jul 2021 15:05:23 +0000 (UTC)
commit 5d1bad2f207440d55b6b8e7b8fcc9c877d7fc73c
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.
clutter/clutter/clutter-actor.c | 5 ++++-
clutter/clutter/clutter-pick-context.c | 15 +++++++++++++++
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, 43 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 989e479a82..27849385e4 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -3957,7 +3957,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..95897b2b48 100644
--- a/clutter/clutter/clutter-pick-context.c
+++ b/clutter/clutter/clutter-pick-context.c
@@ -118,6 +118,21 @@ 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
+ * @box: a #ClutterActorBox
+ * @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]