fix load of data to ACTUALLY set the load error in evas's image

objects. including preload.



SVN revision: 59529
This commit is contained in:
Carsten Haitzler 2011-05-19 11:19:22 +00:00
parent 359e67f68a
commit 4dd1d5cf62
14 changed files with 137 additions and 35 deletions

View File

@ -130,7 +130,7 @@ EAPI void evas_cache_image_set(Evas_Cache_Image *cache, unsi
EAPI Image_Entry* evas_cache_image_alone(Image_Entry *im);
EAPI Image_Entry* evas_cache_image_dirty(Image_Entry *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
EAPI void evas_cache_image_load_data(Image_Entry *im);
EAPI int evas_cache_image_load_data(Image_Entry *im);
EAPI void evas_cache_image_unload_data(Image_Entry *im);
EAPI Eina_Bool evas_cache_image_is_loaded(Image_Entry *im);
EAPI void evas_cache_image_unload_all(Evas_Cache_Image *cache);

View File

@ -378,13 +378,17 @@ _evas_cache_image_async_heavy(void *data)
{
error = cache->func.load(current);
if (cache->func.debug) cache->func.debug("load", current);
current->load_error = error;
if (error != EVAS_LOAD_ERROR_NONE)
{
current->flags.loaded = 0;
_evas_cache_image_entry_surface_alloc(cache, current,
current->w, current->h);
}
else current->flags.loaded = 1;
else
{
current->flags.loaded = 1;
}
}
current->channel = pchannel;
// check the unload cancel flag
@ -1142,15 +1146,15 @@ evas_cache_image_size_set(Image_Entry *im, unsigned int w, unsigned int h)
return NULL;
}
EAPI void
EAPI int
evas_cache_image_load_data(Image_Entry *im)
{
#ifdef BUILD_ASYNC_PRELOAD
Eina_Bool preload = EINA_FALSE;
#endif
int error;
int error = EVAS_LOAD_ERROR_NONE;
if (im->flags.loaded) return;
if (im->flags.loaded) return error;
#ifdef BUILD_ASYNC_PRELOAD
if (im->preload)
{
@ -1174,7 +1178,7 @@ evas_cache_image_load_data(Image_Entry *im)
LKU(wakeup);
}
if (im->flags.loaded) return;
if (im->flags.loaded) return error;
LKL(im->lock);
#endif
im->flags.in_progress = EINA_TRUE;
@ -1193,6 +1197,7 @@ evas_cache_image_load_data(Image_Entry *im)
#ifdef BUILD_ASYNC_PRELOAD
if (preload) _evas_cache_image_async_end(im);
#endif
return error;
}
EAPI void

View File

@ -831,7 +831,8 @@ evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace)
o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
o->engine_data,
0,
&data);
&data,
&o->load_error);
return evas_object_image_data_convert_internal(o, data, to_cspace);
}
@ -951,7 +952,8 @@ evas_object_image_data_get(const Evas_Object *obj, Eina_Bool for_writing)
o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
o->engine_data,
for_writing,
&data);
&data,
&o->load_error);
if (o->engine_data)
{
int stride = 0;
@ -1250,7 +1252,8 @@ evas_object_image_save(const Evas_Object *obj, const char *file, const char *key
o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
o->engine_data,
0,
&data);
&data,
&o->load_error);
if (flags)
{
char *p, *pp;
@ -1330,7 +1333,8 @@ evas_object_image_pixels_import(Evas_Object *obj, Evas_Pixel_Import_Source *pixe
obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
o->engine_data,
1,
&image_pixels);
&image_pixels,
&o->load_error);
/* FIXME: need to actualyl support this */
/* memcpy(image_pixels, pixels->rows, o->cur.image.w * o->cur.image.h * 4);*/
if (o->engine_data)
@ -1360,7 +1364,8 @@ evas_object_image_pixels_import(Evas_Object *obj, Evas_Pixel_Import_Source *pixe
obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
o->engine_data,
1,
&image_pixels);
&image_pixels,
&o->load_error);
if (image_pixels)
evas_common_convert_yuv_420p_601_rgba((DATA8 **) pixels->rows,
(DATA8 *) image_pixels,
@ -3304,7 +3309,8 @@ evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
(obj->layer->evas->engine.data.output,
o->engine_data,
0,
&data);
&data,
&o->load_error);
if (!data)
return 0;
@ -3442,4 +3448,13 @@ _evas_object_image_preloading_set(Evas_Object *obj, Eina_Bool preloading)
o->preloading = preloading;
}
void
_evas_object_image_preloading_check(Evas_Object *obj)
{
Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
if (obj->layer->evas->engine.func->image_load_error_get)
o->load_error = obj->layer->evas->engine.func->image_load_error_get
(obj->layer->evas->engine.data.output, o->engine_data);
}
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/

View File

@ -61,6 +61,7 @@ void
evas_object_inform_call_image_preloaded(Evas_Object *obj)
{
if (!_evas_object_image_preloading_get(obj)) return;
_evas_object_image_preloading_check(obj);
_evas_object_image_preloading_set(obj, 0);
_evas_object_event_new();

View File

@ -588,6 +588,7 @@ struct _Image_Entry
int server_id;
int connect_num;
int channel;
int load_error;
};
struct _Engine_Image_Entry

View File

@ -655,7 +655,7 @@ struct _Evas_Func
void *(*image_size_set) (void *data, void *image, int w, int h);
void (*image_stride_get) (void *data, void *image, int *stride);
void *(*image_dirty_region) (void *data, void *image, int x, int y, int w, int h);
void *(*image_data_get) (void *data, void *image, int to_write, DATA32 **image_data);
void *(*image_data_get) (void *data, void *image, int to_write, DATA32 **image_data, int *err);
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, const void *target);
@ -732,6 +732,7 @@ struct _Evas_Func
void *(*gl_proc_address_get) (void *data, const char *name);
int (*gl_native_surface_get) (void *data, void *surface, void *native_surface);
void *(*gl_api_get) (void *data);
int (*image_load_error_get) (void *data, void *image);
};
struct _Evas_Image_Load_Func
@ -800,6 +801,7 @@ const Evas_Smart_Cb_Description *evas_smart_cb_description_find(const Evas_Smart
Eina_Bool _evas_object_image_preloading_get(const Evas_Object *obj);
void _evas_object_image_preloading_set(Evas_Object *obj, Eina_Bool preloading);
void _evas_object_image_preloading_check(Evas_Object *obj);
void evas_object_smart_del(Evas_Object *obj);
void evas_object_smart_cleanup(Evas_Object *obj);
void evas_object_smart_member_raise(Evas_Object *member);

View File

@ -321,10 +321,11 @@ 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)
eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
{
Render_Engine *re = (Render_Engine *)data;
evas_direct3d_image_data_get(re->d3d, image, to_write, image_data);
if (err) *err = EVAS_LOAD_ERROR_NONE;
return image;
}

View File

@ -637,24 +637,27 @@ 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)
eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
{
Render_Engine *re;
Evas_GL_Image *im;
int error;
re = (Render_Engine *)data;
if (!image)
{
*image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_GENERIC;
return NULL;
}
im = image;
if (im->native.data)
{
*image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_NONE;
return im;
}
evas_cache_image_load_data(&im->im->cache_entry);
error = evas_cache_image_load_data(&im->im->cache_entry);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
@ -670,7 +673,8 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
if (!im_new)
{
*image_data = NULL;
return im;
if (err) *err = error;
return im;
}
evas_gl_common_image_free(im);
im = im_new;
@ -688,6 +692,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
abort();
break;
}
if (err) *err = error;
return im;
}
@ -853,6 +858,17 @@ eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
return EINA_FALSE;
}
static int
eng_image_load_error_get(void *data __UNUSED__, void *image)
{
Evas_GL_Image *im;
if (!image) return EVAS_LOAD_ERROR_NONE;
im = image;
return im->im->cache_entry.load_error;
}
static int
module_open(Evas_Module *em)
{
@ -917,6 +933,10 @@ module_open(Evas_Module *em)
ORD(image_colorspace_get);
ORD(image_native_set);
ORD(image_native_get);
// ORD(image_draw_filtered);
// ORD(image_filtered_get);
// ORD(image_filtered_save);
// ORD(image_filtered_free);
ORD(font_draw);
ORD(image_scale_hint_set);
@ -925,6 +945,25 @@ module_open(Evas_Module *em)
ORD(image_map_draw);
ORD(image_map_surface_new);
ORD(image_map_surface_free);
// ORD(image_content_hint_set);
// ORD(image_content_hint_get);
// ORD(image_cache_flush);
// ORD(image_cache_set);
// ORD(image_cache_get);
// ORD(gl_surface_create);
// ORD(gl_surface_destroy);
// ORD(gl_context_create);
// ORD(gl_context_destroy);
// ORD(gl_make_current);
// ORD(gl_proc_address_get);
// ORD(gl_native_surface_get);
// ORD(gl_api_get);
ORD(image_load_error_get);
/* now advertise out own api */
em->functions = (void *)(&func);

View File

@ -1735,30 +1735,34 @@ 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)
eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
{
Render_Engine *re;
Evas_GL_Image *im;
int error;
re = (Render_Engine *)data;
if (!image)
{
*image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_GENERIC;
return NULL;
}
im = image;
if (im->native.data)
{
*image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_NONE;
return im;
}
if ((im->tex) && (im->tex->pt) && (im->tex->pt->dyn.data))
{
*image_data = im->tex->pt->dyn.data;
if (err) *err = EVAS_LOAD_ERROR_NONE;
return im;
}
eng_window_use(re->win);
evas_cache_image_load_data(&im->im->cache_entry);
error = evas_cache_image_load_data(&im->im->cache_entry);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
@ -1776,6 +1780,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
if (!im_new)
{
*image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
return im;
}
evas_gl_common_image_free(im);
@ -1794,6 +1799,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
abort();
break;
}
if (err) *err = error;
return im;
}
@ -2513,7 +2519,7 @@ eng_gl_make_current(void *data, void *surface, void *context)
Render_Engine *re;
Render_Engine_GL_Surface *sfc;
Render_Engine_GL_Context *ctx;
int ret;
int ret = 0;
re = (Render_Engine *)data;
sfc = (Render_Engine_GL_Surface*)surface;
@ -2893,6 +2899,15 @@ eng_gl_api_get(void *data)
return &gl_funcs;
}
static int
eng_image_load_error_get(void *data __UNUSED__, void *image)
{
Evas_GL_Image *im;
if (!image) return EVAS_LOAD_ERROR_NONE;
im = image;
return im->im->cache_entry.load_error;
}
static int
module_open(Evas_Module *em)
@ -2998,6 +3013,8 @@ module_open(Evas_Module *em)
ORD(gl_api_get);
ORD(image_load_error_get);
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;

View File

@ -191,9 +191,10 @@ eng_image_dirty_region(void *data __UNUSED__, void *image, int x __UNUSED__, int
}
static void *
eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data)
eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
{
Soft16_Image *im;
int error;
if (!image)
{
@ -202,13 +203,14 @@ eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **im
}
im = image;
evas_cache_image_load_data(&im->cache_entry);
error = evas_cache_image_load_data(&im->cache_entry);
if (to_write)
im = (Soft16_Image *) evas_cache_image_alone(&im->cache_entry);
if (image_data) *image_data = (DATA32 *) im->pixels;
if (err) *err = error;
return im;
}

View File

@ -666,18 +666,19 @@ evas_engine_sdl16_image_dirty_region(void *data __UNUSED__,
static void*
evas_engine_sdl16_image_data_get(void *data __UNUSED__, void *image,
int to_write, DATA32** image_data)
int to_write, DATA32** image_data, int *err)
{
SDL_Engine_Image_Entry *eim = image;
Soft16_Image *im;
int error;
if (!eim)
{
*image_data = NULL;
return NULL;
}
im = (Soft16_Image *) eim->cache_entry.src;
evas_cache_image_load_data(&im->cache_entry);
error = evas_cache_image_load_data(&im->cache_entry);
if (to_write)
eim = (SDL_Engine_Image_Entry *) evas_cache_engine_image_alone(&eim->cache_entry,
@ -686,6 +687,7 @@ evas_engine_sdl16_image_data_get(void *data __UNUSED__, void *image,
/* FIXME: Handle colorspace conversion correctly. */
if (image_data) *image_data = (DATA32 *) im->pixels;
if (err) *err = error;
return eim;
}

View File

@ -225,9 +225,10 @@ eng_image_dirty_region(void *data __UNUSED__, void *image __UNUSED__,
static void *
eng_image_data_get(void *data __UNUSED__, void *image, int to_write,
DATA32 ** image_data)
DATA32 ** image_data, int *err)
{
Soft8_Image *im;
int error;
if (!image)
{
@ -236,7 +237,7 @@ eng_image_data_get(void *data __UNUSED__, void *image, int to_write,
}
im = image;
evas_cache_image_load_data(&im->cache_entry);
error = evas_cache_image_load_data(&im->cache_entry);
if (to_write)
im = (Soft8_Image *) evas_cache_image_alone(&im->cache_entry);
@ -244,6 +245,7 @@ eng_image_data_get(void *data __UNUSED__, void *image, int to_write,
if (image_data)
*image_data = (DATA32 *) im->pixels;
if (err) *err = error;
return im;
}

View File

@ -277,6 +277,7 @@ eng_image_mask_create(void *data __UNUSED__, void *image)
if (!im->image.data)
evas_cache_image_load_data(&im->cache_entry);
src = im->image.data;
if (!src) return;
for (end = dst + sz ; dst < end ; dst ++, src ++)
*dst = *src >> 24;
im->mask.dirty = 0;
@ -411,9 +412,10 @@ eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w,
}
static void *
eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data)
eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
{
RGBA_Image *im;
int error;
if (!image)
{
@ -421,12 +423,12 @@ eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **im
return NULL;
}
im = image;
evas_cache_image_load_data(&im->cache_entry);
error = evas_cache_image_load_data(&im->cache_entry);
switch (im->cache_entry.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (to_write)
im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
im = (RGBA_Image *)evas_cache_image_alone(&im->cache_entry);
*image_data = im->image.data;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
@ -437,6 +439,7 @@ eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **im
abort();
break;
}
if (err) *err = error;
return im;
}
@ -868,7 +871,6 @@ eng_image_draw_filtered(void *data __UNUSED__, void *context __UNUSED__,
if (!fn) return;
if (im->cache_entry.cache) evas_cache_image_load_data(&im->cache_entry);
fn(filter, image, surface);
return;
}
@ -937,6 +939,16 @@ eng_image_filtered_free(void *image, Filtered_Image *fi)
im->filtered = eina_list_remove(im->filtered, fi);
}
static int
eng_image_load_error_get(void *data, void *image)
{
RGBA_Image *im;
if (!image) return EVAS_LOAD_ERROR_NONE;
im = image;
return im->cache_entry.load_error;
}
/*
*****
**
@ -1067,8 +1079,9 @@ static Evas_Func func =
NULL, // FIXME: need software mesa for gl rendering <- gl_context_destroy
NULL, // FIXME: need software mesa for gl rendering <- gl_make_current
NULL, // FIXME: need software mesa for gl rendering <- gl_proc_address_get
NULL, // FIXME: need software mesa for gl rendering <- gl_native_surface_get
NULL // FIXME: need software mesa for gl rendering <- gl_api_get
NULL, // FIXME: need software mesa for gl rendering <- gl_native_surface_get
NULL, // FIXME: need software mesa for gl rendering <- gl_api_get
eng_image_load_error_get
/* FUTURE software generic calls go here */
};

View File

@ -425,7 +425,7 @@ evas_engine_sdl_image_dirty_region(void *data,
static void*
evas_engine_sdl_image_data_get(void *data, void *image,
int to_write, DATA32** image_data)
int to_write, DATA32** image_data, int *err)
{
SDL_Engine_Image_Entry *eim = image;
RGBA_Image *im;
@ -435,6 +435,7 @@ evas_engine_sdl_image_data_get(void *data, void *image,
if (!eim)
{
*image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_GENERIC;
return NULL;
}
im = (RGBA_Image *) eim->cache_entry.src;
@ -456,6 +457,7 @@ evas_engine_sdl_image_data_get(void *data, void *image,
abort();
break;
}
if (err) *err = EVAS_LOAD_ERROR_NONE;
return eim;
}