From: cedric Date: Tue, 20 Jan 2009 14:56:37 +0000 (+0000) Subject: Correctly cancel each image object and not all at once. X-Git-Tag: accepted/2.0/20130306.225542~242^2~2628 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5383c98357aa38daea87e95e27f6580d5fc47daf;p=profile%2Fivi%2Fevas.git Correctly cancel each image object and not all at once. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@38658 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/cache/evas_cache.h b/src/lib/cache/evas_cache.h index e2c1770..605d9cf 100644 --- a/src/lib/cache/evas_cache.h +++ b/src/lib/cache/evas_cache.h @@ -154,7 +154,7 @@ EAPI Engine_Image_Entry* evas_cache_engine_image_size_set(Engine_Image_Entr EAPI void evas_cache_engine_image_load_data(Engine_Image_Entry *eim); EAPI void evas_cache_image_preload_data(Image_Entry *im, const void *target); -EAPI void evas_cache_image_preload_cancel(Image_Entry *im); +EAPI void evas_cache_image_preload_cancel(Image_Entry *im, const void *target); #ifdef __cplusplus } diff --git a/src/lib/cache/evas_cache_image.c b/src/lib/cache/evas_cache_image.c index c6d424d..a9cc888 100644 --- a/src/lib/cache/evas_cache_image.c +++ b/src/lib/cache/evas_cache_image.c @@ -300,6 +300,22 @@ _evas_cache_image_entry_surface_alloc(Evas_Cache_Image *cache, } #ifdef BUILD_ASYNC_PRELOAD +static void +_evas_cache_image_async_call(Image_Entry *im) +{ + pthread_mutex_lock(&mutex); + while (im->targets) + { + Evas_Cache_Target *tmp = im->targets; + + evas_async_events_put(tmp->target, EVAS_CALLBACK_IMAGE_PRELOADED, NULL, + (void (*)(void*, Evas_Callback_Type, void*))evas_object_event_callback_call); + im->targets = (Evas_Cache_Target*) eina_inlist_remove(EINA_INLIST_GET(im->targets), EINA_INLIST_GET(im->targets)); + free(tmp); + } + pthread_mutex_unlock(&mutex); +} + static int _evas_cache_image_entry_preload_add(Image_Entry *ie, const void *target) @@ -347,7 +363,7 @@ _evas_cache_image_entry_preload_add(Image_Entry *ie, } static int -_evas_cache_image_entry_preload_remove(Image_Entry *ie) +_evas_cache_image_entry_preload_remove(Image_Entry *ie, const void *target) { int ret = 0; @@ -369,9 +385,35 @@ _evas_cache_image_entry_preload_remove(Image_Entry *ie) { if (l->ie == ie) { - preload = eina_inlist_remove(preload, - EINA_INLIST_GET(l)); - free(l); + Evas_Cache_Target *tg; + + if (target) { + EINA_INLIST_FOREACH(ie->targets, tg) + { + if (tg->target == target) { + ie->targets = (Evas_Cache_Target*) eina_inlist_remove(EINA_INLIST_GET(ie->targets), EINA_INLIST_GET(tg)); + free(tg); + break; + } + } + } else { + _evas_cache_image_async_call(ie); + + while (ie->targets) + { + tg = ie->targets; + ie->targets = (Evas_Cache_Target*) eina_inlist_remove(EINA_INLIST_GET(ie->targets), EINA_INLIST_GET(tg)); + free(tg); + } + } + + if (!ie->targets) + { + preload = eina_inlist_remove(preload, + EINA_INLIST_GET(l)); + free(l); + } + break; } } @@ -385,22 +427,6 @@ _evas_cache_image_entry_preload_remove(Image_Entry *ie) return ret; } - -static void -_evas_cache_image_async_call(Image_Entry *im) -{ - pthread_mutex_lock(&mutex); - while (im->targets) - { - Evas_Cache_Target *tmp = im->targets; - - evas_async_events_put(tmp->target, EVAS_CALLBACK_IMAGE_PRELOADED, NULL, - (void (*)(void*, Evas_Callback_Type, void*))evas_object_event_callback_call); - im->targets = (Evas_Cache_Target*) eina_inlist_remove(EINA_INLIST_GET(im->targets), EINA_INLIST_GET(im->targets)); - free(tmp); - } - pthread_mutex_unlock(&mutex); -} #endif EAPI int @@ -677,7 +703,7 @@ evas_cache_image_drop(Image_Entry *im) if (im->references == 0) { #ifdef BUILD_ASYNC_PRELOAD - _evas_cache_image_entry_preload_remove(im); + _evas_cache_image_entry_preload_remove(im, NULL); #endif if (im->flags.dirty) @@ -945,7 +971,7 @@ evas_cache_image_load_data(Image_Entry *im) #ifdef BUILD_ASYNC_PRELOAD int preload = im->flags.preload; /* We check a first time, to prevent useless lock. */ - _evas_cache_image_entry_preload_remove(im); + _evas_cache_image_entry_preload_remove(im, NULL); if (im->flags.loaded) return ; pthread_mutex_lock(&im->lock); #endif @@ -1005,7 +1031,7 @@ evas_cache_image_preload_data(Image_Entry *im, const void *target) } EAPI void -evas_cache_image_preload_cancel(Image_Entry *im) +evas_cache_image_preload_cancel(Image_Entry *im, const void *target) { #ifdef BUILD_ASYNC_PRELOAD Evas_Cache_Image *cache; @@ -1014,7 +1040,7 @@ evas_cache_image_preload_cancel(Image_Entry *im) assert(im->cache); cache = im->cache; - _evas_cache_image_entry_preload_remove(im); + _evas_cache_image_entry_preload_remove(im, target); #else (void) im; #endif diff --git a/src/lib/canvas/evas_object_image.c b/src/lib/canvas/evas_object_image.c index b30ffae..922f537 100644 --- a/src/lib/canvas/evas_object_image.c +++ b/src/lib/canvas/evas_object_image.c @@ -267,7 +267,8 @@ evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key) if (!o->engine_data) obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output, - o->engine_data); + o->engine_data, + obj); if (o->cur.file) eina_stringshare_del(o->cur.file); if (o->cur.key) eina_stringshare_del(o->cur.key); @@ -1081,7 +1082,8 @@ evas_object_image_preload(Evas_Object *obj, Evas_Bool cancel) } if (cancel) obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output, - o->engine_data); + o->engine_data, + obj); else obj->layer->evas->engine.func->image_data_preload_request(obj->layer->evas->engine.data.output, o->engine_data, diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h index ae1bcc9..ee63a8b 100644 --- a/src/lib/include/evas_private.h +++ b/src/lib/include/evas_private.h @@ -632,7 +632,7 @@ struct _Evas_Func void *(*image_data_get) (void *data, void *image, int to_write, DATA32 **image_data); void *(*image_data_put) (void *data, void *image, DATA32 *image_data); void (*image_data_preload_request) (void *data, void *image, const void *target); - void (*image_data_preload_cancel) (void *data, void *image); + void (*image_data_preload_cancel) (void *data, void *image, const void *target); void *(*image_alpha_set) (void *data, void *image, int has_alpha); int (*image_alpha_get) (void *data, void *image); void *(*image_border_set) (void *data, void *image, int l, int r, int t, int b); diff --git a/src/modules/engines/cairo_x11/evas_engine.c b/src/modules/engines/cairo_x11/evas_engine.c index 655d81a..130bcf0 100644 --- a/src/modules/engines/cairo_x11/evas_engine.c +++ b/src/modules/engines/cairo_x11/evas_engine.c @@ -79,8 +79,8 @@ static void *eng_image_size_set(void *data, void *image, int w, int h); static void *eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h); static void *eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data); static void *eng_image_data_put(void *data, void *image, DATA32 *image_data); -static void eng_image_data_preload_request(void *data, void *image, void *target); -static void eng_image_data_preload_cancel(void *data, void *image); +static void eng_image_data_preload_request(void *data, void *image, const void *target); +static void eng_image_data_preload_cancel(void *data, void *image, const void *target); static void *eng_image_alpha_set(void *data, void *image, int has_alpha); static int eng_image_alpha_get(void *data, void *image); static void *eng_image_border_set(void *data, void *image, int l, int r, int t, int b); @@ -1047,7 +1047,7 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data) } static void -eng_image_data_preload_request(void *data, void *image, void *target) +eng_image_data_preload_request(void *data, void *image, const void *target) { Render_Engine *re; @@ -1057,7 +1057,7 @@ eng_image_data_preload_request(void *data, void *image, void *target) } static void -eng_image_data_preload_cancel(void *data, void *image) +eng_image_data_preload_cancel(void *data, void *image, const void *target) { Render_Engine *re; diff --git a/src/modules/engines/directfb/evas_engine.c b/src/modules/engines/directfb/evas_engine.c index e1ca579..7f4284b 100644 --- a/src/modules/engines/directfb/evas_engine.c +++ b/src/modules/engines/directfb/evas_engine.c @@ -1414,7 +1414,7 @@ evas_engine_dfb_image_data_put(void *data, void *image, DATA32* image_data) } static void -evas_engine_dfb_image_data_preload_request(void *data, void *image, void *target) +evas_engine_dfb_image_data_preload_request(void *data, void *image, const void *target) { DirectFB_Engine_Image_Entry *deie = image; RGBA_Image *im; @@ -1426,7 +1426,7 @@ evas_engine_dfb_image_data_preload_request(void *data, void *image, void *target } static void -evas_engine_dfb_image_data_preload_cancel(void *data, void *image) +evas_engine_dfb_image_data_preload_cancel(void *data, void *image, const void *target) { DirectFB_Engine_Image_Entry *deie = image; RGBA_Image *im; @@ -1434,7 +1434,7 @@ evas_engine_dfb_image_data_preload_cancel(void *data, void *image) if (!deie) return ; im = (RGBA_Image*) deie->cache_entry.src; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void * diff --git a/src/modules/engines/gl_glew/evas_engine.c b/src/modules/engines/gl_glew/evas_engine.c index de8c599..2f916c2 100644 --- a/src/modules/engines/gl_glew/evas_engine.c +++ b/src/modules/engines/gl_glew/evas_engine.c @@ -837,7 +837,7 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data) } static void -eng_image_data_preload_request(void *data, void *image, void *target) +eng_image_data_preload_request(void *data, void *image, const void *target) { Evas_GL_Image *gim = image; RGBA_Image *im; @@ -849,7 +849,7 @@ eng_image_data_preload_request(void *data, void *image, void *target) } static void -eng_image_data_preload_cancel(void *data, void *image) +eng_image_data_preload_cancel(void *data, void *image, const void *target) { Evas_GL_Image *gim = image; RGBA_Image *im; @@ -857,7 +857,7 @@ eng_image_data_preload_cancel(void *data, void *image) if (!gim) return ; im = (RGBA_Image*) gim->im; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void diff --git a/src/modules/engines/gl_x11/evas_engine.c b/src/modules/engines/gl_x11/evas_engine.c index 1c56809..7b22cf3 100644 --- a/src/modules/engines/gl_x11/evas_engine.c +++ b/src/modules/engines/gl_x11/evas_engine.c @@ -967,7 +967,7 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data) } static void -eng_image_data_preload_request(void *data, void *image, void *target) +eng_image_data_preload_request(void *data, void *image, const void *target) { Evas_GL_Image *gim = image; RGBA_Image *im; @@ -979,7 +979,7 @@ eng_image_data_preload_request(void *data, void *image, void *target) } static void -eng_image_data_preload_cancel(void *data, void *image) +eng_image_data_preload_cancel(void *data, void *image, const void *target) { Evas_GL_Image *gim = image; RGBA_Image *im; @@ -987,7 +987,7 @@ eng_image_data_preload_cancel(void *data, void *image) if (!gim) return ; im = (RGBA_Image*) gim->im; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void diff --git a/src/modules/engines/software_16/evas_engine.c b/src/modules/engines/software_16/evas_engine.c index c9b142a..a2b0704 100644 --- a/src/modules/engines/software_16/evas_engine.c +++ b/src/modules/engines/software_16/evas_engine.c @@ -624,12 +624,12 @@ eng_image_data_preload_request(void *data, void *image, const void *target) } static void -eng_image_data_preload_cancel(void *data, void *image) +eng_image_data_preload_cancel(void *data, void *image, const void *target) { Soft16_Image *im = image; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void diff --git a/src/modules/engines/software_16_sdl/evas_engine.c b/src/modules/engines/software_16_sdl/evas_engine.c index b6e03f5..4b8a670 100644 --- a/src/modules/engines/software_16_sdl/evas_engine.c +++ b/src/modules/engines/software_16_sdl/evas_engine.c @@ -742,7 +742,7 @@ evas_engine_sdl16_image_data_preload_request(void *data, void *image, const void } static void -evas_engine_sdl16_image_data_preload_cancel(void *data, void *image) +evas_engine_sdl16_image_data_preload_cancel(void *data, void *image, const void *target) { SDL_Engine_Image_Entry *eim = image; Soft16_Image *im; @@ -750,7 +750,7 @@ evas_engine_sdl16_image_data_preload_cancel(void *data, void *image) if (!eim) return ; im = (Soft16_Image *) eim->cache_entry.src; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void* diff --git a/src/modules/engines/software_generic/evas_engine.c b/src/modules/engines/software_generic/evas_engine.c index 1435b31..06663a7 100644 --- a/src/modules/engines/software_generic/evas_engine.c +++ b/src/modules/engines/software_generic/evas_engine.c @@ -723,12 +723,12 @@ eng_image_data_preload_request(void *data, void *image, const void *target) } static void -eng_image_data_preload_cancel(void *data, void *image) +eng_image_data_preload_cancel(void *data, void *image, const void *target) { RGBA_Image *im = image; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void diff --git a/src/modules/engines/software_sdl/evas_engine.c b/src/modules/engines/software_sdl/evas_engine.c index aa4712d..5fb2e1c 100644 --- a/src/modules/engines/software_sdl/evas_engine.c +++ b/src/modules/engines/software_sdl/evas_engine.c @@ -515,7 +515,7 @@ evas_engine_sdl_image_data_preload_request(void *data, void *image, const void * } static void -evas_engine_sdl_image_data_preload_cancel(void *data, void *image) +evas_engine_sdl_image_data_preload_cancel(void *data, void *image, const void *target) { SDL_Engine_Image_Entry *eim = image; RGBA_Image *im; @@ -523,7 +523,7 @@ evas_engine_sdl_image_data_preload_cancel(void *data, void *image) if (!eim) return ; im = (RGBA_Image*) eim->cache_entry.src; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void* diff --git a/src/modules/engines/xrender_x11/evas_engine.c b/src/modules/engines/xrender_x11/evas_engine.c index 06c6197..c40de6d 100644 --- a/src/modules/engines/xrender_x11/evas_engine.c +++ b/src/modules/engines/xrender_x11/evas_engine.c @@ -915,7 +915,7 @@ eng_image_data_preload_request(void *data, void *image, const void *target) } static void -eng_image_data_preload_cancel(void *data, void *image) +eng_image_data_preload_cancel(void *data, void *image, const void *target) { XR_Image *xim = image; RGBA_Image *im; @@ -923,7 +923,7 @@ eng_image_data_preload_cancel(void *data, void *image) if (!xim) return ; im = (RGBA_Image*) xim->im; if (!im) return ; - evas_cache_image_preload_cancel(&im->cache_entry); + evas_cache_image_preload_cancel(&im->cache_entry, target); } static void