diff options
Diffstat (limited to 'filters')
| -rw-r--r-- | filters/php_bumpmap.c | 30 | ||||
| -rw-r--r-- | filters/php_colormatrix.c | 72 | ||||
| -rw-r--r-- | filters/php_colormod.c | 25 | ||||
| -rw-r--r-- | filters/php_hsbcolor.c | 42 | ||||
| -rw-r--r-- | filters/php_testfilter.c | 35 |
5 files changed, 123 insertions, 81 deletions
diff --git a/filters/php_bumpmap.c b/filters/php_bumpmap.c index 24e548d..6910f82 100644 --- a/filters/php_bumpmap.c +++ b/filters/php_bumpmap.c @@ -44,9 +44,7 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) int *paramtypes; char *script; Imlib_Image im=NULL; - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; paramnames=allpnames[index]; paramtypes=allptypes[index]; @@ -54,28 +52,36 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) script=estrdup(filter); script=_php_bumpmap_stradd(script,"("); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) - { - if (str_index) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) + { + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { int match=0; int index=0; while (paramnames[index]) { - if (strcmp(STR_VAL(str_index),paramnames[index])==0) + if (strcmp(str_index,paramnames[index])==0) { char val[32]; + zval **data; + zend_hash_get_current_data_ex(params,(void**)&data,&pos); switch(paramtypes[index]) { case 'I': - im=(Imlib_Image)_php_imlib_get_image(Z_RES_P(data)); /* Why is cast to Imlib_Image needed? */ + im=(Imlib_Image)_php_imlib_get_image(data); /* Why is cast to Imlib_Image needed? */ script=_php_bumpmap_stradd(script,"map=[]"); break; case 'i': convert_to_long_ex(data); sprintf(val,"%d",(int)Z_LVAL_PP(data)); - script=_php_bumpmap_stradd(script,STR_VAL(str_index)); + script=_php_bumpmap_stradd(script,str_index); script=_php_bumpmap_stradd(script,"="); script=_php_bumpmap_stradd(script,val); break; @@ -91,7 +97,8 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) php_error(E_NOTICE,"Unknown argument %s ignored",str_index); } } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (script[strlen(script)-1]==',') script[strlen(script)-1]='\0'; script=_php_bumpmap_stradd(script,");"); @@ -115,9 +122,6 @@ php_filter_deinit() } int -_php_bumpmap_getfilterindex(char*); - -int php_filter_exec(Imlib_Image im, char *filter, HashTable *params) { int index=_php_bumpmap_getfilterindex(filter); diff --git a/filters/php_colormatrix.c b/filters/php_colormatrix.c index f5dab0e..1cd28b2 100644 --- a/filters/php_colormatrix.c +++ b/filters/php_colormatrix.c @@ -264,36 +264,42 @@ static void _php_colormatrix_saturatemat(double mat[16], double sat) mat[15] = 1.0; } -static void _php_colormatrix_usermat(double mat[16], imlib_zval* data) +static void _php_colormatrix_usermat(double mat[16], zval** data) { HashTable* mat_ht; - ulong num_index; - zend_string *str_index; - imlib_zval *value; - - convert_to_array_ex(data); -#if PHP_VERSION_ID >= 70000 - mat_ht = HASH_OF(data); -#else + HashPosition pos; + + convert_to_array_ex(data); + mat_ht=(*data)->value.ht; // FIXME: should really use HASH_OF macro. // Filter API change needed to supply TSRMLS to filters -#endif - ZEND_HASH_FOREACH_KEY_VAL(mat_ht, num_index, str_index, value) + zend_hash_internal_pointer_reset_ex(mat_ht,&pos); + while (pos) { - if ((num_index>=0)&&(num_index<16)) + char *str_index; + ulong num_index; + int retval; + zval **value; + + retval=zend_hash_get_current_key_ex(mat_ht,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_LONG) { - convert_to_double_ex(value); - mat[num_index]=Z_DVAL_PP(value); + if ((num_index>=0)&&(num_index<16)) + { + zend_hash_get_current_data_ex(mat_ht,(void**)&value,&pos); + convert_to_double_ex(value); + mat[num_index]=Z_DVAL_PP(value); + } } - } ZEND_HASH_FOREACH_END(); + + zend_hash_move_forward_ex(mat_ht,&pos); + } } static int _php_colormatrix_exec(Imlib_Image im, char* filter, HashTable* params) { - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; double mat[16]; int x=0,y=0,w,h,imgw,imgh; @@ -304,28 +310,38 @@ _php_colormatrix_exec(Imlib_Image im, char* filter, HashTable* params) w = imgw = imlib_image_get_width(); h = imgh = imlib_image_get_height(); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { - if (!strcmp(STR_VAL(str_index),"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; + zval **data; + zend_hash_get_current_data_ex(params,(void**)&data,&pos); + + if (!strcmp(str_index,"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; if (!strcmp(filter,"cm_user")) { - if (!strcmp(STR_VAL(str_index),"matrix")) _php_colormatrix_usermat(mat,data); + if (!strcmp(str_index,"matrix")) _php_colormatrix_usermat(mat,data); } if (!strcmp(filter,"cm_saturation")) { - if (!strcmp(STR_VAL(str_index),"sat")) { convert_to_double_ex(data); _php_colormatrix_saturatemat(mat,Z_DVAL_PP(data)); }; + if (!strcmp(str_index,"sat")) { convert_to_double_ex(data); _php_colormatrix_saturatemat(mat,Z_DVAL_PP(data)); }; } if (!strcmp(filter,"cm_huerot")) { - if (!strcmp(STR_VAL(str_index),"angle")) { convert_to_double_ex(data); _php_colormatrix_huerotatemat(mat,Z_DVAL_PP(data)); }; + if (!strcmp(str_index,"angle")) { convert_to_double_ex(data); _php_colormatrix_huerotatemat(mat,Z_DVAL_PP(data)); }; } } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (x<0) x=0; if (y<0) y=0; diff --git a/filters/php_colormod.c b/filters/php_colormod.c index a93ae84..c240f1f 100644 --- a/filters/php_colormod.c +++ b/filters/php_colormod.c @@ -32,37 +32,43 @@ _php_colormod_exec(HashTable* params) char *paramnames[]={"x","y","w","h","brightness","contrast","gamma","brightness_r","contrast_r","gamma_r","brightness_g","contrast_g","gamma_g","brightness_b","contrast_b","gamma_b","brightness_a","contrast_a","gamma_a","tint","tint_r","tint_g","tint_b","tint_a",0}; int paramtypes[]= {'i','i','i','i','d', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd' }; char *script; - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; script=estrdup("colormod("); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { int match=0; int index=0; while (paramnames[index]) { - if (strcmp(STR_VAL(str_index),paramnames[index])==0) + if (strcmp(str_index,paramnames[index])==0) { char val[32]; + zval **data; + zend_hash_get_current_data_ex(params,(void**)&data,&pos); switch(paramtypes[index]) { case 'i': convert_to_long_ex(data); sprintf(val,"%d",(int)Z_LVAL_PP(data)); - script=_php_colormod_stradd(script,STR_VAL(str_index)); + script=_php_colormod_stradd(script,str_index); script=_php_colormod_stradd(script,"="); script=_php_colormod_stradd(script,val); break; case 'd': convert_to_double_ex(data); sprintf(val,"%f",(double)Z_DVAL_PP(data)); - script=_php_colormod_stradd(script,STR_VAL(str_index)); + script=_php_colormod_stradd(script,str_index); script=_php_colormod_stradd(script,"="); script=_php_colormod_stradd(script,val); break; @@ -78,7 +84,8 @@ _php_colormod_exec(HashTable* params) php_error(E_NOTICE,"Unknown argument %s ignored",str_index); } } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (script[strlen(script)-1]==',') script[strlen(script)-1]='\0'; script=_php_colormod_stradd(script,");"); diff --git a/filters/php_hsbcolor.c b/filters/php_hsbcolor.c index 288c7c1..577afc2 100644 --- a/filters/php_hsbcolor.c +++ b/filters/php_hsbcolor.c @@ -101,9 +101,7 @@ static void _php_hsbcolor_hsb2rgb(double hue, double saturation, double brightne static int _php_hsbcolor_exec(Imlib_Image im, HashTable* params) { - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; double h_add = 0, s_add = 0, b_add = 0; double h_mul = 1.0, s_mul = 1.0, b_mul = 1.0; @@ -113,23 +111,33 @@ _php_hsbcolor_exec(Imlib_Image im, HashTable* params) w = imgw = imlib_image_get_width(); h = imgh = imlib_image_get_height(); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { - if (!strcmp(STR_VAL(str_index),"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; - - if (!strcmp(STR_VAL(str_index),"h_add")) { convert_to_double_ex(data); h_add=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"s_add")) { convert_to_double_ex(data); s_add=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"b_add")) { convert_to_double_ex(data); b_add=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"h_mul")) { convert_to_double_ex(data); h_mul=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"s_mul")) { convert_to_double_ex(data); s_mul=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"b_mul")) { convert_to_double_ex(data); b_mul=Z_DVAL_PP(data); }; + zval **data; + zend_hash_get_current_data_ex(params,(void*)&data,&pos); + + if (!strcmp(str_index,"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; + + if (!strcmp(str_index,"h_add")) { convert_to_double_ex(data); h_add=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"s_add")) { convert_to_double_ex(data); s_add=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"b_add")) { convert_to_double_ex(data); b_add=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"h_mul")) { convert_to_double_ex(data); h_mul=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"s_mul")) { convert_to_double_ex(data); s_mul=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"b_mul")) { convert_to_double_ex(data); b_mul=Z_DVAL_PP(data); }; } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (x<0) x=0; if (y<0) y=0; diff --git a/filters/php_testfilter.c b/filters/php_testfilter.c index c9e4b5b..ca844b3 100644 --- a/filters/php_testfilter.c +++ b/filters/php_testfilter.c @@ -14,9 +14,7 @@ _php_testfilter_tint(Imlib_Image im, HashTable* params) { Imlib_Image imge = im; Imlib_Image anoim; - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; Imlib_Color_Modifier cm; DATA8 atab[256]; @@ -30,21 +28,30 @@ _php_testfilter_tint(Imlib_Image im, HashTable* params) w = imlib_image_get_width(); h = imlib_image_get_height(); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { + zval **data; + zend_hash_get_current_data_ex(params,(void*)&data,&pos); convert_to_long_ex(data); - if (!strcmp(STR_VAL(str_index),"red")) r=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"blue")) b=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"green")) g=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"x")) x=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"y")) y=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"w")) w=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"h")) h=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"alpha")) a=Z_LVAL_PP(data); + if (!strcmp(str_index,"red")) r=Z_LVAL_PP(data); + if (!strcmp(str_index,"blue")) b=Z_LVAL_PP(data); + if (!strcmp(str_index,"green")) g=Z_LVAL_PP(data); + if (!strcmp(str_index,"x")) x=Z_LVAL_PP(data); + if (!strcmp(str_index,"y")) y=Z_LVAL_PP(data); + if (!strcmp(str_index,"w")) w=Z_LVAL_PP(data); + if (!strcmp(str_index,"h")) h=Z_LVAL_PP(data); + if (!strcmp(str_index,"alpha")) a=Z_LVAL_PP(data); } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } /* zend_printf( "Using values red=%d,blue=%d,green=%d,x=%d,y=%d,height=%d,width=%d,alpha=%d\n", r,b,g,x,y,w,h,a ); */ |
