mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05: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
|
||||
counted handles */
|
||||
|
||||
#if COGL_DEBUG
|
||||
#ifdef COGL_HANDLE_DEBUG
|
||||
|
||||
#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)
|
||||
|
||||
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) \
|
||||
do { \
|
||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
||||
printf ("COGL %s REF %p %i\n", \
|
||||
g_quark_to_string ((obj)->klass->type), \
|
||||
(obj), (obj)->ref_count); \
|
||||
} while (0)
|
||||
#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
|
||||
|
||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) \
|
||||
do { \
|
||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
||||
printf ("COGL %s UNREF %p %i\n", \
|
||||
g_quark_to_string ((obj)->klass->type), \
|
||||
(obj), (obj)->ref_count - 1); \
|
||||
} while (0)
|
||||
#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
|
||||
|
||||
#define COGL_HANDLE_DEBUG_FREE(obj) \
|
||||
printf ("COGL %s FREE %p\n", \
|
||||
g_quark_to_string ((obj)->klass->type), (obj)) \
|
||||
g_debug ("COGL %s FREE %p\n", 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_REF(type_name, obj)
|
||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, obj)
|
||||
#define COGL_HANDLE_DEBUG_FREE(obj)
|
||||
|
||||
#endif /* COGL_DEBUG */
|
||||
#endif /* COGL_HANDLE_DEBUG */
|
||||
|
||||
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
|
||||
\
|
||||
@ -103,8 +98,7 @@ typedef struct _CoglHandleObject
|
||||
obj->klass = &_cogl_##type_name##_class; \
|
||||
if (!obj->klass->type) \
|
||||
{ \
|
||||
obj->klass->type = \
|
||||
_cogl_##type_name##_get_type (); \
|
||||
obj->klass->type = _cogl_##type_name##_get_type (); \
|
||||
obj->klass->virt_free = _cogl_##type_name##_free; \
|
||||
} \
|
||||
\
|
||||
@ -126,8 +120,7 @@ typedef struct _CoglHandleObject
|
||||
if (handle == COGL_INVALID_HANDLE) \
|
||||
return FALSE; \
|
||||
\
|
||||
return (obj->klass->type == \
|
||||
_cogl_##type_name##_get_type ()); \
|
||||
return (obj->klass->type == _cogl_##type_name##_get_type ()); \
|
||||
} \
|
||||
\
|
||||
CoglHandle G_GNUC_DEPRECATED \
|
||||
@ -150,7 +143,7 @@ typedef struct _CoglHandleObject
|
||||
{ \
|
||||
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
|
||||
": Ignoring unref of Cogl handle " \
|
||||
"due to type missmatch"); \
|
||||
"due to type mismatch"); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
|
@ -49,29 +49,28 @@ typedef struct _CoglBoxedValue
|
||||
} CoglBoxedValue;
|
||||
#endif
|
||||
|
||||
#define COGL_DEBUG 0
|
||||
/* XXX - set to 1 to enable checks on every GL call */
|
||||
#define COGL_GL_DEBUG 0
|
||||
|
||||
#if COGL_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
#if COGL_GL_DEBUG
|
||||
|
||||
const gchar *cogl_gl_error_to_string (GLenum error_code);
|
||||
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum __err; \
|
||||
(x); \
|
||||
while ((err = glGetError ()) != GL_NO_ERROR) \
|
||||
while ((__err = glGetError ()) != GL_NO_ERROR) \
|
||||
{ \
|
||||
g_warning ("%s: GL error (%d): %s\n", \
|
||||
G_STRLOC, \
|
||||
cogl_gl_error_to_string (err));\
|
||||
cogl_gl_error_to_string (__err)); \
|
||||
} } G_STMT_END
|
||||
|
||||
#else /* COGL_DEBUG */
|
||||
#else /* !COGL_GL_DEBUG */
|
||||
|
||||
#define GE(x) (x)
|
||||
|
||||
#endif /* COGL_DEBUG */
|
||||
#endif /* COGL_GL_DEBUG */
|
||||
|
||||
#define COGL_ENABLE_BLEND (1<<1)
|
||||
#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_BACKFACE_CULLING (1<<5)
|
||||
|
||||
void
|
||||
_cogl_features_init (void);
|
||||
void _cogl_features_init (void);
|
||||
gint _cogl_get_format_bpp (CoglPixelFormat format);
|
||||
|
||||
gint
|
||||
_cogl_get_format_bpp (CoglPixelFormat format);
|
||||
|
||||
void
|
||||
cogl_enable (gulong flags);
|
||||
|
||||
gulong
|
||||
cogl_get_enable ();
|
||||
void cogl_enable (gulong flags);
|
||||
gulong cogl_get_enable (void);
|
||||
|
||||
#endif /* __COGL_INTERNAL_H */
|
||||
|
@ -372,9 +372,7 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
#if COGL_DEBUG
|
||||
printf("=== Drawing Tex Quad (Sliced Mode) ===\n");
|
||||
#endif
|
||||
COGL_NOTE (DRAW, "Drawing Tex Quad (Sliced Mode)");
|
||||
|
||||
/* 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 */
|
||||
@ -485,17 +483,21 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
|
||||
slice_tx2 /= iter_x.span->size;
|
||||
}
|
||||
|
||||
#if COGL_DEBUG
|
||||
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
||||
printf("qx1: %f\n", (slice_qx1));
|
||||
printf("qy1: %f\n", (slice_qy1));
|
||||
printf("qx2: %f\n", (slice_qx2));
|
||||
printf("qy2: %f\n", (slice_qy2));
|
||||
printf("tx1: %f\n", (slice_tx1));
|
||||
printf("ty1: %f\n", (slice_ty1));
|
||||
printf("tx2: %f\n", (slice_tx2));
|
||||
printf("ty2: %f\n", (slice_ty2));
|
||||
#endif
|
||||
COGL_NOTE (DRAW,
|
||||
"~~~~~ slice (%d, %d)\n"
|
||||
"qx1: %f\t"
|
||||
"qy1: %f\n"
|
||||
"qx2: %f\t"
|
||||
"qy2: %f\n"
|
||||
"tx1: %f\t"
|
||||
"ty1: %f\n"
|
||||
"tx2: %f\t"
|
||||
"ty2: %f\n",
|
||||
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 */
|
||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
|
||||
|
@ -38,6 +38,7 @@
|
||||
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||
#endif
|
||||
|
||||
#include "cogl-debug.h"
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-context.h"
|
||||
@ -46,7 +47,7 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||
#include "cogl-gles2-wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef COGL_DEBUG
|
||||
#ifdef COGL_GL_DEBUG
|
||||
/* GL error to string conversion */
|
||||
static const struct {
|
||||
GLuint error_code;
|
||||
@ -78,18 +79,16 @@ cogl_gl_error_to_string (GLenum error_code)
|
||||
return gl_errors[i].error_string;
|
||||
}
|
||||
|
||||
return "Unknown error";
|
||||
return "Unknown GL error";
|
||||
}
|
||||
#endif /* COGL_DEBUG */
|
||||
#endif /* COGL_GL_DEBUG */
|
||||
|
||||
void
|
||||
cogl_clear (const CoglColor *color, gulong buffers)
|
||||
{
|
||||
GLbitfield gl_buffers = 0;
|
||||
|
||||
#if COGL_DEBUG
|
||||
fprintf(stderr, "\n ============== Paint Start ================ \n");
|
||||
#endif
|
||||
COGL_NOTE (DRAW, "Clear begin");
|
||||
|
||||
cogl_clip_ensure ();
|
||||
|
||||
@ -101,20 +100,29 @@ cogl_clear (const CoglColor *color, gulong buffers)
|
||||
0.0) );
|
||||
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
|
||||
if (buffers & COGL_BUFFER_BIT_DEPTH)
|
||||
gl_buffers |= GL_DEPTH_BUFFER_BIT;
|
||||
|
||||
if (buffers & COGL_BUFFER_BIT_STENCIL)
|
||||
gl_buffers |= GL_STENCIL_BUFFER_BIT;
|
||||
|
||||
if (!gl_buffers)
|
||||
{
|
||||
static gboolean shown = FALSE;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
glClear (gl_buffers);
|
||||
|
||||
COGL_NOTE (DRAW, "Clear end");
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
@ -563,24 +571,31 @@ cogl_get_viewport (float v[4])
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (red)
|
||||
{
|
||||
GE( glGetIntegerv(GL_RED_BITS, &value) );
|
||||
*red = value;
|
||||
}
|
||||
|
||||
if (green)
|
||||
{
|
||||
GE( glGetIntegerv(GL_GREEN_BITS, &value) );
|
||||
*green = value;
|
||||
}
|
||||
|
||||
if (blue)
|
||||
{
|
||||
GE( glGetIntegerv(GL_BLUE_BITS, &value) );
|
||||
*blue = value;
|
||||
}
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
GE( glGetIntegerv(GL_ALPHA_BITS, &value ) );
|
||||
|
@ -44,17 +44,6 @@
|
||||
#include <stdlib.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
|
||||
|
||||
#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);
|
||||
|
||||
#if COGL_DEBUG
|
||||
printf ("CREATE SLICE (%d,%d)\n", x,y);
|
||||
printf ("size: (%d x %d)\n",
|
||||
COGL_NOTE (TEXTURE, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
|
||||
x, y,
|
||||
x_span->size - x_span->waste,
|
||||
y_span->size - y_span->waste);
|
||||
#endif
|
||||
|
||||
/* Setup texture parameters */
|
||||
GE( glBindTexture (tex->gl_target,
|
||||
gl_handles[y * n_x_slices + x]) );
|
||||
|
@ -40,17 +40,6 @@
|
||||
#include <stdlib.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);
|
||||
|
||||
static void _cogl_texture_free (CoglTexture *tex);
|
||||
|
Loading…
Reference in New Issue
Block a user