mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 11:30:45 -05:00
Avoid needless event copies when queueing from a backend to a stage
All backends follow the same pattern of queueing events first in ClutterMainContext, then copying them to a ClutterStage queue and immediately free them. Instead, we can just pass ownership of events directly to ClutterStage thus avoiding the allocation and copy in between. https://bugzilla.gnome.org/show_bug.cgi?id=711857
This commit is contained in:
parent
572504db4d
commit
e70a0109f2
@ -2410,7 +2410,7 @@ clutter_do_event (ClutterEvent *event)
|
||||
* because we've "looked ahead" and know all motion events that
|
||||
* will occur before drawing the frame.
|
||||
*/
|
||||
_clutter_stage_queue_event (event->any.stage, event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -62,7 +62,8 @@ gboolean _clutter_stage_needs_update (ClutterStage
|
||||
gboolean _clutter_stage_do_update (ClutterStage *stage);
|
||||
|
||||
void _clutter_stage_queue_event (ClutterStage *stage,
|
||||
ClutterEvent *event);
|
||||
ClutterEvent *event,
|
||||
gboolean copy_event);
|
||||
gboolean _clutter_stage_has_queued_events (ClutterStage *stage);
|
||||
void _clutter_stage_process_queued_events (ClutterStage *stage);
|
||||
void _clutter_stage_update_input_devices (ClutterStage *stage);
|
||||
|
@ -937,7 +937,8 @@ clutter_stage_real_fullscreen (ClutterStage *stage)
|
||||
|
||||
void
|
||||
_clutter_stage_queue_event (ClutterStage *stage,
|
||||
ClutterEvent *event)
|
||||
ClutterEvent *event,
|
||||
gboolean copy_event)
|
||||
{
|
||||
ClutterStagePrivate *priv;
|
||||
gboolean first_event;
|
||||
@ -949,7 +950,10 @@ _clutter_stage_queue_event (ClutterStage *stage,
|
||||
|
||||
first_event = priv->event_queue->length == 0;
|
||||
|
||||
g_queue_push_tail (priv->event_queue, clutter_event_copy (event));
|
||||
if (copy_event)
|
||||
event = clutter_event_copy (event);
|
||||
|
||||
g_queue_push_tail (priv->event_queue, event);
|
||||
|
||||
if (first_event)
|
||||
{
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "clutter-xkb-utils.h"
|
||||
#include "clutter-backend-private.h"
|
||||
#include "clutter-evdev.h"
|
||||
#include "clutter-stage-private.h"
|
||||
|
||||
#include "clutter-device-manager-evdev.h"
|
||||
|
||||
@ -573,8 +574,7 @@ clutter_event_dispatch (GSource *g_source,
|
||||
goto out;
|
||||
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
|
||||
/* update the device states *after* the event */
|
||||
event_state = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_EFFECTIVE);
|
||||
|
@ -309,8 +309,7 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
||||
while (spin > 0 && (event = clutter_event_get ()))
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
--spin;
|
||||
}
|
||||
|
||||
|
@ -712,8 +712,7 @@ clutter_event_dispatch (GSource *source,
|
||||
if (event)
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
}
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
@ -267,8 +267,7 @@ clutter_event_dispatch (GSource *source,
|
||||
if (event)
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "clutter-event.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-stage-private.h"
|
||||
|
||||
#include "clutter-event-wayland.h"
|
||||
|
||||
@ -94,8 +95,7 @@ clutter_event_source_wayland_dispatch (GSource *base,
|
||||
if (event)
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
}
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
@ -294,8 +294,7 @@ clutter_event_dispatch (GSource *source,
|
||||
if ((event = clutter_event_get ()))
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
}
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "clutter-event-private.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-stage-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -220,8 +221,7 @@ clutter_x11_handle_event (XEvent *xevent)
|
||||
while (spin > 0 && (event = clutter_event_get ()))
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
--spin;
|
||||
}
|
||||
|
||||
@ -321,8 +321,7 @@ clutter_event_dispatch (GSource *source,
|
||||
if (event != NULL)
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
}
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
Loading…
Reference in New Issue
Block a user