diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index ac11ccc78..5efa31126 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -168,6 +168,7 @@ static const GDebugKey clutter_debug_keys[] = { #ifdef CLUTTER_ENABLE_PROFILE static const GDebugKey clutter_profile_keys[] = { + {"picking-only", CLUTTER_PROFILE_PICKING_ONLY }, {"disable-report", CLUTTER_PROFILE_DISABLE_REPORT } }; #endif /* CLUTTER_ENABLE_DEBUG */ @@ -574,6 +575,11 @@ _clutter_do_pick (ClutterStage *stage, if (clutter_debug_flags & CLUTTER_DEBUG_NOP_PICKING) return CLUTTER_ACTOR (stage); +#ifdef CLUTTER_ENABLE_PROFILE + if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY) + _clutter_profile_resume (); +#endif /* CLUTTER_ENABLE_PROFILE */ + CLUTTER_COUNTER_INC (_clutter_uprof_context, do_pick_counter); CLUTTER_TIMER_START (_clutter_uprof_context, pick_timer); @@ -636,15 +642,22 @@ _clutter_do_pick (ClutterStage *stage, if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff) { - CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_timer); - return CLUTTER_ACTOR (stage); + actor = CLUTTER_ACTOR (stage); + goto result; } id = _clutter_pixel_to_id (pixel); actor = clutter_get_actor_by_gid (id); +result: + CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_timer); +#ifdef CLUTTER_ENABLE_PROFILE + if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY) + _clutter_profile_suspend (); +#endif + return actor; } @@ -1528,6 +1541,11 @@ clutter_init_real (GError **error) /* - will call to backend and cogl */ _clutter_feature_init (); +#ifdef CLUTTER_ENABLE_PROFILE + if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY) + _clutter_profile_suspend (); +#endif + /* * Resolution requires display to be open, so can only be queried after * the post_parse hooks run. diff --git a/clutter/clutter-profile.c b/clutter/clutter-profile.c index f5dff93f5..aa84f4349 100644 --- a/clutter/clutter-profile.c +++ b/clutter/clutter-profile.c @@ -8,6 +8,9 @@ UProfContext *_clutter_uprof_context; #define REPORT_COLUMN0_WIDTH 40 +static gboolean searched_for_gl_uprof_context = FALSE; +static UProfContext *gl_uprof_context = NULL; + typedef struct _ClutterUProfReportState { gulong n_frames; @@ -166,5 +169,31 @@ clutter_uprof_destructor (void) uprof_context_unref (_clutter_uprof_context); } +void +_clutter_profile_suspend (void) +{ + if (G_UNLIKELY (!searched_for_gl_uprof_context)) + { + gl_uprof_context = uprof_find_context ("OpenGL"); + searched_for_gl_uprof_context = TRUE; + } + + if (gl_uprof_context) + uprof_context_suspend (gl_uprof_context); + + /* NB: The Cogl context is linked to this so it will also be suspended... */ + uprof_context_suspend (_clutter_uprof_context); +} + +void +_clutter_profile_resume (void) +{ + if (gl_uprof_context) + uprof_context_resume (gl_uprof_context); + + /* NB: The Cogl context is linked to this so it will also be resumed... */ + uprof_context_resume (_clutter_uprof_context); +} + #endif diff --git a/clutter/clutter-profile.h b/clutter/clutter-profile.h index 53330a893..00ea77dfb 100644 --- a/clutter/clutter-profile.h +++ b/clutter/clutter-profile.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS typedef enum { + CLUTTER_PROFILE_PICKING_ONLY = 1 << 0, CLUTTER_PROFILE_DISABLE_REPORT = 1 << 1 } ClutterProfileFlag; @@ -47,6 +48,11 @@ extern UProfContext *_clutter_uprof_context; #define CLUTTER_TIMER_START UPROF_TIMER_START #define CLUTTER_TIMER_STOP UPROF_TIMER_STOP +void +_clutter_profile_suspend (void); +void +_clutter_profile_resume (void); + #else /* CLUTTER_ENABLE_PROFILE */ #define CLUTTER_STATIC_TIMER(A,B,C,D,E) extern void _clutter_dummy_decl (void) @@ -56,6 +62,9 @@ extern UProfContext *_clutter_uprof_context; #define CLUTTER_TIMER_START(A,B) G_STMT_START{ (void)0; }G_STMT_END #define CLUTTER_TIMER_STOP(A,B) G_STMT_START{ (void)0; }G_STMT_END +#define _clutter_profile_suspend() G_STMT_START {} G_STMT_END +#define _clutter_profile_resume() G_STMT_START {} G_STMT_END + #endif /* CLUTTER_ENABLE_PROFILE */ extern guint clutter_profile_flags;