"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-debug.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2007,2008,2009 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  *
22  */
23
24 #ifndef __COGL_DEBUG_H__
25 #define __COGL_DEBUG_H__
26
27 #include "cogl-profile.h"
28 #include "cogl-flags.h"
29 #include "cogl-util.h"
30
31 #include <glib.h>
32
33 G_BEGIN_DECLS
34
35 typedef enum {
36   COGL_DEBUG_SLICING,
37   COGL_DEBUG_OFFSCREEN,
38   COGL_DEBUG_DRAW,
39   COGL_DEBUG_PANGO,
40   COGL_DEBUG_RECTANGLES,
41   COGL_DEBUG_HANDLE,
42   COGL_DEBUG_BLEND_STRINGS,
43   COGL_DEBUG_DISABLE_BATCHING,
44   COGL_DEBUG_DISABLE_VBOS,
45   COGL_DEBUG_DISABLE_PBOS,
46   COGL_DEBUG_JOURNAL,
47   COGL_DEBUG_BATCHING,
48   COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM,
49   COGL_DEBUG_MATRICES,
50   COGL_DEBUG_ATLAS,
51   COGL_DEBUG_DUMP_ATLAS_IMAGE,
52   COGL_DEBUG_DISABLE_ATLAS,
53   COGL_DEBUG_DISABLE_SHARED_ATLAS,
54   COGL_DEBUG_OPENGL,
55   COGL_DEBUG_DISABLE_TEXTURING,
56   COGL_DEBUG_DISABLE_ARBFP,
57   COGL_DEBUG_DISABLE_FIXED,
58   COGL_DEBUG_DISABLE_GLSL,
59   COGL_DEBUG_SHOW_SOURCE,
60   COGL_DEBUG_DISABLE_BLENDING,
61   COGL_DEBUG_TEXTURE_PIXMAP,
62   COGL_DEBUG_BITMAP,
63   COGL_DEBUG_DISABLE_NPOT_TEXTURES,
64   COGL_DEBUG_WIREFRAME,
65   COGL_DEBUG_DISABLE_SOFTWARE_CLIP,
66   COGL_DEBUG_DISABLE_PROGRAM_CACHES,
67   COGL_DEBUG_DISABLE_FAST_READ_PIXEL,
68   COGL_DEBUG_CLIPPING,
69   COGL_DEBUG_WINSYS,
70
71   COGL_DEBUG_N_FLAGS
72 } CoglDebugFlags;
73
74 #ifdef COGL_ENABLE_DEBUG
75
76 #define COGL_DEBUG_N_LONGS COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_DEBUG_N_FLAGS)
77
78 /* _cogl_debug_flags currently needs to exported outside of the shared
79    library for cogl-pango. The special COGL_EXPORT macro is needed to
80    get this to work when building with MSVC */
81 COGL_EXPORT extern unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
82
83 extern GHashTable *_cogl_debug_instances;
84
85 #define COGL_DEBUG_ENABLED(flag) \
86   COGL_FLAGS_GET (_cogl_debug_flags, flag)
87
88 #define COGL_DEBUG_SET_FLAG(flag) \
89   COGL_FLAGS_SET (_cogl_debug_flags, flag, TRUE)
90
91 #define COGL_DEBUG_CLEAR_FLAG(flag) \
92   COGL_FLAGS_SET (_cogl_debug_flags, flag, FALSE)
93
94 #ifdef __GNUC__
95 #define COGL_NOTE(type,x,a...)                      G_STMT_START {            \
96         if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) {            \
97           _cogl_profile_trace_message ("[" #type "] " G_STRLOC " & " x, ##a); \
98         }                                           } G_STMT_END
99
100 #else
101 #define COGL_NOTE(type,...)                         G_STMT_START {            \
102         if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) {            \
103           char *_fmt = g_strdup_printf (__VA_ARGS__);                         \
104           _cogl_profile_trace_message ("[" #type "] " G_STRLOC " & %s", _fmt);\
105           g_free (_fmt);                                                      \
106         }                                           } G_STMT_END
107
108 #endif /* __GNUC__ */
109
110 #else /* !COGL_ENABLE_DEBUG */
111
112 #define COGL_NOTE(type,...) G_STMT_START {} G_STMT_END
113
114 #define COGL_DEBUG_ENABLED(flag) FALSE
115
116 #define COGL_DEBUG_SET_FLAG(flag) \
117   G_STMT_START { } G_STMT_END
118
119 #define COGL_DEBUG_CLEAR_FLAG(flag) \
120   G_STMT_START { } G_STMT_END
121
122 #endif /* COGL_ENABLE_DEBUG */
123
124 void
125 _cogl_debug_check_environment (void);
126
127 void
128 _cogl_parse_debug_string (const char *value,
129                           gboolean enable,
130                           gboolean ignore_help);
131
132 G_END_DECLS
133
134 #endif /* __COGL_DEBUG_H__ */
135