This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 8ac4aa41dac9e27830da30fc1b2804f4404edaa5 (commit) via 8bfe15827e2fc8dcdee58cf3d435a78e8b9955b8 (commit) via 5614a72ad692285e00909d83a971eab6e0aa6199 (commit) via fad224dbbcdf6744e57cbf0ca235f226e37f794a (commit) from 402373dac8551c34bf48ceeba4aace19cee0eea9 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/8ac4aa41dac9e27830da30fc1b2804f4404ed...
commit 8ac4aa41dac9e27830da30fc1b2804f4404edaa5 Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 3 19:06:38 2013 +0100
core: context: Fix GP_PIXEL_ADDR() macro.
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index 0977a27..83d3c10 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -78,9 +78,9 @@ typedef struct GP_Context { * Rows and columns are specified in the image's orientation * (i.e. they might not be XY if the image is rotated). */ -#define GP_PIXEL_ADDR(context, x, y) (((context)->pixels - + y * (context)->bytes_per_row - + (x * (context)->bpp) / 8)) +#define GP_PIXEL_ADDR(context, x, y) ((context)->pixels + + (y) * (context)->bytes_per_row + + ((x) * (context)->bpp) / 8)
#define GP_CALC_ROW_SIZE(pixel_type, width) ((GP_PixelSize(pixel_type) * width) / 8 + http://repo.or.cz/w/gfxprim.git/commit/8bfe15827e2fc8dcdee58cf3d435a78e8b995...
commit 8bfe15827e2fc8dcdee58cf3d435a78e8b9955b8 Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 3 17:45:03 2013 +0100
doc: Update debug layer docs.
diff --git a/doc/debug.txt b/doc/debug.txt index 3f1cc69..cdc3d4b 100644 --- a/doc/debug.txt +++ b/doc/debug.txt @@ -1,8 +1,23 @@ Debug Messages --------------
-The GFXprim library includes a debug messages infrastructure in order to ease -debugging. +The GFXprim library includes a debug message infrastructure in order to ease +the debugging. + +Many places of the library uses debug messages to report warnings, bugs, or +generally important events (i.e. context has been allocated, filter function +has been called). + +Debug messages are printed into the stderr and could be redirected to custom +handler. + +The verbosity of the messages could be changed by the debug level. The debug +level is an unsigned integer (by default set to '0') and only messages that have +debug level lower or equal to debug level are printed. + +There are few special debug message types with negative debug level (that +means that they are always printed), and as so these are used on various error +conditions, see bellow for more information.
[source,c] ------------------------------------------------------------------------------- @@ -15,17 +30,17 @@ void GP_SetDebugLevel(unsigned int level); unsigned int GP_GetDebugLevel(void); -------------------------------------------------------------------------------
-Sets or gets library debug level. The default level is 0 at which only BUG, -WARNING, TODO and messages with debug level 0 are shown. +Sets or gets library debug level. The default level is '0' at which only +'FATAL', 'BUG', 'WARNING', 'TODO' and messages with debug level '0' are shown.
Increasing this number would cause the library to be more verbose in debugging messages.
-Setting debug level to 1 would expose debug messages when object was created +Setting debug level to '1' would expose debug messages when object was created or destroyed or when particular algorithm has been started.
-Setting debug level to value higher than 1 would expose even more verbose -messages the current maximum used by debug messages is 4. +Setting debug level to value higher than '1' would expose even more verbose +messages the current maximum used by debug messages is '4'.
The debug level may also be set by setting the 'GP_DEBUG' environment variable. In such case the debug level is set accordingly to its value when @@ -45,10 +60,47 @@ GP_WARN(...)
GP_BUG(...)
+GP_FATAL(...) + void GP_DebugPrint(int level, const char *file, const char *function, int line, const char *fmt, ...); -------------------------------------------------------------------------------
-Printf-like macros used to create debug messages. All of them calls the -'GP_DebugPrint()' function with correct parameters. +Printf-like macros used to print debug messages. All of them calls the +'GP_DebugPrint()' function with slightly parameters. + +[source,c] +------------------------------------------------------------------------------- +enum GP_DebugType { + GP_DEBUG_TODO = -1, + GP_DEBUG_WARN = -2, + GP_DEBUG_BUG = -3, + GP_DEBUG_FATAL = -4, +}; + +/* + * Custom debug message handler structure. + */ +struct GP_DebugMsg { + int level; + const char *file; + const char *fn; + unsigned int line; + const char *msg; +}; + +/* + * Sets custom debug message handler. + * + * If NULL is passed, custom handler is disabled and debug messages are printed + * into the stderr. + */ +void GP_SetDebugHandler(void (*handler)(const struct GP_DebugMsg *msg)); + +------------------------------------------------------------------------------- + +By default debug messages are printed into the 'stderr' you can redirect them +to your debug handler by this function.
+NOTE: For more information see debug message handler + link:example_debug_handler.html[example]. diff --git a/doc/example_debug_handler.txt b/doc/example_debug_handler.txt new file mode 100644 index 0000000..a859f68 --- /dev/null +++ b/doc/example_debug_handler.txt @@ -0,0 +1,7 @@ +Debug Message Handler Example +----------------------------- + +[source,c] +------------------------------------------------------------------ +include::../demos/c_simple/debug_handler.c[] +------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/5614a72ad692285e00909d83a971eab6e0aa6...
commit 5614a72ad692285e00909d83a971eab6e0aa6199 Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 3 17:26:59 2013 +0100
libs: backends: GP_X11: Small cleanup.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index e3ee8eb..59b28ae 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -97,14 +97,7 @@ static void x11_flip(GP_Backend *self)
XLockDisplay(win->dpy);
-#ifdef HAVE_X_SHM - if (win->shm_flag) - XShmPutImage(win->dpy, win->win, DefaultGC(win->dpy, win->scr), - win->img, 0, 0, 0, 0, w, h, False); - else -#endif /* HAVE_X_SHM */ - XPutImage(win->dpy, win->win, DefaultGC(win->dpy, win->scr), - win->img, 0, 0, 0, 0, w, h); + putimage(win, 0, 0, w - 1, h - 1);
XFlush(win->dpy);
@@ -113,9 +106,9 @@ static void x11_flip(GP_Backend *self)
static void x11_ev(XEvent *ev) { - /* Lookup for window */ static struct x11_win *win = NULL;
+ /* Lookup for window */ if (win == NULL || win->win != ev->xany.window) { win = win_list_lookup(ev->xany.window);
@@ -566,12 +559,12 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, goto err1; }
- /* Init the event queue, once we know the window size */ - GP_EventQueueInit(&backend->event_queue, wreq.w, wreq.h, 0); - if (flags & GP_X11_FULLSCREEN) x11_win_fullscreen(win, 1); + /* Init the event queue, once we know the window size */ + GP_EventQueueInit(&backend->event_queue, wreq.w, wreq.h, 0); + backend->context = NULL;
if ((flags & GP_X11_DISABLE_SHM) || create_shm_ximage(backend, w, h))
http://repo.or.cz/w/gfxprim.git/commit/fad224dbbcdf6744e57cbf0ca235f226e37f7...
commit fad224dbbcdf6744e57cbf0ca235f226e37f794a Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 3 17:16:59 2013 +0100
libs: core: debug: API for custom message handler.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index bca6fa2..3e741cc 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -18,7 +18,8 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch virtual_backend_example meta_data meta_data_dump tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input_example fileview linetest randomshapetest fonttest- loaders_register blittest textaligntest abort sin_AA x11_windows + loaders_register blittest textaligntest abort sin_AA x11_windows+ debug_handler
ifeq ($(HAVE_LIBSDL),yes) APPS+=SDL_glue diff --git a/libs/core/GP_Debug.c b/demos/c_simple/debug_handler.c similarity index 55% copy from libs/core/GP_Debug.c copy to demos/c_simple/debug_handler.c index 75a54f3..9623645 100644 --- a/libs/core/GP_Debug.c +++ b/demos/c_simple/debug_handler.c @@ -16,76 +16,59 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
-#include <stdarg.h> +/* + + Example on custom debug message handler.
-#include "GP_Debug.h" + */
-static unsigned int debug_level = GP_DEFAULT_DEBUG_LEVEL; -static int env_used = 0; +#include <GP.h>
-void GP_SetDebugLevel(unsigned int level) +static char level_to_c(int level) { - debug_level = level; + switch (level) { + case GP_DEBUG_TODO: + return 'T'; + case GP_DEBUG_WARN: + return 'W'; + case GP_DEBUG_BUG: + return 'B'; + case GP_DEBUG_FATAL: + return 'F'; + case 0 ... 9: + return '0' + level; + default: + return 'U'; + } }
-unsigned int GP_GetDebugLevel(void) +void debug_handler(const struct GP_DebugMsg *msg) { - return debug_level; + printf("%c: %s->%s():%u: %sn", level_to_c(msg->level), msg->file, + msg->fn, msg->line, msg->msg); }
-void GP_DebugPrint(int level, const char *file, const char *function, int line, - const char *fmt, ...) +int main(void) { - int i; + /* Set custom debug handler */ + GP_SetDebugHandler(debug_handler); - if (!env_used) { - char *level = getenv("GP_DEBUG"); - - env_used = 1; - - if (level != NULL) { - int new_level = atoi(level); - - if (new_level >= 0) { - debug_level = new_level; + /* Print some debug messages */ + GP_WARN("This is a warning"); + GP_FATAL("This is a fatal condition");
- GP_DEBUG(1, "Using debug level GP_DEBUG=%i " - "from enviroment variable", - debug_level); - } - } - } - - if (level > (int)debug_level) - return; + /* Turn on verbose debug and call some library functions */ + GP_SetDebugLevel(10);
- for (i = 1; i < level; i++) - fputc(' ', stderr); + GP_Context *ctx = GP_ContextAlloc(1000, 1000, 1);
- switch (level) { - case -3: - fprintf(stderr, "*** BUG: %s:%s():%u: ", file, function, line); - break; - case -2: - fprintf(stderr, "*** WARNING: %s:%s():%u: ", file, function, line); - break; - case -1: - fprintf(stderr, "*** TODO: %s:%s():%u: ", file, function, line); - break; - default: - fprintf(stderr, "%u: %s:%s():%u: ", - level, file, function, line); - break; - } + GP_FilterGaussianBlur(ctx, ctx, 10, 10, NULL); + + GP_ContextFree(ctx);
- va_list va; - va_start(va, fmt); - vfprintf(stderr, fmt, va); - va_end(va); - - fputc('n', stderr); + return 0; } diff --git a/include/core/GP_Debug.h b/include/core/GP_Debug.h index a09ba69..4008bcd 100644 --- a/include/core/GP_Debug.h +++ b/include/core/GP_Debug.h @@ -16,37 +16,63 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/* - - Debug messages and debug level. Debug level is an unsigned integer.
- Messages with debug level 0 are always printed (you should generally avoid - using them unless you wan't user to see the message.) + Debug message layer.
- Debug level 1 should be used on object initalization and generally rare and - important events. + Many places of the library uses debug messages to report warnings, bugs, or + generally important events (i.e. context has been allocated, filter function + has been called).
- Debug level > 1 is intended for more verbose reporting, like inner cycles - or loop debugging. + Debug messages are printed into the stderr and could be redirected to custom + handler.
- Debug levels with negative level are special. Debug level -1 means TODO, - level -2 says WARNING while -2 means BUG (i.e. library get into unconsistent - state). + The verbosity of the messages could be changed by the debug level. The debug + level is an unsigned integer (by default set to '0') and only messages that have + debug level lower or equal to debug level are printed. + + There are few special debug message types with negative debug level (that + means that they are always printed), and as so these are used on various error + conditions, see bellow for more information.
*/
-#ifndef GP_DEBUG_H -#define GP_DEBUG_H +#ifndef CORE_GP_DEBUG_H +#define CORE_GP_DEBUG_H
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h>
+/* + * Messages with debug level 0 are always printed (you should generally avoid + * using them unless you wan't user to see the message.) + * + * Debug level 1 should be used on object initalization and generally rare and + * important events. + * + * Debug level > 1 is intended for more verbose reporting, like inner cycles + * or loop debugging. + * + * Debug levels with negative level are special. + * + * -1 TODO - not implemented feature + * -2 WARNING - generally error that can be recovered + * -3 BUG - library gets into unconsistent state + * -4 FATAL - fatal condition, not compiled with XYZ support etc. + */ +enum GP_DebugType { + GP_DEBUG_TODO = -1, + GP_DEBUG_WARN = -2, + GP_DEBUG_BUG = -3, + GP_DEBUG_FATAL = -4, +}; + #define GP_DEFAULT_DEBUG_LEVEL 0
#define GP_DEBUG(level, ...) @@ -61,11 +87,40 @@ #define GP_BUG(...) GP_DebugPrint(-3, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+#define GP_FATAL(...) + GP_DebugPrint(-4, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) + +void GP_DebugPrint(int level, const char *file, const char *function, int line, + const char *fmt, ...) __attribute__ ((format (printf, 5, 6))); + +/* + * Sets debug level. + */ void GP_SetDebugLevel(unsigned int level);
+/* + * Returns current debug level. + */ unsigned int GP_GetDebugLevel(void);
-void GP_DebugPrint(int level, const char *file, const char *function, int line, - const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
-#endif /* GP_DEBUG_H */ +/* + * Custom debug message handler structure. + */ +struct GP_DebugMsg { + int level; + const char *file; + const char *fn; + unsigned int line; + const char *msg; +}; + +/* + * Sets custom debug message handler. + * + * If NULL is passed, custom handler is disabled and debug messages are printed + * into the stderr. + */ +void GP_SetDebugHandler(void (*handler)(const struct GP_DebugMsg *msg)); + +#endif /* CORE_GP_DEBUG_H */ diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index 6cb08a5..ff65884 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -47,6 +47,9 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) uint32_t bpr = get_bpr(bpp, w); void *pixels;
+ GP_DEBUG(1, "Allocating context %u x %u - %s", + w, h, GP_PixelTypeName(type)); + pixels = malloc(bpr * h); context = malloc(sizeof(GP_Context));
@@ -58,10 +61,10 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) return NULL; }
- context->pixels = pixels; - context->bpp = bpp; - context->bytes_per_row = bpr; - context->offset = 0; + context->pixels = pixels; + context->bpp = bpp; + context->bytes_per_row = bpr; + context->offset = 0;
context->w = w; context->h = h; diff --git a/libs/core/GP_Debug.c b/libs/core/GP_Debug.c index 75a54f3..db1ed26 100644 --- a/libs/core/GP_Debug.c +++ b/libs/core/GP_Debug.c @@ -16,17 +16,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
#include <stdarg.h>
-#include "GP_Debug.h" +#include "core/GP_Debug.h"
static unsigned int debug_level = GP_DEFAULT_DEBUG_LEVEL; + static int env_used = 0;
+static void (*debug_handler)(const struct GP_DebugMsg *msg) = NULL; + void GP_SetDebugLevel(unsigned int level) { debug_level = level; @@ -37,6 +40,11 @@ unsigned int GP_GetDebugLevel(void) return debug_level; }
+void GP_SetDebugHandler(void (*handler)(const struct GP_DebugMsg *msg)) +{ + debug_handler = handler; +} + void GP_DebugPrint(int level, const char *file, const char *function, int line, const char *fmt, ...) { @@ -63,17 +71,42 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, if (level > (int)debug_level) return;
+ /* If handler is set, fill struct msg and call it */ + if (debug_handler) { + char buf[256]; + + va_list va; + va_start(va, fmt); + vsnprintf(buf, sizeof(buf), fmt, va); + va_end(va); + + struct GP_DebugMsg msg = { + .level = level, + .file = file, + .fn = function, + .line = line, + .msg = buf, + }; + + debug_handler(&msg); + + return; + } + for (i = 1; i < level; i++) fputc(' ', stderr);
switch (level) { - case -3: + case GP_DEBUG_FATAL: + fprintf(stderr, "*** FATAL: %s:%s():%u: ", file, function, line); + break; + case GP_DEBUG_BUG: fprintf(stderr, "*** BUG: %s:%s():%u: ", file, function, line); break; - case -2: + case GP_DEBUG_WARN: fprintf(stderr, "*** WARNING: %s:%s():%u: ", file, function, line); break; - case -1: + case GP_DEBUG_TODO: fprintf(stderr, "*** TODO: %s:%s():%u: ", file, function, line); break; default:
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/Makefile | 3 +- .../c_simple/debug_handler.c | 66 ++++++++------ doc/debug.txt | 70 +++++++++++++-- ...ress_callback.txt => example_debug_handler.txt} | 6 +- include/core/GP_Context.h | 8 +- include/core/GP_Debug.h | 89 ++++++++++++++++---- libs/backends/GP_X11.c | 17 +--- libs/core/GP_Context.c | 11 ++- libs/core/GP_Debug.c | 43 ++++++++- 9 files changed, 230 insertions(+), 83 deletions(-) copy tests/drivers/linux_input.c => demos/c_simple/debug_handler.c (66%) copy doc/{example_loaders_progress_callback.txt => example_debug_handler.txt} (58%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.