5 #ifdef COGL_ENABLE_PROFILE
7 #include "cogl-profile.h"
8 #include "cogl-debug.h"
10 #include <glib/gi18n-lib.h>
13 UProfContext *_cogl_uprof_context;
16 debug_option_getter (void *user_data)
18 unsigned int shift = GPOINTER_TO_UINT (user_data);
19 return COGL_DEBUG_ENABLED (shift);
23 debug_option_setter (gboolean value, void *user_data)
25 unsigned int shift = GPOINTER_TO_UINT (user_data);
28 COGL_DEBUG_SET_FLAG (shift);
30 COGL_DEBUG_CLEAR_FLAG (shift);
34 print_exit_report (void)
36 if (getenv ("COGL_PROFILE_OUTPUT_REPORT"))
38 UProfReport *report = uprof_report_new ("Cogl report");
39 uprof_report_add_context (report, _cogl_uprof_context);
40 uprof_report_print (report);
41 uprof_report_unref (report);
43 uprof_context_unref (_cogl_uprof_context);
47 _cogl_uprof_init (void)
49 _cogl_uprof_context = uprof_context_new ("Cogl");
50 #define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
52 int shift = COGL_DEBUG_ ## MASK_NAME; \
53 uprof_context_add_boolean_option (_cogl_uprof_context, \
54 g_dgettext (GETTEXT_PACKAGE, GROUP), \
56 g_dgettext (GETTEXT_PACKAGE, \
58 g_dgettext (GETTEXT_PACKAGE, \
60 debug_option_getter, \
61 debug_option_setter, \
62 GUINT_TO_POINTER (shift)); \
65 #include "cogl-debug-options.h"
68 atexit (print_exit_report);
72 _cogl_profile_trace_message (const char *format, ...)
76 va_start (ap, format);
77 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, ap);
80 if (_cogl_uprof_context)
81 uprof_context_vtrace_message (_cogl_uprof_context, format, ap);