diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index f5f0afa21..ac11ccc78 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -137,6 +137,7 @@ static guint clutter_main_loop_level = 0; static GSList *main_loops = NULL; guint clutter_debug_flags = 0; /* global clutter debug flag */ +guint clutter_profile_flags = 0; /* global clutter profile flag */ const guint clutter_major_version = CLUTTER_MAJOR_VERSION; const guint clutter_minor_version = CLUTTER_MINOR_VERSION; @@ -165,6 +166,12 @@ static const GDebugKey clutter_debug_keys[] = { }; #endif /* CLUTTER_ENABLE_DEBUG */ +#ifdef CLUTTER_ENABLE_PROFILE +static const GDebugKey clutter_profile_keys[] = { + {"disable-report", CLUTTER_PROFILE_DISABLE_REPORT } +}; +#endif /* CLUTTER_ENABLE_DEBUG */ + /** * clutter_get_show_fps: * @@ -1423,6 +1430,32 @@ clutter_arg_no_debug_cb (const char *key, } #endif /* CLUTTER_ENABLE_DEBUG */ +#ifdef CLUTTER_ENABLE_PROFILE +static gboolean +clutter_arg_profile_cb (const char *key, + const char *value, + gpointer user_data) +{ + clutter_profile_flags |= + g_parse_debug_string (value, + clutter_profile_keys, + G_N_ELEMENTS (clutter_profile_keys)); + return TRUE; +} + +static gboolean +clutter_arg_no_profile_cb (const char *key, + const char *value, + gpointer user_data) +{ + clutter_profile_flags &= + ~g_parse_debug_string (value, + clutter_profile_keys, + G_N_ELEMENTS (clutter_profile_keys)); + return TRUE; +} +#endif /* CLUTTER_ENABLE_PROFILE */ + GQuark clutter_init_error_quark (void) { @@ -1557,6 +1590,12 @@ static GOptionEntry clutter_args[] = { { "clutter-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_no_debug_cb, N_("Clutter debugging flags to unset"), "FLAGS" }, #endif /* CLUTTER_ENABLE_DEBUG */ +#ifdef CLUTTER_ENABLE_PROFILE + { "clutter-profile", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_profile_cb, + N_("Clutter profiling flags to set"), "FLAGS" }, + { "clutter-no-profile", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_no_profile_cb, + N_("Clutter profiling flags to unset"), "FLAGS" }, +#endif /* CLUTTER_ENABLE_PROFILE */ { NULL, }, }; @@ -1600,6 +1639,18 @@ pre_parse_hook (GOptionContext *context, } #endif /* CLUTTER_ENABLE_DEBUG */ +#ifdef CLUTTER_ENABLE_PROFILE + env_string = g_getenv ("CLUTTER_PROFILE"); + if (env_string != NULL) + { + clutter_profile_flags = + g_parse_debug_string (env_string, + clutter_profile_keys, + G_N_ELEMENTS (clutter_profile_keys)); + env_string = NULL; + } +#endif /* CLUTTER_ENABLE_PROFILE */ + env_string = g_getenv ("CLUTTER_SHOW_FPS"); if (env_string) clutter_show_fps = TRUE; diff --git a/clutter/clutter-profile.c b/clutter/clutter-profile.c index f08d37306..f5dff93f5 100644 --- a/clutter/clutter-profile.c +++ b/clutter/clutter-profile.c @@ -155,7 +155,7 @@ print_timers (UProfContext *context) static void __attribute__ ((destructor)) clutter_uprof_destructor (void) { - if (getenv ("CLUTTER_PROFILE_OUTPUT_REPORT")) + if (!(clutter_profile_flags & CLUTTER_PROFILE_DISABLE_REPORT)) { UProfReport *report = uprof_report_new ("Clutter report"); uprof_report_add_context (report, _clutter_uprof_context); diff --git a/clutter/clutter-profile.h b/clutter/clutter-profile.h index a8c57c6ec..53330a893 100644 --- a/clutter/clutter-profile.h +++ b/clutter/clutter-profile.h @@ -26,8 +26,14 @@ #ifndef _CLUTTER_PROFILE_H_ #define _CLUTTER_PROFILE_H_ +#include + G_BEGIN_DECLS +typedef enum { + CLUTTER_PROFILE_DISABLE_REPORT = 1 << 1 +} ClutterProfileFlag; + #ifdef CLUTTER_ENABLE_PROFILE #include @@ -52,6 +58,8 @@ extern UProfContext *_clutter_uprof_context; #endif /* CLUTTER_ENABLE_PROFILE */ +extern guint clutter_profile_flags; + G_END_DECLS #endif /* _CLUTTER_PROFILE_H_ */