gegl r2206 - in trunk: . gegl



Author: ok
Date: Sun Apr 20 22:11:17 2008
New Revision: 2206
URL: http://svn.gnome.org/viewvc/gegl?rev=2206&view=rev

Log:
* autogen.sh: pass --enable-debug when autogen is used.
* configure.ac: added check for --enable-debug added sse and mmx
* gegl/gegl-debug.h: debug infrastructure like the one in clutter.
* gegl/gegl-init.h: added gegl_get_debug_enabled().
* gegl/gegl-init.c: (gegl_post_parse_hook), (gegl_arg_debug_cb),
(gegl_arg_no_debug_cb), (gegl_get_debug_enabled): added debug
infrastructure.
* gegl/gegl-utils.[ch]: removed old unused log infrastructure.


Added:
   trunk/gegl/gegl-debug.h
Modified:
   trunk/ChangeLog
   trunk/autogen.sh
   trunk/configure.ac
   trunk/gegl/gegl-init.c
   trunk/gegl/gegl-init.h
   trunk/gegl/gegl-utils.c
   trunk/gegl/gegl-utils.h

Modified: trunk/autogen.sh
==============================================================================
--- trunk/autogen.sh	(original)
+++ trunk/autogen.sh	Sun Apr 20 22:11:17 2008
@@ -323,7 +323,7 @@
 echo "Running ./configure..."
 echo
 
-$srcdir/configure --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@"
+$srcdir/configure --enable-debug --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@"
 RC=$?
 if test $RC -ne 0; then
   echo

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sun Apr 20 22:11:17 2008
@@ -153,9 +153,9 @@
 
 AC_MSG_CHECKING([whether to turn on debugging])
 AC_ARG_ENABLE(debug,
-              [  --enable-debug          turn on debugging (default=no)],
+              [  --enable-debug          turn on  debugging (default=no)],
               if eval "test x$enable_debug = xyes"; then
-                DEBUGFLAG="-g"
+                DEBUGFLAG="-g -DGEGL_ENABLE_DEBUG"
               fi)
 
 if test -n "$DEBUGFLAG"; then
@@ -291,6 +291,7 @@
 dnl ===========================================================================
 
 
+
 #################
 # Check for Win32
 #################
@@ -424,6 +425,7 @@
   AC_SUBST(SSE_EXTRA_CFLAGS)
 fi
 
+CFLAGS="$CFLAGS $SSE_EXTRA_CFLAGS"
 
 
 ###############################
@@ -842,6 +844,7 @@
   Build workshop: $enable_workshop
   Build website:  $have_asciidoc
   Multiprocessor: $enable_mp
+  SIMD:           sse:$enable_sse mmx:$enable_mmx
 
 Optional dependencies:
   GTK+:           $have_gtk

Added: trunk/gegl/gegl-debug.h
==============================================================================
--- (empty file)
+++ trunk/gegl/gegl-debug.h	Sun Apr 20 22:11:17 2008
@@ -0,0 +1,99 @@
+#ifndef __GEGL_DEBUG_H__
+#define __GEGL_DEBUG_H__
+
+#include <glib.h>
+#include "gegl-init.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+  GEGL_DEBUG_PROCESS         = 1 << 0,
+  GEGL_DEBUG_BUFFER_LOAD     = 1 << 1,
+  GEGL_DEBUG_BUFFER_SAVE     = 1 << 2,
+  GEGL_DEBUG_TILE_BACKEND    = 1 << 3,
+  GEGL_DEBUG_PROCESSOR       = 1 << 4,
+} GeglDebugFlag;
+
+/* only compiled in from gegl-init.c but kept here to
+ * make it easier to update and keep in sync with the
+ * flags
+ */
+#ifdef __GEGL_INIT_C
+static const GDebugKey gegl_debug_keys[] = {
+  { "process",       GEGL_DEBUG_PROCESS},
+  { "buffer-load",   GEGL_DEBUG_BUFFER_LOAD},
+  { "buffer-save",   GEGL_DEBUG_BUFFER_SAVE},
+  { "tile-backend",  GEGL_DEBUG_TILE_BACKEND},
+  { "processor",     GEGL_DEBUG_PROCESSOR},
+  { "all",           GEGL_DEBUG_PROCESS|
+                     GEGL_DEBUG_BUFFER_LOAD|
+                     GEGL_DEBUG_BUFFER_SAVE|
+                     GEGL_DEBUG_TILE_BACKEND|
+                     GEGL_DEBUG_PROCESSOR},
+};
+#endif /* GEGL_ENABLE_DEBUG */
+
+#ifdef GEGL_ENABLE_DEBUG
+
+#ifdef __GNUC_
+#define GEGL_NOTE(type,x,a...)               G_STMT_START {     \
+        if (gegl_debug_flags & GEGL_DEBUG_##type)               \
+          { g_message ("[" #type "] " G_STRLOC ": " x, ##a); }  \
+                                                } G_STMT_END
+
+#define GEGL_TIMESTAMP(type,x,a...)             G_STMT_START {  \
+        if (gegl_debug_flags & GEGL_DEBUG_##type)               \
+          { g_message ("[" #type "]" " %li:"  G_STRLOC ": "     \
+                       x, gegl_get_timestamp(), ##a); }         \
+                                                   } G_STMT_END
+#else
+/* Try the C99 version; unfortunately, this does not allow us to pass
+ * empty arguments to the macro, which means we have to
+ * do an intemediate printf.
+ */
+#define GEGL_NOTE(type,...)               G_STMT_START {        \
+        if (gegl_debug_flags & GEGL_DEBUG_##type)               \
+	{                                                       \
+	  gchar * _fmt = g_strdup_printf (__VA_ARGS__);         \
+          g_message ("[" #type "] " G_STRLOC ": %s",_fmt);      \
+          g_free (_fmt);                                        \
+	}                                                       \
+                                                } G_STMT_END
+
+#define GEGL_TIMESTAMP(type,...)             G_STMT_START {     \
+        if (gegl_debug_flags & GEGL_DEBUG_##type)               \
+	{                                                       \
+	  gchar * _fmt = g_strdup_printf (__VA_ARGS__);         \
+          g_message ("[" #type "]" " %li:"  G_STRLOC ": %s",    \
+                       gegl_get_timestamp(), _fmt);             \
+          g_free (_fmt);                                        \
+	}                                                       \
+                                                   } G_STMT_END
+#endif
+
+#define GEGL_MARK()      GEGL_NOTE(MISC, "== mark ==")
+#define GEGL_DBG(x) { a }
+
+#define GEGL_GLERR()                         G_STMT_START {     \
+        if (gegl_debug_flags & GEGL_DEBUG_GL)                   \
+          { GLenum _err = glGetError (); /* roundtrip */        \
+            if (_err != GL_NO_ERROR)                            \
+              g_warning (G_STRLOC ": GL Error %x", _err);       \
+          }                                     } G_STMT_END
+
+
+#else /* !GEGL_ENABLE_DEBUG */
+
+#define GEGL_NOTE(type,...)
+#define GEGL_MARK()
+#define GEGL_DBG(x)
+#define GEGL_GLERR()
+#define GEGL_TIMESTAMP(type,...)
+
+#endif /* GEGL_ENABLE_DEBUG */
+
+extern guint gegl_debug_flags;
+
+G_END_DECLS
+
+#endif /* __GEGL_DEBUG_H__  */

Modified: trunk/gegl/gegl-init.c
==============================================================================
--- trunk/gegl/gegl-init.c	(original)
+++ trunk/gegl/gegl-init.c	Sun Apr 20 22:11:17 2008
@@ -17,6 +17,7 @@
  */
 
 #include "config.h"
+#define __GEGL_INIT_C
 
 #include <babl/babl.h>
 
@@ -32,6 +33,13 @@
 #include <process.h>
 #endif
 
+#include <gegl-debug.h>
+
+
+guint gegl_debug_flags = 0; 
+
+
+
 #include "gegl-instrument.h"
 /*#include "gegl-types.h"*/
 #include "gegl-init.h"
@@ -236,6 +244,7 @@
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 }
 
+
 static gboolean
 gegl_post_parse_hook (GOptionContext *context,
                       GOptionGroup   *group,
@@ -252,6 +261,22 @@
   g_type_init ();
   gegl_instrument ("gegl", "gegl_init", 0);
 
+
+#ifdef GEGL_ENABLE_DEBUG
+  {
+    const char *env_string;
+    env_string = g_getenv ("GEGL_DEBUG");
+    if (env_string != NULL)
+      {
+        gegl_debug_flags =
+          g_parse_debug_string (env_string,
+                                gegl_debug_keys,
+                                G_N_ELEMENTS (gegl_debug_keys));
+        env_string = NULL;
+      }
+  }
+#endif /* GEGL_ENABLE_DEBUG */
+
   time = gegl_ticks ();
 
   if (g_getenv ("BABL_ERROR") == NULL)
@@ -321,6 +346,52 @@
   return TRUE;
 }
 
+
+
+#ifdef GEGL_ENABLE_DEBUG
+static gboolean
+gegl_arg_debug_cb (const char *key,
+                   const char *value,
+                   gpointer    user_data)
+{
+  gegl_debug_flags |=
+    g_parse_debug_string (value,
+                          gegl_debug_keys,
+                          G_N_ELEMENTS (gegl_debug_keys));
+  return TRUE;
+}
+
+static gboolean
+gegl_arg_no_debug_cb (const char *key,
+                      const char *value,
+                      gpointer    user_data)
+{
+  gegl_debug_flags &=
+    ~g_parse_debug_string (value,
+                           gegl_debug_keys,
+                           G_N_ELEMENTS (gegl_debug_keys));
+  return TRUE;
+}
+#endif
+
+/*
+ * gegl_get_debug_enabled:
+ *
+ * Check if gegl has debugging turned on.
+ *
+ * Return value: TRUE if debugging is turned on, FALSE otherwise.
+ */
+gboolean
+gegl_get_debug_enabled (void)
+{
+#ifdef GEGL_ENABLE_DEBUG
+  return gegl_debug_flags != 0;
+#else
+  return FALSE;
+#endif
+}
+
+
 static const gchar *makefile (void)
 {
   return
@@ -341,3 +412,5 @@
     "clean:\n"
     "	rm -f *$(SHREXT) $(OFILES)\n";
 }
+
+

Modified: trunk/gegl/gegl-init.h
==============================================================================
--- trunk/gegl/gegl-init.h	(original)
+++ trunk/gegl/gegl-init.h	Sun Apr 20 22:11:17 2008
@@ -22,10 +22,11 @@
 G_BEGIN_DECLS
 
 
-void           gegl_init             (gint    *argc,
-                                      gchar ***argv);
-GOptionGroup * gegl_get_option_group (void);
-void           gegl_exit             (void);
+void           gegl_init              (gint    *argc,
+                                       gchar ***argv);
+GOptionGroup * gegl_get_option_group  (void);
+void           gegl_exit              (void);
+gboolean       gegl_get_debug_enabled (void);
 
 
 G_END_DECLS

Modified: trunk/gegl/gegl-utils.c
==============================================================================
--- trunk/gegl/gegl-utils.c	(original)
+++ trunk/gegl/gegl-utils.c	Sun Apr 20 22:11:17 2008
@@ -176,99 +176,6 @@
     return FALSE;
 }
 
-#define GEGL_LOG_DOMAIN    "Gegl"
-
-void
-gegl_log_debug (const gchar *file,
-                gint         line,
-                const gchar *function,
-                const gchar *format,
-                ...)
-{
-  va_list args;
-
-  va_start (args, format);
-  gegl_logv (G_LOG_LEVEL_DEBUG, file, line, function, format, args);
-  va_end (args);
-}
-
-void
-gegl_log_info (const gchar *file,
-               gint         line,
-               const gchar *function,
-               const gchar *format,
-               ...)
-{
-  va_list args;
-
-  va_start (args, format);
-  gegl_logv (G_LOG_LEVEL_INFO, file, line, function, format, args);
-  va_end (args);
-}
-
-void
-gegl_log_message (const gchar *file,
-                  gint         line,
-                  const gchar *function,
-                  const gchar *format,
-                  ...)
-{
-  va_list args;
-
-  va_start (args, format);
-  gegl_logv (G_LOG_LEVEL_MESSAGE, file, line, function, format, args);
-  va_end (args);
-}
-
-void
-gegl_log_direct (const gchar *format,
-                 ...)
-{
-  va_list args;
-
-  va_start (args, format);
-  gegl_direct_logv (G_LOG_LEVEL_DEBUG, format, args);
-  va_end (args);
-}
-
-static void
-gegl_logv (GLogLevelFlags  level,
-           const gchar    *file,
-           gint            line,
-           const gchar    *function,
-           const gchar    *format,
-           va_list         args)
-{
-  if (g_getenv ("GEGL_LOG_ON"))
-    {
-      gchar *tabbed = NULL;
-
-      /* log the file and line */
-      g_log (GEGL_LOG_DOMAIN, level, "%s:  %s:%d:", function, file, line);
-
-      /* move the regular output over a bit. */
-      tabbed = g_strconcat ("   ", format, NULL);
-      g_logv (GEGL_LOG_DOMAIN, level, tabbed, args);
-      g_log (GEGL_LOG_DOMAIN, level, "        ");
-      g_free (tabbed);
-    }
-}
-
-static void
-gegl_direct_logv (GLogLevelFlags  level,
-                  const gchar    *format,
-                  va_list         args)
-{
-  if (g_getenv ("GEGL_LOG_ON"))
-    {
-      gchar *tabbed = NULL;
-      tabbed = g_strconcat ("   ", format, NULL);
-      g_logv (GEGL_LOG_DOMAIN, level, tabbed, args);
-      g_free (tabbed);
-    }
-}
-
-
 static GeglRectangle *
 gegl_rectangle_dup (const GeglRectangle *rectangle)
 {
@@ -293,46 +200,6 @@
 
 #define GEGL_ALIGN 16
 
-#if 0
-void *
-gegl_malloc (gsize size);
-
-/* utility call that makes sure allocations are 16 byte aligned.
- * making RGBA float buffers have aligned access for pixels.
- */ void * gegl_malloc (gsize size)
-{
-  gint   off;
-  gint   i;
-  gint   to_add;
-  gchar *mem = g_malloc (size + GEGL_ALIGN + 1);
-  void *ret;
-  *mem='G';
-  off = (((guint)mem) + 1) % GEGL_ALIGN;
-  to_add = GEGL_ALIGN-off;
-  ret = (void*)(mem + 1 + to_add);
-  for (i=1;i<1+to_add;i++)
-    mem[i]=' ';
-  return ret;
-}
-
-void
-gegl_free (void *buf);
-void
-gegl_free (void *buf)
-{
-  gchar *p = buf;
-  g_assert (buf);
-  p--;
-  while (*p!='G')
-    {
-      g_assert (*p==' ');
-    }
-   p--;
-  g_free (p);
-}
-#endif
-
-
 gpointer
 gegl_malloc (gsize size);
 
@@ -362,3 +229,4 @@
   g_assert (buf);
   g_free (*((gpointer*)buf -1));
 }
+

Modified: trunk/gegl/gegl-utils.h
==============================================================================
--- trunk/gegl/gegl-utils.h	(original)
+++ trunk/gegl/gegl-utils.h	Sun Apr 20 22:11:17 2008
@@ -44,24 +44,6 @@
 gboolean    gegl_rectangle_contains      (const GeglRectangle *r,
                                           const GeglRectangle *s);
 
-void        gegl_log_debug               (const gchar    *file,
-                                          gint            line,
-                                          const gchar    *function,
-                                          const gchar    *format,
-                                          ...) G_GNUC_PRINTF (4, 5);
-void        gegl_log_info                (const gchar    *file,
-                                          gint            line,
-                                          const gchar    *function,
-                                          const gchar    *format,
-                                          ...) G_GNUC_PRINTF (4, 5);
-void        gegl_log_message             (const gchar    *file,
-                                          gint            line,
-                                          const gchar    *function,
-                                          const gchar    *format,
-                                          ...) G_GNUC_PRINTF (4, 5);
-void        gegl_log_direct              (const gchar    *format,
-                                          ...) G_GNUC_PRINTF (1, 2);
-
 GType       gegl_rectangle_get_type      (void) G_GNUC_CONST;
 
 #ifndef __GEGL_H__
@@ -78,10 +60,10 @@
 gint        _gegl_float_epsilon_equal (float     v1,
                                        float     v2);
 
-void *
-gegl_aligned_malloc (gsize size);
-void
-gegl_aligned_free (void *buf);
+gpointer gegl_malloc                  (gsize size);
+void     gegl_free                    (gpointer buf);
+
+
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]