* modifed the script engine, instead of three passes i've nobbled it down to

one, this means the bump_mapped pr0n will now render a coupla degree's faster
 (gilbertt this is for you, and those pictures of pabs' mom)
* Update Imlib2.h and api.c to reflect changes

ps. on the road to the next gen script interpreter


SVN revision: 2677
This commit is contained in:
Chris Ross 2000-05-21 00:04:39 +00:00
parent b6409d23fa
commit c200ced976
5 changed files with 56 additions and 52 deletions

View File

@ -1 +0,0 @@
timestamp

View File

@ -269,7 +269,7 @@ void imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b);
void imlib_filter_constants(int a, int r, int g, int b);
void imlib_filter_divisors(int a, int r, int g, int b);
Imlib_Image imlib_apply_filter( char *script, ... );
void imlib_apply_filter( char *script, ... );
/* need to add polygon fill code */

View File

@ -2432,30 +2432,17 @@ imlib_filter_divisors(int a, int r, int g, int b)
__imlib_FilterDivisors((ImlibFilter *)ctxt_filter, a, r, g, b);
}
Imlib_Image imlib_apply_filter( char *script, ... )
void imlib_apply_filter( char *script, ... )
{
Imlib_Image im;
IFunction *func = NULL, *ptr;
va_list param_list;
pImlibExternalFilter filter;
Imlib_Image im;
__imlib_dynamic_filters_init();
CAST_IMAGE(im, ctxt_image);
CAST_IMAGE(im, ctxt_image);
va_start( param_list, script );
func = (IFunction *)__imlib_script_parse( script, param_list );
func = __imlib_script_parse( im, script, param_list );
va_end( param_list );
for( ptr = func->next; ptr != NULL; ptr = ptr->next )
{
filter = __imlib_get_dynamic_filter( ptr->name );
if( filter != NULL )
{
im = filter->exec_filter( ptr->name, im, ptr->params );
imlib_context_set_image( im );
}
}
__imlib_script_tidyup( func );
return im;
}

View File

@ -11,14 +11,16 @@
#include <ctype.h>
#include <errno.h>
#include <X11/Xlib.h>
#include "Imlib2.h"
#include "image.h"
#include "file.h"
#include "dynamic_filters.h"
#include "script.h"
#include "loaderpath.h"
/*
#define FDEBUG 1
*/
int __imlib_find_string( char *haystack, char *needle )
{
if( strstr( haystack, needle ) != NULL )
@ -26,7 +28,7 @@ int __imlib_find_string( char *haystack, char *needle )
return 0;
}
char *stripwhitespace( char *str )
char *__imlib_stripwhitespace( char *str )
{
int i, strt = 0, in_quote = 0;
char *tmpstr = calloc( strlen(str)+1, sizeof(char) );
@ -82,7 +84,9 @@ pIFunctionParam __imlib_parse_param( char *param )
ptr->key = strdup(param);
ptr->data = strdup( "" );
ptr->type = VAR_CHAR;
#ifdef FDEBUG
printf( "DEBUG: -> s_param [%s]=\"%s\"\n", ptr->key, (char *)ptr->data );
#endif
ptr->next = NULL;
}
return ptr;
@ -99,7 +103,7 @@ pIFunction __imlib_parse_function( char *func )
if( func != NULL )
{
func = stripwhitespace( func );
func = __imlib_stripwhitespace( func );
ptrfunc->name = __imlib_copystr( func, 0, __imlib_find_string( func, "(" ) - 1 );
#ifdef FDEBUG
printf( "DEBUG: Function name: \"%s\"\n", ptrfunc->name );
@ -138,12 +142,13 @@ pIFunction __imlib_parse_function( char *func )
return ptrfunc;
}
pIFunction __imlib_script_parse( char *script, va_list param_list )
pIFunction __imlib_script_parse( Imlib_Image im, char *script, va_list param_list )
{
int i = 0, in_quote = 0, start = 0, hit_null = 0;
IFunction *ptr = __imlib_parse_function( NULL ), *tmp_fptr = NULL;
IFunction *rptr = ptr;
IFunctionParam *tmp_pptr;
pImlibExternalFilter filter;
void *tmpptr;
#ifdef FDEBUG
@ -161,39 +166,51 @@ pIFunction __imlib_script_parse( char *script, va_list param_list )
{
ptr->next = __imlib_parse_function( __imlib_copystr( script, start, i-1 ) );
ptr = ptr->next;
start = i+1;
}
}
/* righty now we need to traverse the whole of the function tree and see if we have hit
* any [], if we have replace it with the next var off the list update the pointer, luverly
* jubly */
for( tmp_fptr = rptr->next; tmp_fptr != NULL; tmp_fptr = tmp_fptr->next )
{
for( tmp_pptr = tmp_fptr->params; tmp_pptr != NULL; tmp_pptr = tmp_pptr->next )
{
if( strcmp( (char *)(tmp_pptr->data), "[]" ) == 0 )
/* righty now we need to traverse the whole of the function tree and see if we have hit
* any [], if we have replace it with the next var off the list update the pointer, luverly
* jubly */
for( tmp_pptr = ptr->params; tmp_pptr != NULL; tmp_pptr = tmp_pptr->next )
{
if( !hit_null )
tmpptr = va_arg( param_list, void *);
else
tmpptr = NULL;
if( tmpptr == NULL )
if( strcmp( (char *)(tmp_pptr->data), "[]" ) == 0 )
{
if( !hit_null )
tmpptr = va_arg( param_list, void *);
else
tmpptr = NULL;
if( tmpptr == NULL )
{
#ifdef FDEBUG
printf( "DEBUG: WARNING: We have hit a null. (dyn_filter.c)\n" );
printf( "DEBUG: WARNING: We have hit a null. (dyn_filter.c)\n" );
#endif
hit_null = 1;
}
#ifdef FDEBUG
printf( "Setting %s::%s to a pointer.\n", ptr->name, tmp_pptr->key );
#endif
tmp_pptr->type = VAR_PTR;
tmp_pptr->data = ( tmpptr != NULL ? tmpptr : NULL );
#ifdef FDEBUG
printf( "%p\n", tmp_pptr->data );
#endif
hit_null = 1;
}
#ifdef FDEBUG
printf( "Setting %s::%s to a pointer.\n", tmp_fptr->name, tmp_pptr->key );
#endif
tmp_pptr->type = VAR_PTR;
tmp_pptr->data = ( tmpptr != NULL ? tmpptr : NULL );
#ifdef FDEBUG
printf( "%p\n", tmp_pptr->data );
#endif
/* for more funcky stuff in the furutre
* if( strlen( (char *)(tmp_pptr->data) ) == 0 )
* {
* free( tmp_pptr->data );
* tmp_pptr->data = __imlib_script_get_variable( tmp_pptr->key );
* }
*/
}
/* excutre the filter */
filter = __imlib_get_dynamic_filter( ptr->name );
if( filter != NULL )
{
printf( "Executing Filter %s\n", ptr->name );
im = filter->exec_filter( ptr->name, im, ptr->params );
imlib_context_set_image( im );
}
start = i+1;
}
}
#ifdef FDEBUG

View File

@ -2,6 +2,7 @@
#define _DYN_FUNCTION_H_
#include "ltdl.h"
#include "Imlib2.h"
#include <stdarg.h>
#define VAR_CHAR 1
@ -26,6 +27,6 @@ struct _imlib_function
pIFunction next;
};
pIFunction __imlib_script_parse( char *script, va_list );
pIFunction __imlib_script_parse( Imlib_Image im, char *script, va_list );
void __imlib_script_tidyup( IFunction *func );
#endif /* _FUNCTION_H_ */