On 07/19/2011 03:49 AM, Jiyoun Park wrote:
> I made patch related with animation gif.
Hi Jiyoun,
I've suggested some changes (formatting & other) in the
attached patch, which applies on top of yours.
thanks,
Mike
diff --git a/evas/src/lib/include/evas_common.h b/evas/src/lib/include/evas_common.h
index 7e33b96..e556985 100644
--- a/evas/src/lib/include/evas_common.h
+++ b/evas/src/lib/include/evas_common.h
@@ -511,7 +511,7 @@ struct _Image_Entry_Flags
Eina_Bool delete_me : 1;
Eina_Bool pending : 1;
#endif
- Eina_Bool animated :1;
+ Eina_Bool animated : 1;
};
struct _Evas_Cache_Target
@@ -595,13 +595,12 @@ struct _Image_Entry
int channel;
int load_error;
- /* for animation feature */
+ /* for animation feature */
int frame_count;
Evas_Image_Animated_Loop_Hint loop_hint;
int loop_count;
int cur_frame;
- Eina_List *frames;
-
+ Eina_List *frames;
};
struct _Engine_Image_Entry
diff --git a/evas/src/modules/engines/software_generic/evas_engine.c b/evas/src/modules/engines/software_generic/evas_engine.c
index a66b65d..5396117 100644
--- a/evas/src/modules/engines/software_generic/evas_engine.c
+++ b/evas/src/modules/engines/software_generic/evas_engine.c
@@ -652,7 +652,7 @@ eng_image_scale_hint_get(void *data __UNUSED__, void *image)
}
static Eina_Bool
-eng_image_animated_get (void *data __UNUSED__, void *image)
+eng_image_animated_get(void *data __UNUSED__, void *image)
{
Image_Entry *im;
@@ -662,7 +662,7 @@ eng_image_animated_get (void *data __UNUSED__, void *image)
}
static int
-eng_image_animated_frame_count_get (void *data __UNUSED__, void *image)
+eng_image_animated_frame_count_get(void *data __UNUSED__, void *image)
{
Image_Entry *im;
@@ -673,7 +673,7 @@ eng_image_animated_frame_count_get (void *data __UNUSED__, void *image)
}
static Evas_Image_Animated_Loop_Hint
-eng_image_animated_loop_type_get (void *data __UNUSED__, void *image)
+eng_image_animated_loop_type_get(void *data __UNUSED__, void *image)
{
Image_Entry *im;
@@ -684,7 +684,7 @@ eng_image_animated_loop_type_get (void *data __UNUSED__, void *image)
}
static int
-eng_image_animated_loop_count_get (void *data __UNUSED__, void *image)
+eng_image_animated_loop_count_get(void *data __UNUSED__, void *image)
{
Image_Entry *im;
@@ -695,7 +695,7 @@ eng_image_animated_loop_count_get (void *data __UNUSED__, void *image)
}
static double
-eng_image_animated_frame_duration_get (void *data __UNUSED__, void *image, int start_frame, int frame_num)
+eng_image_animated_frame_duration_get(void *data __UNUSED__, void *image, int start_frame, int frame_num)
{
Image_Entry *im;
@@ -706,7 +706,7 @@ eng_image_animated_frame_duration_get (void *data __UNUSED__, void *image, int s
}
static Eina_Bool
-eng_image_animated_frame_set (void *data __UNUSED__, void *image, int frame_index)
+eng_image_animated_frame_set(void *data __UNUSED__, void *image, int frame_index)
{
Image_Entry *im;
@@ -714,7 +714,6 @@ eng_image_animated_frame_set (void *data __UNUSED__, void *image, int frame_inde
im = image;
if (!im->flags.animated) return EINA_FALSE;
if (im->cur_frame == frame_index) return EINA_FALSE;
-printf("[%s][%d] frame=%d before: %d after: %d\n",__FUNCTION__,__LINE__,frame_index,im->cur_frame,frame_index);
im->cur_frame = frame_index;
return EINA_TRUE;
}
diff --git a/evas/src/modules/loaders/gif/evas_image_load_gif.c b/evas/src/modules/loaders/gif/evas_image_load_gif.c
index 0f50951..e7e9afa 100644
--- a/evas/src/modules/loaders/gif/evas_image_load_gif.c
+++ b/evas/src/modules/loaders/gif/evas_image_load_gif.c
@@ -83,13 +83,13 @@ _find_frame(Image_Entry *ie, int frame_index, Gif_Frame **frame)
static Eina_Bool
_find_close_frame(Image_Entry *ie, int frame_index, Gif_Frame **frame)
{
- if (!ie) return EINA_FALSE;
- if (!ie->frames) return EINA_FALSE;
-
int i;
Eina_Bool hit = EINA_FALSE;
i = frame_index -1;
+ if (!ie) return EINA_FALSE;
+ if (!ie->frames) return EINA_FALSE;
+
for ( ; i > 0 ; i--)
{
hit = _find_frame(ie, i,frame );
@@ -102,16 +102,15 @@ _find_close_frame(Image_Entry *ie, int frame_index, Gif_Frame **frame)
static Eina_Bool
_evas_image_skip_frame(GifFileType *gif, int frame)
{
- Eina_Bool res = EINA_FALSE;
- int remain_frame = 0;
+ Eina_Bool res = EINA_FALSE;
+ int remain_frame = 0;
GifRecordType rec;
if (!gif) return res;
- if (frame == 0) return EINA_TRUE; //it is not need skip any thing
+ if (frame == 0) return EINA_TRUE; /* no need to skip */
if (frame < 0 || frame > FRAME_MAX) return EINA_FALSE;
remain_frame = frame;
- static int ex_c=0, im_c=0 , im_f_c=0;
do
{
@@ -119,8 +118,6 @@ _evas_image_skip_frame(GifFileType *gif, int frame)
if (rec == EXTENSION_RECORD_TYPE)
{
- ex_c ++;
-
int ext_code;
GifByteType *ext;
@@ -135,9 +132,8 @@ _evas_image_skip_frame(GifFileType *gif, int frame)
if (rec == IMAGE_DESC_RECORD_TYPE)
{
- im_f_c ++;
- int img_code;
- GifByteType *img;
+ int img_code;
+ GifByteType *img;
if (DGifGetImageDesc(gif) == GIF_ERROR) return EINA_FALSE;
@@ -147,14 +143,12 @@ _evas_image_skip_frame(GifFileType *gif, int frame)
while (img)
{
- im_c++;
img = NULL;
DGifGetCodeNext(gif, &img);
}
- im_c=0;
if (remain_frame < 1) return EINA_TRUE;
}
- if (rec == TERMINATE_RECORD_TYPE) return EINA_FALSE; //we skip the end of file. it means
+ if (rec == TERMINATE_RECORD_TYPE) return EINA_FALSE; /* end of file */
} while ((rec != TERMINATE_RECORD_TYPE) && (remain_frame > 0));
}
@@ -164,7 +158,7 @@ static Eina_Bool _evas_image_load_frame_graphic_info(Gif_Frame *frame, GifByteTy
if (!frame || !ext) return EINA_FALSE;
/* transparent */
- if((ext[1] & 0x1) != 0)
+ if ((ext[1] & 0x1) != 0)
frame->frame_info.transparent = ext[4];
else
frame->frame_info.transparent = -1;
@@ -176,7 +170,7 @@ static Eina_Bool _evas_image_load_frame_graphic_info(Gif_Frame *frame, GifByteTy
static Eina_Bool _evas_image_load_frame_image_des_info(GifFileType *gif, Gif_Frame *frame)
{
- if( !gif || !frame) return EINA_FALSE;
+ if (!gif || !frame) return EINA_FALSE;
frame->image_des.x = gif->Image.Left;
frame->image_des.y = gif->Image.Top;
frame->image_des.w = gif->Image.Width;
@@ -186,7 +180,6 @@ static Eina_Bool _evas_image_load_frame_image_des_info(GifFileType *gif, Gif_Fra
static Eina_Bool _evas_image_load_frame_image_data(Image_Entry *ie, GifFileType *gif, Gif_Frame *frame, int *error)
{
- if( !gif || !frame) return EINA_FALSE;
int w;
int h;
int i,j;
@@ -199,13 +192,16 @@ static Eina_Bool _evas_image_load_frame_image_data(Image_Entry *ie, GifFileType
double per;
double per_inc;
ColorMapObject *cmap;
- GifByteType *img;
- GifRowType *rows;
+ GifByteType *img;
+ GifRowType *rows;
int intoffset[] = { 0, 4, 2, 1 };
int intjump[] = { 8, 8, 4, 2 };
- size_t siz = 0;
+ size_t siz;
+ int cache_w;
+ int cache_h;
+
+ if (!gif || !frame) return EINA_FALSE;
- int cache_w, cache_h;
w = gif->Image.Width;
h = gif->Image.Height;
cache_w = ie->w;
@@ -252,7 +248,7 @@ static Eina_Bool _evas_image_load_frame_image_data(Image_Entry *ie, GifFileType
{
for (i = 0; i < h; i++)
{
- if(DGifGetLine(gif, rows[i], w) != GIF_OK)
+ if (DGifGetLine(gif, rows[i], w) != GIF_OK)
{
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
goto error;
@@ -270,12 +266,13 @@ static Eina_Bool _evas_image_load_frame_image_data(Image_Entry *ie, GifFileType
per_inc = 100.0 / (((double)w) * h);
if (frame->index > 1)
{
- //1. get previous frame only frame index is bigger than 1
+ /* get previous frame only frame index is bigger than 1 */
int cur_frame = frame->index;
DATA32 *ptr_src;
Gif_Frame *new_frame = NULL;
+ int cur_x, cur_y;
- if(!_find_close_frame(ie, cur_frame, &new_frame))
+ if (!_find_close_frame(ie, cur_frame, &new_frame))
{
if (!evas_image_load_specific_frame(ie, ie->file, cur_frame-1, error))
{
@@ -289,10 +286,9 @@ static Eina_Bool _evas_image_load_frame_image_data(Image_Entry *ie, GifFileType
memcpy(ptr, ptr_src, siz);
}
-
- //2. composite frames
- int cur_x = frame->image_des.x;
- int cur_y = frame->image_des.y;
+ /* composite frames */
+ cur_x = frame->image_des.x;
+ cur_y = frame->image_des.y;
ptr = ptr + cache_w*(cur_y);
for (i = 0; i < h; i++)
@@ -351,32 +347,28 @@ error:
}
free(rows);
return EINA_FALSE;
-
}
static Eina_Bool
_evas_image_load_frame(Image_Entry *ie, GifFileType *gif, Gif_Frame *frame, Frame_Load_Type type, int *error)
{
- if (!gif || !frame) return EINA_FALSE;
- if (LOAD_FRAME_NONE > type || LOAD_FRAME_DATA_INFO < type) return EINA_FALSE;
-
GifRecordType rec;
+ int f_c = 0;
+ int gra_res = 0, img_res = 0;
+ Eina_Bool res = EINA_FALSE;
- int f_c =0;
- int gra_res = 0, img_res = 0;
- Eina_Bool res = EINA_FALSE;
-
+ if (!gif || !frame) return EINA_FALSE;
+ if (LOAD_FRAME_NONE > type || LOAD_FRAME_DATA_INFO < type) return EINA_FALSE;
do
{
-
if (DGifGetRecordType(gif, &rec) == GIF_ERROR) return EINA_FALSE;
if (rec == IMAGE_DESC_RECORD_TYPE)
{
- img_res ++;
+ img_res++;
break;
}
- else if (rec = EXTENSION_RECORD_TYPE)
+ else if (rec = EXTENSION_RECORD_TYPE)
{
int ext_code;
GifByteType *ext;
@@ -385,23 +377,24 @@ _evas_image_load_frame(Image_Entry *ie, GifFileType *gif, Gif_Frame *frame, Fram
DGifGetExtension(gif, &ext_code, &ext);
while (ext)
{
- if(ext_code == 0xf9) /*Graphic Control Extension */
+ if (ext_code == 0xf9) /* Graphic Control Extension */
{
- gra_res ++;
- if ((type == LOAD_FRAME_INFO) || (type == LOAD_FRAME_DATA_INFO)) /*fill frame info */
- _evas_image_load_frame_graphic_info(frame,ext);
+ gra_res++;
+ /* fill frame info */
+ if ((type == LOAD_FRAME_INFO) || (type == LOAD_FRAME_DATA_INFO))
+ _evas_image_load_frame_graphic_info(frame,ext);
}
ext = NULL;
DGifGetExtensionNext(gif, &ext);
}
}
- }while ((rec != TERMINATE_RECORD_TYPE) && (img_res == 0));
- if ( (gra_res !=1 ) || (gra_res !=1 )) return EINA_FALSE;
+ } while ((rec != TERMINATE_RECORD_TYPE) && (img_res == 0));
+ if ((gra_res != 1) || (gra_res != 1)) return EINA_FALSE;
if (DGifGetImageDesc(gif) == GIF_ERROR) return EINA_FALSE;
- if ((type == LOAD_FRAME_INFO) || (type == LOAD_FRAME_DATA_INFO))
+ if ((type == LOAD_FRAME_INFO) || (type == LOAD_FRAME_DATA_INFO))
_evas_image_load_frame_image_des_info(gif, frame);
- if ((type == LOAD_FRAME_DATA) || (type == LOAD_FRAME_DATA_INFO))
+ if ((type == LOAD_FRAME_DATA) || (type == LOAD_FRAME_DATA_INFO))
{
res = _evas_image_load_frame_image_data(ie, gif,frame, error);
if (!res) return EINA_FALSE;
@@ -410,7 +403,7 @@ _evas_image_load_frame(Image_Entry *ie, GifFileType *gif, Gif_Frame *frame, Fram
}
-//set frame data to cache entry's data
+/* set frame data to cache entry's data */
static Eina_Bool evas_image_load_file_data_gif_internal(Image_Entry *ie, Gif_Frame *frame, int *error)
{
int w;
@@ -422,6 +415,8 @@ static Eina_Bool evas_image_load_file_data_gif_internal(Image_Entry *ie, Gif_Fra
DATA32 *dst;
DATA32 *src;
int cache_w, cache_h;
+ size_t siz;
+
cache_w = ie->w;
cache_h = ie->h;
w = frame->image_des.w;
@@ -429,22 +424,20 @@ static Eina_Bool evas_image_load_file_data_gif_internal(Image_Entry *ie, Gif_Fra
dst_x = frame->image_des.x;
dst_y = frame->image_des.y;
- src=frame->data;
+ src = frame->data;
-/*first check */
if (!evas_cache_image_pixels(ie))
{
- evas_cache_image_surface_alloc(ie, w, h);
+ evas_cache_image_surface_alloc(ie, w, h);
}
- /*second check*/
+
if (!evas_cache_image_pixels(ie))
{
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
return EINA_FALSE;
}
-/////////////only copy real frame part
- size_t siz = 0;
+ /* only copy real frame part */
siz = cache_w * cache_h * sizeof(DATA32);
dst = evas_cache_image_pixels(ie);
@@ -465,9 +458,7 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char *file, const char *key
int w;
int h;
int alpha;
-
- // for animated image
- int loop_count = -1;
+ int loop_count = -1;
w = 0;
h = 0;
@@ -549,13 +540,14 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char *file, const char *key
DGifGetExtension(gif, &ext_code, &ext);
while (ext)
{
- if(ext_code == 0xf9) /* Graphic Control Extension */
+ if (ext_code == 0xf9) /* Graphic Control Extension */
{
if ((ext[1] & 1) && (alpha < 0)) alpha = (int)ext[4];
}
- else if(ext_code == 0xff)/* application extension */
+ else if (ext_code == 0xff) /* application extension */
{
- if (!strncmp ((char*)(&ext[1]), "NETSCAPE2.0", 11) || !strncmp ((char*)(&ext[1]), "ANIMEXTS1.0", 11))
+ if (!strncmp ((char*)(&ext[1]), "NETSCAPE2.0", 11) ||
+ !strncmp ((char*)(&ext[1]), "ANIMEXTS1.0", 11))
{
ext=NULL;
DGifGetExtensionNext(gif, &ext);
@@ -590,15 +582,13 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char *file, const char *key
return EINA_TRUE;
}
-
-
static Eina_Bool
evas_image_load_specific_frame(Image_Entry *ie, const char *file, int frame_index, int *error)
{
-
int fd;
- GifFileType *gif;
+ GifFileType *gif;
Gif_Frame *frame = NULL;
+
#ifndef __EMX__
fd = open(file, O_RDONLY);
#else
@@ -625,25 +615,24 @@ evas_image_load_specific_frame(Image_Entry *ie, const char *file, int frame_inde
}
frame = malloc(sizeof (Gif_Frame));
- if(!frame)
+ if (!frame)
{
- if(fd)
+ if (fd)
close(fd);
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
return EINA_FALSE;
}
frame->index = frame_index;
- if(!_evas_image_load_frame(ie,gif, frame, LOAD_FRAME_DATA_INFO,error))
+ if (!_evas_image_load_frame(ie,gif, frame, LOAD_FRAME_DATA_INFO,error))
{
- if(fd)
+ if (fd)
close(fd);
return EINA_FALSE;
}
ie->frames = eina_list_append(ie->frames, frame);
- //LOAD sucess
- if(fd)
+ if (fd)
close(fd);
return EINA_TRUE;
}
@@ -653,7 +642,8 @@ evas_image_load_file_data_gif(Image_Entry *ie, const char *file, const char *key
{
int cur_frame_index;
Gif_Frame *frame = NULL;
-
+ Eina_Bool hit;
+ Eina_Bool res;
cur_frame_index = ie->cur_frame;
@@ -662,23 +652,23 @@ evas_image_load_file_data_gif(Image_Entry *ie, const char *file, const char *key
*error = EVAS_LOAD_ERROR_GENERIC;
return EINA_FALSE;
}
- if (cur_frame_index == 0) cur_frame_index++; //first time frame is set to be 0. so default is 1
- /* 1. Cecke current frame exist in hash table */
- Eina_Bool hit = EINA_FALSE;
+ /* first time frame is set to be 0. so default is 1 */
+ if (cur_frame_index == 0) cur_frame_index++;
+ /* Check current frame exists in hash table */
hit = _find_frame(ie, cur_frame_index, &frame);
- // 1-1. if current frame exist in hast table, check load flag
- Eina_Bool res;
+ /* if current frame exist in has table, check load flag */
if (hit)
{
- if (frame->loaded)// 1-1-1. if it loaded , return it.
+ if (frame->loaded)
res = evas_image_load_file_data_gif_internal(ie,frame,error);
- else //1-1-2. if it is not loaded
+ else
{
int fd;
GifFileType *gif;
+
#ifndef __EMX__
fd = open(file, O_RDONLY);
#else
@@ -698,13 +688,13 @@ evas_image_load_file_data_gif(Image_Entry *ie, const char *file, const char *key
return EINA_FALSE;
}
_evas_image_skip_frame(gif, cur_frame_index-1);
- if(!_evas_image_load_frame(ie, gif, frame, LOAD_FRAME_DATA,error))
+ if (!_evas_image_load_frame(ie, gif, frame, LOAD_FRAME_DATA,error))
{
close(fd);
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
return EINA_FALSE;
}
- if(! evas_image_load_file_data_gif_internal( ie, frame, error))
+ if (!evas_image_load_file_data_gif_internal( ie, frame, error))
{
close(fd);
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
@@ -714,7 +704,7 @@ evas_image_load_file_data_gif(Image_Entry *ie, const char *file, const char *key
}
}
- // 1-2. current frame is not exist
+ /* current frame does is not exist */
else
{
if (!evas_image_load_specific_frame(ie, file, cur_frame_index, error))
@@ -725,7 +715,7 @@ evas_image_load_file_data_gif(Image_Entry *ie, const char *file, const char *key
frame = NULL;
hit = _find_frame(ie, cur_frame_index, &frame);
if (!hit) return EINA_FALSE;
- if (!evas_image_load_file_data_gif_internal( ie, frame, error))
+ if (!evas_image_load_file_data_gif_internal(ie, frame, error))
{
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
return EINA_FALSE;
@@ -742,12 +732,10 @@ evas_image_load_frame_duration_gif(Image_Entry *ie, const char *file, const int
GifFileType *gif;
GifRecordType rec;
int done;
-
- // for animated image
- int current_frame = 1;
- int remain_frames = frame_num;
- double duration = 0;
- int frame_count = 0;
+ int current_frame = 1;
+ int remain_frames = frame_num;
+ double duration = 0;
+ int frame_count = 0;
frame_count = ie->frame_count;
@@ -762,10 +750,7 @@ evas_image_load_frame_duration_gif(Image_Entry *ie, const char *file, const int
#else
fd = open(file, O_RDONLY | O_BINARY);
#endif
- if (fd < 0)
- {
- return -1;
- }
+ if (fd < 0) return -1;
gif = DGifOpenFileHandle(fd);
if (!gif)
@@ -774,7 +759,6 @@ evas_image_load_frame_duration_gif(Image_Entry *ie, const char *file, const int
return -1;
}
-
do
{
if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
@@ -783,8 +767,8 @@ evas_image_load_frame_duration_gif(Image_Entry *ie, const char *file, const int
}
if (rec == IMAGE_DESC_RECORD_TYPE)
{
- int img_code;
- GifByteType *img;
+ int img_code;
+ GifByteType *img;
if (DGifGetImageDesc(gif) == GIF_ERROR)
{
@@ -812,7 +796,7 @@ evas_image_load_frame_duration_gif(Image_Entry *ie, const char *file, const int
DGifGetExtension(gif, &ext_code, &ext);
while (ext)
{
- if(ext_code == 0xf9) /* Graphic Control Extension */
+ if (ext_code == 0xf9) /* Graphic Control Extension */
{
int *test = NULL;
------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel