Mercurial > MadButterfly
comparison src/shape_path.c @ 197:bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
author | wycc@wycc-desktop |
---|---|
date | Wed, 19 Nov 2008 00:27:20 +0800 |
parents | 530bb7728546 |
children | 75ec0124202a |
comparison
equal
deleted
inserted
replaced
192:54fdc2a65242 | 197:bcad1ccdf45c |
---|---|
711 #endif | 711 #endif |
712 | 712 |
713 return (shape_t *)path; | 713 return (shape_t *)path; |
714 } | 714 } |
715 | 715 |
716 shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, char *commands, co_aix *arg,int arg_cnt,int *fix_arg,int fix_arg_cnt) { | |
717 sh_path_t *path; | |
718 int msz; | |
719 int cmd_cnt = strlen(commands); | |
720 | |
721 /*! \todo Use elmpool to manage sh_path_t objects. */ | |
722 path = (sh_path_t *)malloc(sizeof(sh_path_t)); | |
723 /*! \todo Remove this memset()? */ | |
724 memset(&path->shape, 0, sizeof(shape_t)); | |
725 path->shape.sh_type = SHT_PATH; | |
726 path->cmd_len = strlen(commands); | |
727 path->arg_len = arg_cnt; | |
728 path->fix_arg_len = fix_arg_cnt; | |
729 msz = cmd_cnt + sizeof(co_aix) * arg_cnt + sizeof(int) * fix_arg_cnt; | |
730 path->user_data = (char *)malloc(msz * 2); | |
731 if(path->user_data == NULL) { | |
732 free(path); | |
733 return NULL; | |
734 } | |
735 | |
736 path->dev_data = path->user_data + msz; | |
737 memcpy(path->user_data,commands,cmd_cnt); | |
738 memcpy(path->user_data+cmd_cnt,arg, sizeof(co_aix)*arg_cnt); | |
739 memcpy(path->user_data+cmd_cnt+arg_cnt*sizeof(co_aix),fix_arg, sizeof(int)*fix_arg_cnt); | |
740 memcpy(path->dev_data, path->user_data, msz); | |
741 | |
742 path->shape.free = sh_path_free; | |
743 | |
744 #ifndef UNITTEST | |
745 rdman_shape_man(rdman, (shape_t *)path); | |
746 #endif | |
747 | |
748 return (shape_t *)path; | |
749 } | |
750 | |
751 | |
716 /*! \brief Transform a path from user space to device space. | 752 /*! \brief Transform a path from user space to device space. |
717 * | 753 * |
718 */ | 754 */ |
719 void sh_path_transform(shape_t *shape) { | 755 void sh_path_transform(shape_t *shape) { |
720 sh_path_t *path; | 756 sh_path_t *path; |