mirror of
https://github.com/brl/mutter.git
synced 2025-02-17 05:44:08 +00:00
[cogl] Rework the debug messages
COGL has a debug message system like Clutter's own. In parallel, it also uses a coupld of #defines. Spread around there are also calls to printf() instead to the more correct g_log* wrappers. This commit tries to unify and clean up the macros and the debug message handling inside COGL to be more consistent.
This commit is contained in:
parent
e73a3899e5
commit
cf4a49061a
@ -46,40 +46,35 @@ typedef struct _CoglHandleObject
|
|||||||
/* Helper macro to encapsulate the common code for COGL reference
|
/* Helper macro to encapsulate the common code for COGL reference
|
||||||
counted handles */
|
counted handles */
|
||||||
|
|
||||||
#if COGL_DEBUG
|
#ifdef COGL_HANDLE_DEBUG
|
||||||
|
|
||||||
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
|
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
|
||||||
printf ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
|
g_debug ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
|
||||||
(obj), (obj)->ref_count)
|
(obj), (obj)->ref_count)
|
||||||
|
|
||||||
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) \
|
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \
|
||||||
do { \
|
CoglHandleObject *__obj = (CoglHandleObject *)handle; \
|
||||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
g_debug ("COGL %s REF %p %i\n", \
|
||||||
printf ("COGL %s REF %p %i\n", \
|
g_quark_to_string ((__obj)->klass->type), \
|
||||||
g_quark_to_string ((obj)->klass->type), \
|
(__obj), (__obj)->ref_count); } G_STMT_END
|
||||||
(obj), (obj)->ref_count); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) \
|
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \
|
||||||
do { \
|
CoglHandleObject *__obj = (CoglHandleObject *)handle; \
|
||||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
g_debug ("COGL %s UNREF %p %i\n", \
|
||||||
printf ("COGL %s UNREF %p %i\n", \
|
g_quark_to_string ((__obj)->klass->type), \
|
||||||
g_quark_to_string ((obj)->klass->type), \
|
(__obj), (__obj)->ref_count - 1); } G_STMT_END
|
||||||
(obj), (obj)->ref_count - 1); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define COGL_HANDLE_DEBUG_FREE(obj) \
|
#define COGL_HANDLE_DEBUG_FREE(obj) \
|
||||||
printf ("COGL %s FREE %p\n", \
|
g_debug ("COGL %s FREE %p\n", g_quark_to_string ((obj)->klass->type), (obj))
|
||||||
g_quark_to_string ((obj)->klass->type), (obj)) \
|
|
||||||
|
|
||||||
#else /* COGL_DEBUG */
|
#else /* !COGL_HANDLE_DEBUG */
|
||||||
|
|
||||||
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj)
|
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj)
|
||||||
#define _COGL_HANDLE_DEBUG_REF(type_name, obj)
|
#define _COGL_HANDLE_DEBUG_REF(type_name, obj)
|
||||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, obj)
|
#define _COGL_HANDLE_DEBUG_UNREF(type_name, obj)
|
||||||
#define COGL_HANDLE_DEBUG_FREE(obj)
|
#define COGL_HANDLE_DEBUG_FREE(obj)
|
||||||
|
|
||||||
#endif /* COGL_DEBUG */
|
#endif /* COGL_HANDLE_DEBUG */
|
||||||
|
|
||||||
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
|
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
|
||||||
\
|
\
|
||||||
@ -103,8 +98,7 @@ typedef struct _CoglHandleObject
|
|||||||
obj->klass = &_cogl_##type_name##_class; \
|
obj->klass = &_cogl_##type_name##_class; \
|
||||||
if (!obj->klass->type) \
|
if (!obj->klass->type) \
|
||||||
{ \
|
{ \
|
||||||
obj->klass->type = \
|
obj->klass->type = _cogl_##type_name##_get_type (); \
|
||||||
_cogl_##type_name##_get_type (); \
|
|
||||||
obj->klass->virt_free = _cogl_##type_name##_free; \
|
obj->klass->virt_free = _cogl_##type_name##_free; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@ -126,8 +120,7 @@ typedef struct _CoglHandleObject
|
|||||||
if (handle == COGL_INVALID_HANDLE) \
|
if (handle == COGL_INVALID_HANDLE) \
|
||||||
return FALSE; \
|
return FALSE; \
|
||||||
\
|
\
|
||||||
return (obj->klass->type == \
|
return (obj->klass->type == _cogl_##type_name##_get_type ()); \
|
||||||
_cogl_##type_name##_get_type ()); \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
CoglHandle G_GNUC_DEPRECATED \
|
CoglHandle G_GNUC_DEPRECATED \
|
||||||
@ -150,7 +143,7 @@ typedef struct _CoglHandleObject
|
|||||||
{ \
|
{ \
|
||||||
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
|
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
|
||||||
": Ignoring unref of Cogl handle " \
|
": Ignoring unref of Cogl handle " \
|
||||||
"due to type missmatch"); \
|
"due to type mismatch"); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
@ -49,29 +49,28 @@ typedef struct _CoglBoxedValue
|
|||||||
} CoglBoxedValue;
|
} CoglBoxedValue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define COGL_DEBUG 0
|
/* XXX - set to 1 to enable checks on every GL call */
|
||||||
|
#define COGL_GL_DEBUG 0
|
||||||
|
|
||||||
#if COGL_DEBUG
|
#if COGL_GL_DEBUG
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
const gchar *cogl_gl_error_to_string (GLenum error_code);
|
const gchar *cogl_gl_error_to_string (GLenum error_code);
|
||||||
|
|
||||||
#define GE(x...) G_STMT_START { \
|
#define GE(x...) G_STMT_START { \
|
||||||
GLenum __err; \
|
GLenum __err; \
|
||||||
(x); \
|
(x); \
|
||||||
while ((err = glGetError ()) != GL_NO_ERROR) \
|
while ((__err = glGetError ()) != GL_NO_ERROR) \
|
||||||
{ \
|
{ \
|
||||||
g_warning ("%s: GL error (%d): %s\n", \
|
g_warning ("%s: GL error (%d): %s\n", \
|
||||||
G_STRLOC, \
|
G_STRLOC, \
|
||||||
cogl_gl_error_to_string (err));\
|
cogl_gl_error_to_string (__err)); \
|
||||||
} } G_STMT_END
|
} } G_STMT_END
|
||||||
|
|
||||||
#else /* COGL_DEBUG */
|
#else /* !COGL_GL_DEBUG */
|
||||||
|
|
||||||
#define GE(x) (x)
|
#define GE(x) (x)
|
||||||
|
|
||||||
#endif /* COGL_DEBUG */
|
#endif /* COGL_GL_DEBUG */
|
||||||
|
|
||||||
#define COGL_ENABLE_BLEND (1<<1)
|
#define COGL_ENABLE_BLEND (1<<1)
|
||||||
#define COGL_ENABLE_ALPHA_TEST (1<<2)
|
#define COGL_ENABLE_ALPHA_TEST (1<<2)
|
||||||
@ -79,16 +78,10 @@ const gchar *cogl_gl_error_to_string (GLenum error_code);
|
|||||||
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
|
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
|
||||||
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
|
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
|
||||||
|
|
||||||
void
|
void _cogl_features_init (void);
|
||||||
_cogl_features_init (void);
|
gint _cogl_get_format_bpp (CoglPixelFormat format);
|
||||||
|
|
||||||
gint
|
void cogl_enable (gulong flags);
|
||||||
_cogl_get_format_bpp (CoglPixelFormat format);
|
gulong cogl_get_enable (void);
|
||||||
|
|
||||||
void
|
|
||||||
cogl_enable (gulong flags);
|
|
||||||
|
|
||||||
gulong
|
|
||||||
cogl_get_enable ();
|
|
||||||
|
|
||||||
#endif /* __COGL_INTERNAL_H */
|
#endif /* __COGL_INTERNAL_H */
|
||||||
|
@ -372,9 +372,7 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
|
|||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
#if COGL_DEBUG
|
COGL_NOTE (DRAW, "Drawing Tex Quad (Sliced Mode)");
|
||||||
printf("=== Drawing Tex Quad (Sliced Mode) ===\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We can't use hardware repeat so we need to set clamp to edge
|
/* We can't use hardware repeat so we need to set clamp to edge
|
||||||
otherwise it might pull in edge pixels from the other side */
|
otherwise it might pull in edge pixels from the other side */
|
||||||
@ -485,17 +483,21 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
|
|||||||
slice_tx2 /= iter_x.span->size;
|
slice_tx2 /= iter_x.span->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COGL_DEBUG
|
COGL_NOTE (DRAW,
|
||||||
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
"~~~~~ slice (%d, %d)\n"
|
||||||
printf("qx1: %f\n", (slice_qx1));
|
"qx1: %f\t"
|
||||||
printf("qy1: %f\n", (slice_qy1));
|
"qy1: %f\n"
|
||||||
printf("qx2: %f\n", (slice_qx2));
|
"qx2: %f\t"
|
||||||
printf("qy2: %f\n", (slice_qy2));
|
"qy2: %f\n"
|
||||||
printf("tx1: %f\n", (slice_tx1));
|
"tx1: %f\t"
|
||||||
printf("ty1: %f\n", (slice_ty1));
|
"ty1: %f\n"
|
||||||
printf("tx2: %f\n", (slice_tx2));
|
"tx2: %f\t"
|
||||||
printf("ty2: %f\n", (slice_ty2));
|
"ty2: %f\n",
|
||||||
#endif
|
iter_x.index, iter_y.index,
|
||||||
|
slice_qx1, slice_qy1,
|
||||||
|
slice_qx2, slice_qy2,
|
||||||
|
slice_tx1, slice_ty1,
|
||||||
|
slice_tx2, slice_ty2);
|
||||||
|
|
||||||
/* Pick and bind opengl texture object */
|
/* Pick and bind opengl texture object */
|
||||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
|
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "cogl-debug.h"
|
||||||
#include "cogl-internal.h"
|
#include "cogl-internal.h"
|
||||||
#include "cogl-util.h"
|
#include "cogl-util.h"
|
||||||
#include "cogl-context.h"
|
#include "cogl-context.h"
|
||||||
@ -46,7 +47,7 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
|||||||
#include "cogl-gles2-wrapper.h"
|
#include "cogl-gles2-wrapper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef COGL_DEBUG
|
#ifdef COGL_GL_DEBUG
|
||||||
/* GL error to string conversion */
|
/* GL error to string conversion */
|
||||||
static const struct {
|
static const struct {
|
||||||
GLuint error_code;
|
GLuint error_code;
|
||||||
@ -78,18 +79,16 @@ cogl_gl_error_to_string (GLenum error_code)
|
|||||||
return gl_errors[i].error_string;
|
return gl_errors[i].error_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Unknown error";
|
return "Unknown GL error";
|
||||||
}
|
}
|
||||||
#endif /* COGL_DEBUG */
|
#endif /* COGL_GL_DEBUG */
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_clear (const CoglColor *color, gulong buffers)
|
cogl_clear (const CoglColor *color, gulong buffers)
|
||||||
{
|
{
|
||||||
GLbitfield gl_buffers = 0;
|
GLbitfield gl_buffers = 0;
|
||||||
|
|
||||||
#if COGL_DEBUG
|
COGL_NOTE (DRAW, "Clear begin");
|
||||||
fprintf(stderr, "\n ============== Paint Start ================ \n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cogl_clip_ensure ();
|
cogl_clip_ensure ();
|
||||||
|
|
||||||
@ -101,20 +100,29 @@ cogl_clear (const CoglColor *color, gulong buffers)
|
|||||||
0.0) );
|
0.0) );
|
||||||
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffers & COGL_BUFFER_BIT_DEPTH)
|
if (buffers & COGL_BUFFER_BIT_DEPTH)
|
||||||
gl_buffers |= GL_DEPTH_BUFFER_BIT;
|
gl_buffers |= GL_DEPTH_BUFFER_BIT;
|
||||||
|
|
||||||
if (buffers & COGL_BUFFER_BIT_STENCIL)
|
if (buffers & COGL_BUFFER_BIT_STENCIL)
|
||||||
gl_buffers |= GL_STENCIL_BUFFER_BIT;
|
gl_buffers |= GL_STENCIL_BUFFER_BIT;
|
||||||
|
|
||||||
if (!gl_buffers)
|
if (!gl_buffers)
|
||||||
{
|
{
|
||||||
static gboolean shown = FALSE;
|
static gboolean shown = FALSE;
|
||||||
|
|
||||||
if (!shown)
|
if (!shown)
|
||||||
g_warning ("You should specify at least one auxiliary buffer when calling cogl_clear");
|
{
|
||||||
|
g_warning ("You should specify at least one auxiliary buffer "
|
||||||
|
"when calling cogl_clear");
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glClear (gl_buffers);
|
glClear (gl_buffers);
|
||||||
|
|
||||||
|
COGL_NOTE (DRAW, "Clear end");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
@ -563,24 +571,31 @@ cogl_get_viewport (float v[4])
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
|
cogl_get_bitmasks (gint *red,
|
||||||
|
gint *green,
|
||||||
|
gint *blue,
|
||||||
|
gint *alpha)
|
||||||
{
|
{
|
||||||
GLint value;
|
GLint value;
|
||||||
|
|
||||||
if (red)
|
if (red)
|
||||||
{
|
{
|
||||||
GE( glGetIntegerv(GL_RED_BITS, &value) );
|
GE( glGetIntegerv(GL_RED_BITS, &value) );
|
||||||
*red = value;
|
*red = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (green)
|
if (green)
|
||||||
{
|
{
|
||||||
GE( glGetIntegerv(GL_GREEN_BITS, &value) );
|
GE( glGetIntegerv(GL_GREEN_BITS, &value) );
|
||||||
*green = value;
|
*green = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blue)
|
if (blue)
|
||||||
{
|
{
|
||||||
GE( glGetIntegerv(GL_BLUE_BITS, &value) );
|
GE( glGetIntegerv(GL_BLUE_BITS, &value) );
|
||||||
*blue = value;
|
*blue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alpha)
|
if (alpha)
|
||||||
{
|
{
|
||||||
GE( glGetIntegerv(GL_ALPHA_BITS, &value ) );
|
GE( glGetIntegerv(GL_ALPHA_BITS, &value ) );
|
||||||
|
@ -44,17 +44,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/*
|
|
||||||
#define COGL_DEBUG 1
|
|
||||||
|
|
||||||
#define GE(x) \
|
|
||||||
{ \
|
|
||||||
glGetError(); x; \
|
|
||||||
GLuint err = glGetError(); \
|
|
||||||
if (err != 0) \
|
|
||||||
printf("err: 0x%x\n", err); \
|
|
||||||
} */
|
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
#ifdef HAVE_COGL_GL
|
||||||
|
|
||||||
#define glDrawRangeElements ctx->pf_glDrawRangeElements
|
#define glDrawRangeElements ctx->pf_glDrawRangeElements
|
||||||
@ -943,12 +932,11 @@ _cogl_texture_slices_create (CoglTexture *tex)
|
|||||||
{
|
{
|
||||||
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x);
|
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x);
|
||||||
|
|
||||||
#if COGL_DEBUG
|
COGL_NOTE (TEXTURE, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
|
||||||
printf ("CREATE SLICE (%d,%d)\n", x,y);
|
x, y,
|
||||||
printf ("size: (%d x %d)\n",
|
|
||||||
x_span->size - x_span->waste,
|
x_span->size - x_span->waste,
|
||||||
y_span->size - y_span->waste);
|
y_span->size - y_span->waste);
|
||||||
#endif
|
|
||||||
/* Setup texture parameters */
|
/* Setup texture parameters */
|
||||||
GE( glBindTexture (tex->gl_target,
|
GE( glBindTexture (tex->gl_target,
|
||||||
gl_handles[y * n_x_slices + x]) );
|
gl_handles[y * n_x_slices + x]) );
|
||||||
|
@ -40,17 +40,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/*
|
|
||||||
#define COGL_DEBUG 1
|
|
||||||
|
|
||||||
#define GE(x) \
|
|
||||||
{ \
|
|
||||||
glGetError(); x; \
|
|
||||||
GLuint err = glGetError(); \
|
|
||||||
if (err != 0) \
|
|
||||||
printf("err: 0x%x\n", err); \
|
|
||||||
} */
|
|
||||||
|
|
||||||
extern void _cogl_journal_flush (void);
|
extern void _cogl_journal_flush (void);
|
||||||
|
|
||||||
static void _cogl_texture_free (CoglTexture *tex);
|
static void _cogl_texture_free (CoglTexture *tex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user