debug: Allow to compile a debug Cogl without cairo

For people still wanting the debugging code, but don't have or don't
want to compile cairo for their platform.
This commit is contained in:
Damien Lespiau 2011-05-16 17:50:49 +01:00
parent aa27ec56df
commit e157971cd8
2 changed files with 17 additions and 5 deletions

View File

@ -40,7 +40,7 @@
http://www.blackpawn.com/texts/lightmaps/default.html http://www.blackpawn.com/texts/lightmaps/default.html
*/ */
#ifdef COGL_ENABLE_DEBUG #if defined (COGL_ENABLE_DEBUG) && defined (HAVE_CAIRO)
/* The cairo header is only used for debugging to generate an image of /* The cairo header is only used for debugging to generate an image of
the atlas */ the atlas */
@ -48,7 +48,7 @@
static void _cogl_rectangle_map_dump_image (CoglRectangleMap *map); static void _cogl_rectangle_map_dump_image (CoglRectangleMap *map);
#endif /* COGL_ENABLE_DEBUG */ #endif /* COGL_ENABLE_DEBUG && HAVE_CAIRO */
typedef struct _CoglRectangleMapNode CoglRectangleMapNode; typedef struct _CoglRectangleMapNode CoglRectangleMapNode;
typedef struct _CoglRectangleMapStackEntry CoglRectangleMapStackEntry; typedef struct _CoglRectangleMapStackEntry CoglRectangleMapStackEntry;
@ -456,7 +456,9 @@ _cogl_rectangle_map_add (CoglRectangleMap *map,
#ifdef COGL_ENABLE_DEBUG #ifdef COGL_ENABLE_DEBUG
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DUMP_ATLAS_IMAGE))) if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DUMP_ATLAS_IMAGE)))
{ {
#ifdef HAVE_CAIRO
_cogl_rectangle_map_dump_image (map); _cogl_rectangle_map_dump_image (map);
#endif
/* Dumping the rectangle map is really slow so we might as well /* Dumping the rectangle map is really slow so we might as well
verify the space remaining here as it is also quite slow */ verify the space remaining here as it is also quite slow */
_cogl_rectangle_map_verify (map); _cogl_rectangle_map_verify (map);
@ -547,7 +549,9 @@ _cogl_rectangle_map_remove (CoglRectangleMap *map,
#ifdef COGL_ENABLE_DEBUG #ifdef COGL_ENABLE_DEBUG
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DUMP_ATLAS_IMAGE))) if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DUMP_ATLAS_IMAGE)))
{ {
#ifdef HAVE_CAIRO
_cogl_rectangle_map_dump_image (map); _cogl_rectangle_map_dump_image (map);
#endif
/* Dumping the rectangle map is really slow so we might as well /* Dumping the rectangle map is really slow so we might as well
verify the space remaining here as it is also quite slow */ verify the space remaining here as it is also quite slow */
_cogl_rectangle_map_verify (map); _cogl_rectangle_map_verify (map);
@ -694,7 +698,7 @@ _cogl_rectangle_map_free (CoglRectangleMap *map)
g_free (map); g_free (map);
} }
#ifdef COGL_ENABLE_DEBUG #if defined (COGL_ENABLE_DEBUG) && defined (HAVE_CAIRO)
static void static void
_cogl_rectangle_map_dump_image_cb (CoglRectangleMapNode *node, void *data) _cogl_rectangle_map_dump_image_cb (CoglRectangleMapNode *node, void *data)
@ -749,4 +753,4 @@ _cogl_rectangle_map_dump_image (CoglRectangleMap *map)
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
} }
#endif /* COGL_ENABLE_DEBUG */ #endif /* COGL_ENABLE_DEBUG && HAVE_CAIRO */

View File

@ -170,7 +170,15 @@ AS_CASE(
[ [
test "$cflags_set" = set || CFLAGS="$CFLAGS -g -O0" test "$cflags_set" = set || CFLAGS="$CFLAGS -g -O0"
COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_HANDLE_DEBUG -DCOGL_ENABLE_DEBUG" COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_HANDLE_DEBUG -DCOGL_ENABLE_DEBUG"
COGL_PKG_REQUIRES="$COGL_PKG_REQUIRES cairo"
# debugging code can use cairo to dump the atlas
PKG_CHECK_EXISTS([CAIRO], [cairo], [have_cairo=yes])
AS_IF([test "x$have_cairo" = "xyes"],
[
COGL_PKG_REQUIRES="$COGL_PKG_REQUIRES cairo"
AC_DEFINE([HAVE_CAIRO], [1], [Whether we have cairo or not])
])
], ],
[no], [no],
[ [