forked from enlightenment/efl
1. scalecache config env vars an use them
2. more api's related to cserve SVN revision: 40548
This commit is contained in:
parent
5f77a25e1b
commit
f79b4a4a2f
|
@ -31,7 +31,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
Op_Getconfig_Reply config;
|
||||
|
||||
if (!evas_cserve_config_get(&config))
|
||||
if (!evas_cserve_raw_config_get(&config))
|
||||
{
|
||||
printf("ERROR: cannot fetch config.\n");
|
||||
exit(-1);
|
||||
|
@ -52,7 +52,7 @@ main(int argc, char **argv)
|
|||
config.cache_item_timeout = atoi(argv[i]);
|
||||
i++;
|
||||
config.cache_item_timeout_check = atoi(argv[i]);
|
||||
if (!evas_cserve_config_set(&config))
|
||||
if (!evas_cserve_raw_config_set(&config))
|
||||
{
|
||||
printf("ERROR: cannot set config.\n");
|
||||
exit(-1);
|
||||
|
@ -62,7 +62,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
Op_Getstats_Reply stats;
|
||||
|
||||
if (!evas_cserve_stats_get(&stats))
|
||||
if (!evas_cserve_raw_stats_get(&stats))
|
||||
{
|
||||
printf("ERROR: cannot fetch stats.\n");
|
||||
exit(-1);
|
||||
|
@ -83,7 +83,7 @@ main(int argc, char **argv)
|
|||
unsigned char *p;
|
||||
int i, j;
|
||||
|
||||
info = evas_cserve_info_get();
|
||||
info = evas_cserve_raw_info_get();
|
||||
if (!info)
|
||||
{
|
||||
printf("ERROR: cannot fetch info.\n");
|
||||
|
|
|
@ -955,6 +955,64 @@ extern "C" {
|
|||
EAPI void evas_object_intercept_clip_unset_callback_add (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), const void *data) EINA_ARG_NONNULL(1, 2);
|
||||
EAPI void *evas_object_intercept_clip_unset_callback_del (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj)) EINA_ARG_NONNULL(1, 2);
|
||||
|
||||
typedef struct _Evas_Cserve_Stats Evas_Cserve_Stats;
|
||||
typedef struct _Evas_Cserve_Image_Cache Evas_Cserve_Image_Cache;
|
||||
typedef struct _Evas_Cserve_Image Evas_Cserve_Image;
|
||||
typedef struct _Evas_Cserve_Config Evas_Cserve_Config;
|
||||
|
||||
struct _Evas_Cserve_Stats
|
||||
{
|
||||
int saved_memory;
|
||||
int wasted_memory;
|
||||
int saved_memory_peak;
|
||||
int wasted_memory_peak;
|
||||
double saved_time_image_header_load;
|
||||
double saved_time_image_data_load;
|
||||
};
|
||||
|
||||
struct _Evas_Cserve_Image_Cache
|
||||
{
|
||||
struct {
|
||||
int mem_total;
|
||||
int count;
|
||||
} active, cached;
|
||||
Eina_List *images;
|
||||
};
|
||||
|
||||
struct _Evas_Cserve_Image
|
||||
{
|
||||
const char *file, *key;
|
||||
int w, h;
|
||||
time_t file_mod_time;
|
||||
time_t file_checked_time;
|
||||
time_t cached_time;
|
||||
int refcount;
|
||||
int data_refcount;
|
||||
int memory_footprint;
|
||||
double head_load_time;
|
||||
double data_load_time;
|
||||
Eina_Bool alpha : 1;
|
||||
Eina_Bool data_loaded : 1;
|
||||
Eina_Bool active : 1;
|
||||
Eina_Bool dead : 1;
|
||||
Eina_Bool useless : 1;
|
||||
};
|
||||
|
||||
struct _Evas_Cserve_Config
|
||||
{
|
||||
int cache_max_usage;
|
||||
int cache_item_timeout;
|
||||
int cache_item_timeout_check;
|
||||
};
|
||||
|
||||
EAPI Eina_Bool evas_cserve_want_get (void) EINA_WARN_UNUSED_RESULT EINA_PURE;
|
||||
EAPI Eina_Bool evas_cserve_connected_get (void) EINA_WARN_UNUSED_RESULT EINA_PURE;
|
||||
EAPI Eina_Bool evas_cserve_stats_get (Evas_Cserve_Stats *stats) EINA_WARN_UNUSED_RESULT EINA_PURE;
|
||||
EAPI void evas_cserve_image_cache_contents_clean (Evas_Cserve_Image_Cache *cache) EINA_PURE;
|
||||
EAPI Eina_Bool evas_cserve_config_get (Evas_Cserve_Config *config) EINA_WARN_UNUSED_RESULT EINA_PURE;
|
||||
EAPI Eina_Bool evas_cserve_config_set (Evas_Cserve_Config *config) EINA_WARN_UNUSED_RESULT EINA_PURE;
|
||||
EAPI void evas_cserve_disconnect (void) EINA_WARN_UNUSED_RESULT EINA_PURE;
|
||||
|
||||
/* Evas utility routines for color space conversions */
|
||||
/* hsv color space has h in the range 0.0 to 360.0, and s,v in the range 0.0 to 1.0 */
|
||||
/* rgb color space has r,g,b in the range 0 to 255 */
|
||||
|
|
|
@ -48,7 +48,8 @@ evas_render.c \
|
|||
evas_smart.c \
|
||||
evas_stack.c \
|
||||
evas_async_events.c \
|
||||
evas_transform.c
|
||||
evas_transform.c \
|
||||
evas_stats.c
|
||||
|
||||
libevas_canvas_la_LIBADD = @EVIL_LIBS@
|
||||
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_cs.h"
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_want_get(void)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
return evas_cserve_use_get();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_connected_get(void)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
return evas_cserve_have_get();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_stats_get(Evas_Cserve_Stats *stats)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
Op_Getstats_Reply st;
|
||||
|
||||
if (!evas_cserve_raw_stats_get(&st)) return 0;
|
||||
if (!stats) return 1;
|
||||
stats->saved_memory = st.saved_memory;
|
||||
stats->wasted_memory - st.wasted_memory;
|
||||
stats->saved_memory_peak - st.saved_memory_peak;
|
||||
stats->wasted_memory_peak - st.wasted_memory_peak;
|
||||
stats->saved_time_image_header_load - st.saved_time_image_header_load;
|
||||
stats->saved_time_image_data_load - st.saved_time_image_data_load;
|
||||
// may expand this in future
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_image_cache_contents_get(Evas_Cserve_Image_Cache *cache)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
Op_Getinfo_Reply *info;
|
||||
Op_Getinfo_Item *itt;
|
||||
unsigned char *p;
|
||||
int i, j;
|
||||
|
||||
if (!(info = evas_cserve_raw_info_get())) return 0;
|
||||
if (!cache)
|
||||
{
|
||||
free(info);
|
||||
return 1;
|
||||
}
|
||||
cache->active.mem_total = info->active.mem_total;
|
||||
cache->active.count = info->active.count;
|
||||
cache->cached.mem_total = info->cached.mem_total;
|
||||
cache->cached.count = info->cached.count;
|
||||
cache->images = NULL;
|
||||
j = info->active.count + info->cached.count;
|
||||
p = (unsigned char *)info;
|
||||
p += sizeof(Op_Getinfo_Reply);
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
Evas_Cserve_Image *im;
|
||||
Op_Getinfo_Item it;
|
||||
char *file, *key, buf[512];
|
||||
struct tm *ltm;
|
||||
|
||||
itt = (Op_Getinfo_Item *)p;
|
||||
memcpy(&it, itt, sizeof(Op_Getinfo_Item));
|
||||
file = p + sizeof(Op_Getinfo_Item);
|
||||
key = file + strlen(file) + 1;
|
||||
im = calloc(1, sizeof(Evas_Cserve_Image));
|
||||
if (!im) continue;
|
||||
if (file[0] != 0)
|
||||
{
|
||||
file = (char *)eina_stringshare_add(file);
|
||||
if (!file)
|
||||
{
|
||||
free(im);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
file = NULL;
|
||||
if (key[0] != 0)
|
||||
{
|
||||
key = (char *)eina_stringshare_add(key);
|
||||
if (!key)
|
||||
{
|
||||
if (file) eina_stringshare_del(file);
|
||||
free(im);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else key = NULL;
|
||||
cache->images = eina_list_append(cache->images, im);
|
||||
im->file = file;
|
||||
im->key = key;
|
||||
im->w = it.w;
|
||||
im->h = it.h;
|
||||
im->cached_time = it.cached_time;
|
||||
im->file_mod_time = it.file_mod_time;
|
||||
im->file_checked_time = it.file_checked_time;
|
||||
im->refcount = it.refcount;
|
||||
im->data_refcount = it.data_refcount;
|
||||
im->memory_footprint = it.memory_footprint;
|
||||
im->head_load_time = it.head_load_time;
|
||||
im->data_load_time = it.data_load_time;
|
||||
im->active = it.active;
|
||||
im->alpha = it.alpha;
|
||||
im->data_loaded = it.data_loaded;
|
||||
im->dead = it.dead;
|
||||
im->useless = it.useless;
|
||||
}
|
||||
free(info);
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_image_cache_contents_clean(Evas_Cserve_Image_Cache *cache)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
Evas_Cserve_Image *im;
|
||||
|
||||
EINA_LIST_FREE(cache->images, im)
|
||||
{
|
||||
if (im->file) eina_stringshare_del(im->file);
|
||||
if (im->key) eina_stringshare_del(im->key);
|
||||
free(im);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_config_get(Evas_Cserve_Config *config)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
Op_Getconfig_Reply conf;
|
||||
|
||||
if (!evas_cserve_raw_config_get(&conf)) return 0;
|
||||
if (!config) return 1;
|
||||
config->cache_max_usage = conf.cache_max_usage;
|
||||
config->cache_item_timeout = conf.cache_item_timeout;
|
||||
config->cache_item_timeout_check = conf.cache_item_timeout_check;
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_config_set(Evas_Cserve_Config *config)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
Op_Setconfig conf;
|
||||
|
||||
if (!config) return 1;
|
||||
conf.cache_max_usage = config->cache_max_usage;
|
||||
conf.cache_item_timeout = config->cache_item_timeout;
|
||||
conf.cache_item_timeout_check = config->cache_item_timeout_check;
|
||||
return evas_cserve_raw_config_set(&conf);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_disconnect(void)
|
||||
{
|
||||
#ifdef EVAS_CSERVE
|
||||
evas_cserve_discon();
|
||||
#endif
|
||||
}
|
|
@ -234,16 +234,18 @@ typedef struct
|
|||
// for clients to connect to cserve
|
||||
EAPI Eina_Bool evas_cserve_init(void);
|
||||
EAPI int evas_cserve_use_get(void);
|
||||
EAPI Eina_Bool evas_cserve_have_get(void);
|
||||
EAPI void evas_cserve_shutdown(void);
|
||||
EAPI void evas_cserve_discon(void);
|
||||
EAPI Eina_Bool evas_cserve_image_load(Image_Entry *ie, const char *file, const char *key, RGBA_Image_Loadopts *lopt);
|
||||
EAPI Eina_Bool evas_cserve_image_data_load(Image_Entry *ie);
|
||||
EAPI void evas_cserve_image_unload(Image_Entry *ie);
|
||||
EAPI void evas_cserve_image_useless(Image_Entry *ie);
|
||||
EAPI void evas_cserve_image_free(Image_Entry *ie);
|
||||
EAPI Eina_Bool evas_cserve_config_get(Op_Getconfig_Reply *config);
|
||||
EAPI Eina_Bool evas_cserve_config_set(Op_Setconfig *config);
|
||||
EAPI Eina_Bool evas_cserve_stats_get(Op_Getstats_Reply *stats);
|
||||
EAPI Op_Getinfo_Reply *evas_cserve_info_get(void);
|
||||
EAPI Eina_Bool evas_cserve_raw_config_get(Op_Getconfig_Reply *config);
|
||||
EAPI Eina_Bool evas_cserve_raw_config_set(Op_Setconfig *config);
|
||||
EAPI Eina_Bool evas_cserve_raw_stats_get(Op_Getstats_Reply *stats);
|
||||
EAPI Op_Getinfo_Reply *evas_cserve_raw_info_get(void);
|
||||
|
||||
// for the server
|
||||
EAPI Server *evas_cserve_server_add(void);
|
||||
|
|
|
@ -187,6 +187,13 @@ evas_cserve_use_get(void)
|
|||
return csrve_init;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_have_get(void)
|
||||
{
|
||||
if (cserve) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_shutdown(void)
|
||||
{
|
||||
|
@ -197,6 +204,16 @@ evas_cserve_shutdown(void)
|
|||
cserve = NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_discon(void)
|
||||
{
|
||||
if (cserve)
|
||||
{
|
||||
server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
server_reinit(void)
|
||||
{
|
||||
|
@ -369,7 +386,7 @@ evas_cserve_image_useless(Image_Entry *ie)
|
|||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_config_get(Op_Getconfig_Reply *config)
|
||||
evas_cserve_raw_config_get(Op_Getconfig_Reply *config)
|
||||
{
|
||||
Op_Getconfig_Reply *rep;
|
||||
int opcode;
|
||||
|
@ -390,7 +407,7 @@ evas_cserve_config_get(Op_Getconfig_Reply *config)
|
|||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_config_set(Op_Setconfig *config)
|
||||
evas_cserve_raw_config_set(Op_Setconfig *config)
|
||||
{
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return 0;
|
||||
|
@ -400,7 +417,7 @@ evas_cserve_config_set(Op_Setconfig *config)
|
|||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_stats_get(Op_Getstats_Reply *stats)
|
||||
evas_cserve_raw_stats_get(Op_Getstats_Reply *stats)
|
||||
{
|
||||
Op_Getstats_Reply *rep;
|
||||
int opcode;
|
||||
|
@ -421,7 +438,7 @@ evas_cserve_stats_get(Op_Getstats_Reply *stats)
|
|||
}
|
||||
|
||||
EAPI Op_Getinfo_Reply *
|
||||
evas_cserve_info_get(void)
|
||||
evas_cserve_raw_info_get(void)
|
||||
{
|
||||
Op_Getinfo_Reply *rep;
|
||||
int opcode;
|
||||
|
|
|
@ -45,15 +45,35 @@ static LK(cache_lock);
|
|||
#endif
|
||||
static Eina_Inlist *cache_list = NULL;
|
||||
static int cache_size = 0;
|
||||
static int init = 0;
|
||||
|
||||
static int max_cache_size = SCALE_CACHE_SIZE;
|
||||
static int max_dimension = MAX_SCALECACHE_DIM;
|
||||
static int max_flop_count = MAX_FLOP_COUNT;
|
||||
static int max_scale_items = MAX_SCALEITEMS;
|
||||
static int min_scale_uses = MIN_SCALE_USES;
|
||||
#endif
|
||||
|
||||
void
|
||||
evas_common_scalecache_init(void)
|
||||
{
|
||||
#ifdef SCALECACHE
|
||||
const char *s;
|
||||
|
||||
init++;
|
||||
if (init > 1) return;
|
||||
use_counter = 0;
|
||||
LKI(cache_lock);
|
||||
s = getenv("EVAS_SCALECACHE_SIZE");
|
||||
if (s) max_cache_size = atoi(s) * 1024;
|
||||
s = getenv("EVAS_SCALECACHE_MAX_DIMENSION");
|
||||
if (s) max_dimension = atoi(s);
|
||||
s = getenv("EVAS_SCALECACHE_MAX_FLOP_COUNT");
|
||||
if (s) max_flop_count = atoi(s);
|
||||
s = getenv("EVAS_SCALECACHE_MAX_ITEMS");
|
||||
if (s) max_scale_items = atoi(s);
|
||||
s = getenv("EVAS_SCALECACHE_MIN_USES");
|
||||
if (s) min_scale_uses = atoi(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -61,6 +81,7 @@ void
|
|||
evas_common_scalecache_shutdown(void)
|
||||
{
|
||||
#ifdef SCALECACHE
|
||||
init--;
|
||||
LKD(cache_lock);
|
||||
#endif
|
||||
}
|
||||
|
@ -197,7 +218,7 @@ _sci_find(RGBA_Image *im,
|
|||
return sci;
|
||||
}
|
||||
}
|
||||
if (eina_list_count(im->cache.list) > MAX_SCALEITEMS)
|
||||
if (eina_list_count(im->cache.list) > max_scale_items)
|
||||
{
|
||||
l = eina_list_last(im->cache.list);
|
||||
sci = l->data;
|
||||
|
@ -351,17 +372,17 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst,
|
|||
// 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)
|
||||
if ((sci->usage >= min_scale_uses)
|
||||
&& (ie->scale_hint != EVAS_IMAGE_SCALE_HINT_DYNAMIC)
|
||||
// && (sci->usage_count > (use_counter - MIN_SCALE_AGE_GAP))
|
||||
)
|
||||
{
|
||||
if (!sci->im)
|
||||
{
|
||||
if ((sci->dst_w < MAX_SCALECACHE_DIM) &&
|
||||
(sci->dst_h < MAX_SCALECACHE_DIM))
|
||||
if ((sci->dst_w < max_dimension) &&
|
||||
(sci->dst_h < max_dimension))
|
||||
{
|
||||
if (sci->flop <= MAX_FLOP_COUNT)
|
||||
if (sci->flop <= max_flop_count)
|
||||
{
|
||||
sci->populate_me = 1;
|
||||
im->cache.populate_count++;
|
||||
|
|
Loading…
Reference in New Issue