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_image_shutdown (void);
EAPI void evas_common_rgba_image_free (Image_Entry *ie); 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_normalize (RGBA_Image *im);
EAPI void evas_common_image_colorspace_dirty (RGBA_Image *im); EAPI void evas_common_image_colorspace_dirty (RGBA_Image *im);
EAPI void evas_common_image_cache_free (void); /*2*/ 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)) if (!evas_image_load_func->file_data(ie, ie->file, ie->key))
return -1; return -1;
evas_module_unref((Evas_Module*) ie->info.module); // evas_module_unref((Evas_Module*) ie->info.module);
ie->info.module = NULL; // ie->info.module = NULL;
return 0; return 0;
} }

View File

@ -162,6 +162,38 @@ evas_common_rgba_image_free(Image_Entry *ie)
_evas_common_rgba_image_delete(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 static int
_evas_common_rgba_image_surface_alloc(Image_Entry *ie, int w, int h) _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 #ifdef SCALECACHE
RGBA_Image *im = (RGBA_Image *)ie; RGBA_Image *im = (RGBA_Image *)ie;
Scaleitem *sci; Scaleitem *sci;
if (!im->image.data) return;
if ((dst_region_w == 0) || (dst_region_h == 0) || if ((dst_region_w == 0) || (dst_region_h == 0) ||
(src_region_w == 0) || (src_region_h == 0)) return; (src_region_w == 0) || (src_region_h == 0)) return;
LKL(im->cache.lock); LKL(im->cache.lock);
@ -350,19 +351,25 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
LKL(im->cache.lock); LKL(im->cache.lock);
if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h)) 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++; noscales++;
if (smooth) if (im->image.data)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc, {
src_region_x, src_region_y, if (smooth)
src_region_w, src_region_h, evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
dst_region_x, dst_region_y, src_region_x, src_region_y,
dst_region_w, dst_region_h); src_region_w, src_region_h,
else dst_region_x, dst_region_y,
evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc, dst_region_w, dst_region_h);
src_region_x, src_region_y, else
src_region_w, src_region_h, evas_common_scale_rgba_in_to_out_clip_sample(im, dst, dc,
dst_region_x, dst_region_y, src_region_x, src_region_y,
dst_region_w, dst_region_h); src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
}
LKU(im->cache.lock); LKU(im->cache.lock);
return; 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) if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry); evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im); evas_common_image_colorspace_normalize(im);
if (smooth) if (im->image.data)
evas_common_scale_rgba_in_to_out_clip_smooth {
(im, sci->im, ct, if (smooth)
src_region_x, src_region_y, evas_common_scale_rgba_in_to_out_clip_smooth
src_region_w, src_region_h, (im, sci->im, ct,
0, 0, src_region_x, src_region_y,
dst_region_w, dst_region_h); src_region_w, src_region_h,
else 0, 0,
evas_common_scale_rgba_in_to_out_clip_sample dst_region_w, dst_region_h);
(im, sci->im, ct, else
src_region_x, src_region_y, evas_common_scale_rgba_in_to_out_clip_sample
src_region_w, src_region_h, (im, sci->im, ct,
0, 0, src_region_x, src_region_y,
dst_region_w, dst_region_h); src_region_w, src_region_h,
sci->populate_me = 0; 0, 0,
dst_region_w, dst_region_h);
sci->populate_me = 0;
}
cache_size += sci->dst_w * sci->dst_h * 4; cache_size += sci->dst_w * sci->dst_h * 4;
// printf(" + %i @ flop: %i (%ix%i)\n", // printf(" + %i @ flop: %i (%ix%i)\n",
// sci->dst_w * sci->dst_h * 4, sci->flop, // 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, // im,
// (int)im->cache.orig_usage, // (int)im->cache.orig_usage,
// (int)im->cache.newest_usage); // (int)im->cache.newest_usage);
if (im->cache.orig_usage < if ((im->cache_entry.flags.loaded) && (!im->cs.no_free) &&
(im->cache.newest_usage / 20)) (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); LKU(im->cache.lock);
} }
else else
{ {
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im);
misses++; misses++;
LKU(im->cache.lock); 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) if (smooth)
evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc, evas_common_scale_rgba_in_to_out_clip_smooth(im, dst, dc,
src_region_x, src_region_y, 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_x, dst_region_y,
dst_region_w, dst_region_h); 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 #endif
} }

View File

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