1 /*
2  * Cogl
3  *
4  * A Low Level GPU Graphics and Utilities API
5  *
6  * Copyright (C) 2007,2008,2009 Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation
10  * files (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use, copy,
12  * modify, merge, publish, distribute, sublicense, and/or sell copies
13  * of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  * SOFTWARE.
27  *
28  *
29  */
30 
31 #ifndef __COGL_DEBUG_H__
32 #define __COGL_DEBUG_H__
33 
34 #include "cogl-profile.h"
35 #include "cogl-flags.h"
36 #include "cogl-util.h"
37 
38 #include <glib.h>
39 
40 G_BEGIN_DECLS
41 
42 typedef enum
43 {
44   COGL_DEBUG_SLICING,
45   COGL_DEBUG_FRAMEBUFFER,
46   COGL_DEBUG_OFFSCREEN,
47   COGL_DEBUG_DRAW,
48   COGL_DEBUG_PANGO,
49   COGL_DEBUG_RECTANGLES,
50   COGL_DEBUG_OBJECT,
51   COGL_DEBUG_BLEND_STRINGS,
52   COGL_DEBUG_DISABLE_BATCHING,
53   COGL_DEBUG_DISABLE_PBOS,
54   COGL_DEBUG_JOURNAL,
55   COGL_DEBUG_BATCHING,
56   COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM,
57   COGL_DEBUG_MATRICES,
58   COGL_DEBUG_ATLAS,
59   COGL_DEBUG_DUMP_ATLAS_IMAGE,
60   COGL_DEBUG_DISABLE_ATLAS,
61   COGL_DEBUG_DISABLE_SHARED_ATLAS,
62   COGL_DEBUG_OPENGL,
63   COGL_DEBUG_DISABLE_TEXTURING,
64   COGL_DEBUG_SHOW_SOURCE,
65   COGL_DEBUG_DISABLE_BLENDING,
66   COGL_DEBUG_TEXTURE_PIXMAP,
67   COGL_DEBUG_BITMAP,
68   COGL_DEBUG_WIREFRAME,
69   COGL_DEBUG_DISABLE_SOFTWARE_CLIP,
70   COGL_DEBUG_DISABLE_PROGRAM_CACHES,
71   COGL_DEBUG_DISABLE_FAST_READ_PIXEL,
72   COGL_DEBUG_CLIPPING,
73   COGL_DEBUG_WINSYS,
74   COGL_DEBUG_PERFORMANCE,
75   COGL_DEBUG_SYNC_PRIMITIVE,
76   COGL_DEBUG_SYNC_FRAME,
77   COGL_DEBUG_TEXTURES,
78   COGL_DEBUG_STENCILLING,
79 
80   COGL_DEBUG_N_FLAGS
81 } CoglDebugFlags;
82 
83 COGL_EXPORT
84 GHashTable *_cogl_debug_instances;
85 #define COGL_DEBUG_N_LONGS COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_DEBUG_N_FLAGS)
86 
87 COGL_EXPORT
88 unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
89 
90 #define COGL_DEBUG_ENABLED(flag) \
91   COGL_FLAGS_GET (_cogl_debug_flags, flag)
92 
93 #define COGL_DEBUG_SET_FLAG(flag) \
94   COGL_FLAGS_SET (_cogl_debug_flags, flag, TRUE)
95 
96 #define COGL_DEBUG_CLEAR_FLAG(flag) \
97   COGL_FLAGS_SET (_cogl_debug_flags, flag, FALSE)
98 
99 #ifdef __GNUC__
100 #define COGL_NOTE(type,x,a...)                      G_STMT_START {            \
101         if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) {            \
102           _cogl_profile_trace_message ("[" #type "] " G_STRLOC ": " x, ##a); \
103         }                                           } G_STMT_END
104 
105 #else
106 #define COGL_NOTE(type,...)                         G_STMT_START {            \
107         if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) {            \
108           char *_fmt = g_strdup_printf (__VA_ARGS__);                         \
109           _cogl_profile_trace_message ("[" #type "] " G_STRLOC ": %s", _fmt);\
110           g_free (_fmt);                                                      \
111         }                                           } G_STMT_END
112 
113 #endif /* __GNUC__ */
114 
115 void
116 _cogl_debug_check_environment (void);
117 
118 void
119 _cogl_parse_debug_string (const char *value,
120                           gboolean enable,
121                           gboolean ignore_help);
122 
123 G_END_DECLS
124 
125 #endif /* __COGL_DEBUG_H__ */
126 
127