add unload callback - missing event problem that makes it impossible

for client apps that tried to be efficient with preloads to adapt
when the preloaded data is taken away from them. this allows it.
missing callback api bug fix.



SVN revision: 55745
This commit is contained in:
Carsten Haitzler 2010-12-24 16:04:27 +00:00
parent 6481adfb2b
commit 19d4f8affc
7 changed files with 35 additions and 6 deletions

View File

@ -102,20 +102,22 @@ typedef enum _Evas_Callback_Type
EVAS_CALLBACK_CHANGED_SIZE_HINTS, /**< Size hints changed event */
EVAS_CALLBACK_IMAGE_PRELOADED, /**< Image as been preloaded */
/*
* The following events are only for use with canvas
* evas_event_callback_add():
*/
EVAS_CALLBACK_CANVAS_FOCUS_IN, /**< Canvas got focus as a whole */
EVAS_CALLBACK_CANVAS_FOCUS_OUT, /**< Canvas lost focus as a whole */
EVAS_CALLBACK_RENDER_FLUSH_PRE, /**< Called just before rendering is updated on the canvas target */
EVAS_CALLBACK_RENDER_FLUSH_POST, /**< Called just after rendering is updated on the canvas target */
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, /**< Canvas object got focus */
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, /**< Canvas object lost focus */
/*
* More object event types - see evas_object_event_callback_add():
*/
EVAS_CALLBACK_IMAGE_UNLOADED, /**< Image data has been unloaded (by some mechanims in evas that throws out original image data) */
/* the following id no event number, but a sentinel: */
EVAS_CALLBACK_LAST /**< keep as last element/sentinel -- not really an event */
} Evas_Callback_Type; /**< The type of event to trigger the callback */

View File

@ -1443,6 +1443,7 @@ evas_cache_image_unload_data(Image_Entry *im)
#ifdef BUILD_ASYNC_PRELOAD
LKU(im->lock);
#endif
//FIXME: imagedataunload - inform owners
}
static Eina_Bool

View File

@ -1340,6 +1340,7 @@ evas_object_image_reload(Evas_Object *obj)
if (o->engine_data)
o->engine_data = obj->layer->evas->engine.func->image_dirty_region(obj->layer->evas->engine.data.output, o->engine_data, 0, 0, o->cur.image.w, o->cur.image.h);
evas_object_image_unload(obj, 1);
evas_object_inform_call_image_unloaded(obj);
evas_object_image_load(obj);
o->prev.file = NULL;
o->prev.key = NULL;
@ -1623,6 +1624,7 @@ evas_object_image_load_dpi_set(Evas_Object *obj, double dpi)
if (o->cur.file)
{
evas_object_image_unload(obj, 0);
evas_object_inform_call_image_unloaded(obj);
evas_object_image_load(obj);
o->changed = 1;
evas_object_change(obj);
@ -1681,6 +1683,7 @@ evas_object_image_load_size_set(Evas_Object *obj, int w, int h)
if (o->cur.file)
{
evas_object_image_unload(obj, 0);
evas_object_inform_call_image_unloaded(obj);
evas_object_image_load(obj);
o->changed = 1;
evas_object_change(obj);
@ -1739,6 +1742,7 @@ evas_object_image_load_scale_down_set(Evas_Object *obj, int scale_down)
if (o->cur.file)
{
evas_object_image_unload(obj, 0);
evas_object_inform_call_image_unloaded(obj);
evas_object_image_load(obj);
o->changed = 1;
evas_object_change(obj);
@ -1789,6 +1793,7 @@ evas_object_image_load_region_set(Evas_Object *obj, int x, int y, int w, int h)
if (o->cur.file)
{
evas_object_image_unload(obj, 0);
evas_object_inform_call_image_unloaded(obj);
evas_object_image_load(obj);
o->changed = 1;
evas_object_change(obj);
@ -2124,6 +2129,7 @@ evas_image_cache_reload(Evas *e)
if (o->magic == MAGIC_OBJ_IMAGE)
{
evas_object_image_unload(obj, 1);
evas_object_inform_call_image_unloaded(obj);
}
}
}
@ -2211,8 +2217,13 @@ evas_object_image_unload(Evas_Object *obj, Eina_Bool dirty)
o->cur.image.w, o->cur.image.h);
}
if (o->engine_data)
obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
o->engine_data);
{
obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
o->engine_data,
obj);
obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
o->engine_data);
}
o->engine_data = NULL;
o->load_error = EVAS_LOAD_ERROR_NONE;
o->cur.has_alpha = 1;

View File

@ -65,3 +65,12 @@ evas_object_inform_call_image_preloaded(Evas_Object *obj)
evas_object_event_callback_call(obj, EVAS_CALLBACK_IMAGE_PRELOADED, NULL);
_evas_post_event_callback_call(obj->layer->evas);
}
void
evas_object_inform_call_image_unloaded(Evas_Object *obj)
{
_evas_object_event_new();
evas_object_event_callback_call(obj, EVAS_CALLBACK_IMAGE_UNLOADED, NULL);
_evas_post_event_callback_call(obj->layer->evas);
}

View File

@ -1558,7 +1558,11 @@ evas_render_dump(Evas *e)
Evas_Object *obj;
EINA_INLIST_FOREACH(lay->objects, obj)
_evas_render_dump_map_surfaces(obj);
{
if ((obj->type) && (!strcmp(obj->type, "image")))
evas_object_inform_call_image_unloaded(obj);
_evas_render_dump_map_surfaces(obj);
}
}
if ((e->engine.func) && (e->engine.func->output_dump) &&
(e->engine.data.output))

View File

@ -743,6 +743,7 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if ((dounload) || (im->cache.orig_usage <
(im->cache.newest_usage / 20)))
{
//FIXME: imagedataunload - inform owners
evas_common_rgba_image_unload(&im->cache_entry);
}
}

View File

@ -756,6 +756,7 @@ void evas_object_inform_call_resize(Evas_Object *obj);
void evas_object_inform_call_restack(Evas_Object *obj);
void evas_object_inform_call_changed_size_hints(Evas_Object *obj);
void evas_object_inform_call_image_preloaded(Evas_Object *obj);
void evas_object_inform_call_image_unloaded(Evas_Object *obj);
void evas_object_intercept_cleanup(Evas_Object *obj);
int evas_object_intercept_call_show(Evas_Object *obj);
int evas_object_intercept_call_hide(Evas_Object *obj);