also be able to free orig data now (and reload)

SVN revision: 39743
This commit is contained in:
Carsten Haitzler 2009-03-27 06:06:45 +00:00
parent e0a8a97b6d
commit 66cc98b0f4
5 changed files with 103 additions and 49 deletions

View File

@ -6,6 +6,7 @@ EAPI void evas_common_image_init (void);
EAPI void evas_common_image_shutdown (void);
EAPI void evas_common_rgba_image_free (Image_Entry *ie);
EAPI void evas_common_rgba_image_unload (Image_Entry *ie);
EAPI void evas_common_image_colorspace_normalize (RGBA_Image *im);
EAPI void evas_common_image_colorspace_dirty (RGBA_Image *im);
EAPI void evas_common_image_cache_free (void); /*2*/

View File

@ -109,8 +109,8 @@ evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
if (!evas_image_load_func->file_data(ie, ie->file, ie->key))
return -1;
evas_module_unref((Evas_Module*) ie->info.module);
ie->info.module = NULL;
// evas_module_unref((Evas_Module*) ie->info.module);
// ie->info.module = NULL;
return 0;
}

View File

@ -162,6 +162,38 @@ evas_common_rgba_image_free(Image_Entry *ie)
_evas_common_rgba_image_delete(ie);
}
EAPI void
evas_common_rgba_image_unload(Image_Entry *ie)
{
RGBA_Image *im = (RGBA_Image *) ie;
evas_cache_image_preload_cancel(ie, NULL);
if (!ie->flags.loaded) return;
if (!ie->info.module) return;
if (!ie->file) return;
ie->flags.loaded = 0;
if ((im->cs.data) && (im->image.data))
{
if (im->cs.data != im->image.data)
{
if (!im->cs.no_free) free(im->cs.data);
}
}
else if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
}
im->cs.data = NULL;
if (im->image.data && !im->image.no_free)
free(im->image.data);
im->image.data = NULL;
ie->allocated.w = 0;
ie->allocated.h = 0;
}
static int
_evas_common_rgba_image_surface_alloc(Image_Entry *ie, int w, int h)
{

View File

@ -264,6 +264,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst,
#ifdef SCALECACHE
RGBA_Image *im = (RGBA_Image *)ie;
Scaleitem *sci;
if (!im->image.data) return;
if ((dst_region_w == 0) || (dst_region_h == 0) ||
(src_region_w == 0) || (src_region_h == 0)) return;
LKL(im->cache.lock);
@ -350,19 +351,25 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
LKL(im->cache.lock);
if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h))
{
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im);
noscales++;
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
}
LKU(im->cache.lock);
return;
}
@ -395,21 +402,24 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im);
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth
(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample
(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
sci->populate_me = 0;
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth
(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample
(im, sci->im, ct,
src_region_x, src_region_y,
src_region_w, src_region_h,
0, 0,
dst_region_w, dst_region_h);
sci->populate_me = 0;
}
cache_size += sci->dst_w * sci->dst_h * 4;
// printf(" + %i @ flop: %i (%ix%i)\n",
// sci->dst_w * sci->dst_h * 4, sci->flop,
@ -442,17 +452,42 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
// im,
// (int)im->cache.orig_usage,
// (int)im->cache.newest_usage);
if (im->cache.orig_usage <
(im->cache.newest_usage / 20))
if ((im->cache_entry.flags.loaded) && (!im->cs.no_free) &&
(im->cache_entry.space == EVAS_COLORSPACE_ARGB8888))
{
// printf("nuke orig %s\n", im->cache_entry.file);
if (im->cache.orig_usage <
(im->cache.newest_usage / 20))
evas_common_rgba_image_unload(&im->cache_entry);
}
LKU(im->cache.lock);
}
else
{
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im);
misses++;
LKU(im->cache.lock);
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
}
}
#else
RGBA_Image *im = (RGBA_Image *)ie;
if (im->image.data)
{
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
src_region_x, src_region_y,
@ -466,20 +501,6 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
}
#else
RGBA_Image *im = (RGBA_Image *)ie;
if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
else
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc,
src_region_x, src_region_y,
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
#endif
}

View File

@ -754,9 +754,9 @@ eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
else
#endif
{
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im);
// if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
// evas_cache_image_load_data(&im->cache_entry);
// evas_common_image_colorspace_normalize(im);
evas_common_rgba_image_scalecache_prepare(im, surface, context, smooth,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);