From faf43b6e20e2e8c1b062c57ef76e2fee7c5f4dae Mon Sep 17 00:00:00 2001 From: Nicholas Niro Date: Mon, 6 Aug 2007 12:59:20 -0400 Subject: [PATCH] Disabled the debugging functions temporarily. Implemented optimization for bitmap loading. --- ChangeLog | 40 ++++++++++++++++++++++++++++++++++++++++ include/neuro/debug.h | 15 +++++++++------ include/neuro/global.h | 2 +- src/debug.c | 19 ++++++++++++++++++- src/extlib/sdl.c | 4 ++-- src/extlib/x11.c | 2 +- src/misc/bitmap.c | 30 ++++++++++++++++++++---------- version.mk | 4 ++-- 8 files changed, 93 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6cd4ac..431456a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2007-08-06 Nicholas Niro + * include/neuro/debug.h : + Fixed the standard debugging macros, they had + a line feed error that did unexpected effects. + + * include/neuro/global.h : + This new file is strictly for internal use of + the library, it is not installed. It contains + the new project namespace name for the project + used for the debugging system. + + * src/debug.c (Neuro_DebugChannel): + Disabled the function temporarily and added initial + code before the real functionalities are + implemented. + + * src/extlib/sdl.c (Lib_GetPixel): + Commented the surface locking calls in order to + attempt to make getting pixels quicker to do. + NOTE: End coders are expected to themselves do the + necessary lockings before fidding with pixels. + + * src/extlib/x11.c (Lib_GetPutPixel): + The data is no longer tagged for refresh everytime + a new pixel is changed, end coders are expected + to lock and unlock to refresh the surfaces + accordingly. + + * src/misc/bitmap.c : + Implemented a new dynamic loading bytes fragmentor + that loads 30% of the full bitmap size at every cycles + instead of an old fixed 1024 bytes like before. + This effectively is supposed to optimize loading speed + for bigger images. + + * src/misc/bitmap.c (processGradual_BMP): + Surface locking were previously done at every cycles + but now, to optimize dynamic loading, locking and + unlocking only happen one time. + 2007-07-14 Nicholas Niro * src/extlib/x11.c : Removed dependency on X11/xpm.h so I had to diff --git a/include/neuro/debug.h b/include/neuro/debug.h index ffb5ba1..be4b26e 100644 --- a/include/neuro/debug.h +++ b/include/neuro/debug.h @@ -76,14 +76,17 @@ you need to set a string to NEURO_MODULE_CHANNEL("")\ to make the process work. example : NEURO_MODULE_CHANNEL("graphics")" #endif*/ /* NOT NEURO_CURRENT_CHANNEL */ -#define NEURO_ERROR(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, NEURO_CURRENT_CHANNEL, "Error", \ - __FILE__, __FUNCTION__, __LINE__, 1, x, y) +#define NEURO_ERROR(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, \ + NEURO_CURRENT_CHANNEL, \ + "Error", __FILE__, __FUNCTION__, __LINE__, 1, x, y) -#define NEURO_WARN(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, NEURO_CURRENT_CHANNEL, "Warn", \ - __FILE__, __FUNCTION__, __LINE__, 1, x, y) +#define NEURO_WARN(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, \ + NEURO_CURRENT_CHANNEL, \ + "Warn", __FILE__, __FUNCTION__, __LINE__, 1, x, y) -#define NEURO_TRACE(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, NEURO_CURRENT_CHANNEL, "Trace", \ - __FILE__, __FUNCTION__, __LINE__, 1, x, y) +#define NEURO_TRACE(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, \ + NEURO_CURRENT_CHANNEL, \ + "Trace", __FILE__, __FUNCTION__, __LINE__, 1, x, y) #define NEURO_PROJECT_NAME(x) char *NEURO_PROJECT_NAMESPACE=x diff --git a/include/neuro/global.h b/include/neuro/global.h index 78b5172..535c109 100644 --- a/include/neuro/global.h +++ b/include/neuro/global.h @@ -8,6 +8,6 @@ #include "config.h" -#define NEURO_PROJECT_NAMESPACE PACKAGE +#define NEURO_PROJECT_NAMESPACE "libneuro" #endif /* NOT __GLOBAL_H */ diff --git a/src/debug.c b/src/debug.c index aa5b4ef..09a7070 100644 --- a/src/debug.c +++ b/src/debug.c @@ -233,6 +233,23 @@ Neuro_DebugChannel(const char *project_name, const char *channel, char *type, ch DEBUG_CHANNEL *buf; u32 total = 0; + return; + + if (!project_name || !channel || !type || !filename || !funcName || !control) + { + char *output = NULL; + + if (funcName) + output = funcName; + + if (output) + NEURO_ERROR("Invalid argument used -- caller name \"%s\"", output); + else + NEURO_ERROR("Invalid argument used -- unknown caller", NULL); + + return; + } + /* we allow the call of this function even * if the init wasn't priorly called. */ @@ -259,7 +276,7 @@ Neuro_DebugChannel(const char *project_name, const char *channel, char *type, ch if (!strcmp(channel, buf->channel) || !strcmp(type, buf->channel)) { if (output_detailed == 1) - fprintf(stderr, "%s : \"%s\" (%s) %s:%s:%d -- ", type, project_name, channel, filename, funcName, lineNum); + fprintf(stderr, "%s : (%s:%s) %s:%s:%d -- ", type, project_name, channel, filename, funcName, lineNum); va_start(args, control); vfprintf(stderr, control, args); diff --git a/src/extlib/sdl.c b/src/extlib/sdl.c index a45f1aa..f4ef74a 100644 --- a/src/extlib/sdl.c +++ b/src/extlib/sdl.c @@ -809,7 +809,7 @@ Lib_GetPixel(v_object *srf, int x, int y) u32 err; - Lib_LockVObject(srf); + /* Lib_LockVObject(srf); */ Lib_GetVObjectData(srf, NULL, NULL, NULL, &pitch, &pixels, NULL, &bpp, NULL, NULL, NULL, NULL); @@ -856,7 +856,7 @@ Lib_GetPixel(v_object *srf, int x, int y) } } - Lib_UnlockVObject(srf); + /* Lib_UnlockVObject(srf); */ return err; diff --git a/src/extlib/x11.c b/src/extlib/x11.c index 4951a9e..85ea191 100644 --- a/src/extlib/x11.c +++ b/src/extlib/x11.c @@ -619,7 +619,7 @@ Lib_PutPixel(v_object *srf, int x, int y, u32 pixel) XSetForeground(dmain->display, dmain->GC, pixel); XDrawPoint(dmain->display, *tmp->cwin, dmain->GC, x, y); - tmp->pixel_data_changed = 1; + /* tmp->pixel_data_changed = 1; */ } u32 diff --git a/src/misc/bitmap.c b/src/misc/bitmap.c index 02a6fbe..7aec534 100644 --- a/src/misc/bitmap.c +++ b/src/misc/bitmap.c @@ -124,6 +124,7 @@ struct BMP_CTX u32 increm; u8 DATA; v_object *output; /* the image into which we will load the bitmap */ + u32 cut_size; /* amount of bytes to load per cycles */ }; @@ -782,6 +783,15 @@ processGradual_BMP(BMP_CTX *ctx, u32 loops) fseek(ctx->f_bitmap, ctx->bmap->header.offset, SEEK_SET); #endif /* NOT USE_ZLIB */ + NEURO_WARN("Bitmap size %d", ctx->psize); + Debug_Val(0, "Bitmap size %d\n", ctx->psize); + + ctx->cut_size = ctx->psize / 30; + + loops = ctx->cut_size; + + /* we lock the surface */ + Lib_LockVObject(ctx->output); } @@ -790,14 +800,13 @@ processGradual_BMP(BMP_CTX *ctx, u32 loops) * bitmap file. */ { i32 initial = ctx->i; - - Lib_LockVObject(ctx->output); - - /* while (ctx->i < ctx->psize) */ while (ctx->i < (initial + loops)) - { + { + if (ctx->i > ctx->psize) + break; + if (ctx->tmp > 0) { /* skip bytes that are inside the bitmap for @@ -845,16 +854,14 @@ processGradual_BMP(BMP_CTX *ctx, u32 loops) /* we push the 8 bits along with various other * variables to the bits processor. */ + process_bitmap(ctx->bmap, ctx->output, ctx->palette, &ctx->DATA, ctx->bmap_colors, &ctx->x, &ctx->y, &ctx->aux_var, &ctx->aux_buf); + ctx->i++; } - Lib_UnlockVObject(ctx->output); - - - if (ctx->i >= ctx->psize) { /* this bitmap finished being loaded, we free everything */ @@ -938,7 +945,7 @@ readBitmapFile(const char *bitmap) i8 Bitmap_Poll(BMP_CTX *ctx) { - return processGradual_BMP(ctx, 1024); + return processGradual_BMP(ctx, ctx->cut_size); } /*-------------------- Constructor Destructor ----------------------*/ @@ -975,6 +982,9 @@ Bitmap_DestroyCTX(BMP_CTX *ctx) if (ctx == NULL) return NULL; + /* loading the image is done so we unlock */ + Lib_UnlockVObject(ctx->output); + output = ctx->output; free(ctx); diff --git a/version.mk b/version.mk index 5713bca..21a12a9 100644 --- a/version.mk +++ b/version.mk @@ -1,6 +1,6 @@ MAJOR=0 MINOR=49 -MICRO=31 +MICRO=32 INTERFACE=3 -REVISION=5 +REVISION=6 BINARY=3 -- 2.11.4.GIT