From 2fdc7e6a1b3bcbdd5ad147e986bb0495578afd1b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 19 May 2009 16:00:18 +0100 Subject: [PATCH] [cogl] Move debugging to a configure-time switch Currently, COGL depends on defining debug symbols by manually modifying the source code. When it's done, it will forcefully print stuff to the console. Since COGL has also a pretty, runtime selectable debugging API we might as well switch everything to it. In order for this to happen, configure needs a new: --enable-cogl-debug command line switch; this will enable COGL debugging, the CoglHandle debugging and will also turn on the error checking for each GL operation. The default setting for the COGL debug defines is off, since it slows down the GL operations; enabling it for a particular debug build is trivial, though. --- cogl-debug.h | 3 ++- common/Makefile.am | 2 +- common/cogl-debug.c | 3 ++- common/cogl-handle.h | 23 ++++++++++++----------- common/cogl-internal.h | 7 +++---- gl/Makefile.am | 2 +- gles/Makefile.am | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/cogl-debug.h b/cogl-debug.h index 79a425282..b31a36c52 100644 --- a/cogl-debug.h +++ b/cogl-debug.h @@ -36,7 +36,8 @@ typedef enum { COGL_DEBUG_OFFSCREEN = 1 << 4, COGL_DEBUG_DRAW = 1 << 5, COGL_DEBUG_PANGO = 1 << 6, - COGL_DEBUG_RECTANGLES = 1 << 7 + COGL_DEBUG_RECTANGLES = 1 << 7, + COGL_DEBUG_HANDLE = 1 << 8 } CoglDebugFlags; #ifdef COGL_ENABLE_DEBUG diff --git a/common/Makefile.am b/common/Makefile.am index 47d24199b..138893a14 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -12,7 +12,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libclutter-cogl-common.la EXTRA_DIST = stb_image.c -libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) libclutter_cogl_common_la_LIBADD = -lm $(CLUTTER_LIBS) libclutter_cogl_common_la_SOURCES = \ cogl-handle.h \ diff --git a/common/cogl-debug.c b/common/cogl-debug.c index 2763314d5..85721fc22 100644 --- a/common/cogl-debug.c +++ b/common/cogl-debug.c @@ -38,7 +38,8 @@ static const GDebugKey cogl_debug_keys[] = { { "offscreen", COGL_DEBUG_OFFSCREEN }, { "draw", COGL_DEBUG_DRAW }, { "pango", COGL_DEBUG_PANGO }, - { "rectangles", COGL_DEBUG_RECTANGLES } + { "rectangles", COGL_DEBUG_RECTANGLES }, + { "handle", COGL_DEBUG_HANDLE } }; static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys); diff --git a/common/cogl-handle.h b/common/cogl-handle.h index e1f1e3c8a..7851932db 100644 --- a/common/cogl-handle.h +++ b/common/cogl-handle.h @@ -48,24 +48,25 @@ typedef struct _CoglHandleObject #ifdef COGL_HANDLE_DEBUG -#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \ - g_debug ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ - (obj), (obj)->ref_count) +#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \ + COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ + (obj), (obj)->ref_count) #define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \ CoglHandleObject *__obj = (CoglHandleObject *)handle; \ - g_debug ("COGL %s REF %p %i\n", \ - g_quark_to_string ((__obj)->klass->type), \ - (__obj), (__obj)->ref_count); } G_STMT_END + COGL_NOTE (HANDLE, "COGL %s REF %p %i\n", \ + g_quark_to_string ((__obj)->klass->type), \ + (__obj), (__obj)->ref_count); } G_STMT_END #define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \ CoglHandleObject *__obj = (CoglHandleObject *)handle; \ - g_debug ("COGL %s UNREF %p %i\n", \ - g_quark_to_string ((__obj)->klass->type), \ - (__obj), (__obj)->ref_count - 1); } G_STMT_END + COGL_NOTE (HANDLE, "COGL %s UNREF %p %i\n", \ + g_quark_to_string ((__obj)->klass->type), \ + (__obj), (__obj)->ref_count - 1); } G_STMT_END -#define COGL_HANDLE_DEBUG_FREE(obj) \ - g_debug ("COGL %s FREE %p\n", g_quark_to_string ((obj)->klass->type), (obj)) +#define COGL_HANDLE_DEBUG_FREE(obj) \ + COGL_NOTE (HANDLE, "COGL %s FREE %p\n", \ + g_quark_to_string ((obj)->klass->type), (obj)) #else /* !COGL_HANDLE_DEBUG */ diff --git a/common/cogl-internal.h b/common/cogl-internal.h index b71de0f7c..f148c35b6 100644 --- a/common/cogl-internal.h +++ b/common/cogl-internal.h @@ -24,6 +24,8 @@ #ifndef __COGL_INTERNAL_H #define __COGL_INTERNAL_H +#include "cogl-debug.h" + #ifdef HAVE_COGL_GLES2 typedef enum { COGL_BOXED_NONE, @@ -49,10 +51,7 @@ typedef struct _CoglBoxedValue } CoglBoxedValue; #endif -/* XXX - set to 1 to enable checks on every GL call */ -#define COGL_GL_DEBUG 0 - -#if COGL_GL_DEBUG +#ifdef COGL_GL_DEBUG const gchar *cogl_gl_error_to_string (GLenum error_code); diff --git a/gl/Makefile.am b/gl/Makefile.am index 26fadc42c..367f674f2 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -52,7 +52,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libclutter-cogl.la -libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_SOURCES = \ diff --git a/gles/Makefile.am b/gles/Makefile.am index abebf7275..3f84b4b2f 100644 --- a/gles/Makefile.am +++ b/gles/Makefile.am @@ -29,7 +29,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libclutter-cogl.la -libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_SOURCES = \