#define MIN_SCALE_USES 3
#define MIN_SCALE_AGE_GAP 5000
#define MIN_SCALECACHE_SIZE 3200
+#define FLOP_ADD 4
+#define MAX_FLOP_COUNT 16
+#define FLOP_DEL 1
+#define SCALE_CACHE_SIZE 4 * 1024 * 1024
typedef struct _Scaleitem Scaleitem;
#endif
static Eina_Inlist *cache_list = NULL;
static int cache_size = 0;
-static int max_cache_size = 4 * 1024 * 1024;
+static int max_cache_size = SCALE_CACHE_SIZE;
#endif
void
}
#ifdef SCALECACHE
+static void
+_sci_fix_newest(RGBA_Image *im)
+{
+ Eina_List *l;
+ Scaleitem *sci;
+
+ im->cache.newest_usage = 0;
+ im->cache.newest_usage_count = 0;
+ EINA_LIST_FOREACH(im->cache.list, l, sci)
+ {
+ if (sci->usage > im->cache.newest_usage)
+ im->cache.newest_usage = sci->usage;
+ if (sci->usage_count > im->cache.newest_usage_count)
+ im->cache.newest_usage_count = sci->usage_count;
+ }
+// printf("_sci_fix_newest! -> %i\n", im->cache.newest_usage);
+}
+
static Scaleitem *
_sci_find(RGBA_Image *im,
RGBA_Draw_Context *dc, int smooth,
l = eina_list_last(im->cache.list);
sci = l->data;
im->cache.list = eina_list_remove_list(im->cache.list, l);
+ if ((sci->usage == im->cache.newest_usage) ||
+ (sci->usage_count == im->cache.newest_usage_count))
+ _sci_fix_newest(im);
if (sci->im)
{
evas_common_rgba_image_free(&sci->im->cache_entry);
evas_common_rgba_image_free(&sci->im->cache_entry);
sci->im = NULL;
sci->usage = 0;
- sci->flop += 4;
+ sci->usage_count = 0;
+ sci->flop += FLOP_ADD;
cache_size -= sci->dst_w * sci->dst_h * 4;
// printf(" 2- %i\n", sci->dst_w * sci->dst_h * 4);
cache_list = eina_inlist_remove(cache_list, (Eina_Inlist *)sci);
// src_region_x, src_region_y, src_region_w, src_region_h,
// dst_region_x, dst_region_y, dst_region_w, dst_region_h,
// smooth);
- if ((sci->usage >= MIN_SCALE_USES) &&
- (sci->usage_count > (use_counter - MIN_SCALE_AGE_GAP)))
+ if ((sci->usage >= MIN_SCALE_USES)
+// && (sci->usage_count > (use_counter - MIN_SCALE_AGE_GAP))
+ )
{
if (!sci->im)
{
if ((sci->dst_w < MIN_SCALECACHE_SIZE) &&
(sci->dst_h < MIN_SCALECACHE_SIZE))
{
- if (sci->flop <= 16)
+ if (sci->flop <= MAX_FLOP_COUNT)
{
sci->populate_me = 1;
im->cache.populate_count++;
}
sci->usage++;
sci->usage_count = use_counter;
+ if (sci->usage > im->cache.newest_usage)
+ im->cache.newest_usage = sci->usage;
+// printf("newset? %p %i > %i\n", im,
+// (int)sci->usage,
+// (int)im->cache.newest_usage);
+ if (sci->usage_count > im->cache.newest_usage_count)
+ im->cache.newest_usage_count = sci->usage_count;
// printf(" -------------- used %8i#, %8i@\n", (int)sci->usage, (int)sci->usage_count);
LKU(im->cache.lock);
#endif
*/
if ((dst_region_w == 0) || (dst_region_h == 0) ||
(src_region_w == 0) || (src_region_h == 0)) return;
+ LKL(im->cache.lock);
if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h))
{
noscales++;
src_region_w, src_region_h,
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
+ LKU(im->cache.lock);
return;
}
- LKL(im->cache.lock);
sci = _sci_find(im, dc, smooth,
src_region_x, src_region_y, src_region_w, src_region_h,
dst_region_w, dst_region_h);
{
static RGBA_Draw_Context *ct = NULL;
+ im->cache.orig_usage++;
+ im->cache.usage_count = use_counter;
im->cache.populate_count--;
pops++;
if (!ct)
ct = evas_common_draw_context_new();
evas_common_draw_context_set_render_op(ct, _EVAS_RENDER_COPY);
}
+ 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,
}
else
{
- if (sci->flop > 0) sci->flop--;
+ if (sci->flop > 0) sci->flop -= FLOP_DEL;
}
// printf("use cached!\n");
evas_common_scale_rgba_in_to_out_clip_sample
dst_region_x, dst_region_y,
dst_region_w, dst_region_h);
hits++;
+// printf("check %p %i < %i\n",
+// im,
+// (int)im->cache.orig_usage,
+// (int)im->cache.newest_usage);
+ if (im->cache.orig_usage <
+ (im->cache.newest_usage / 20))
+ {
+// printf("nuke orig %s\n", im->cache_entry.file);
+ }
LKU(im->cache.lock);
}
else
#endif
}
+#if 0
// to be done
void
evas_common_rgba_image_scalecache_XXX(Image_Entry *ie)
LKU(im->cache.lock);
#endif
}
-
+#endif
if (!image) return;
im = image;
- 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);
-
#ifdef BUILD_PIPE_RENDER
if (cpunum > 1)
- evas_common_pipe_image_draw(im, surface, context, smooth,
- src_x, src_y, src_w, src_h,
- dst_x, dst_y, dst_w, dst_h);
+ {
+ 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);
+
+ evas_common_pipe_image_draw(im, surface, context, smooth,
+ src_x, src_y, src_w, src_h,
+ dst_x, dst_y, dst_w, dst_h);
+ }
else
#endif
{
+ 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);
evas_common_rgba_image_scalecache_do(im, surface, context, smooth,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);