SVN revision: 72948
devs/princeamd/enlightenment-0.17-elive
Mike Blumenkrantz 11 years ago
parent 329a7b1d03
commit 36c7e47745
  1. 73
      src/bin/e_livethumb.c
  2. 195
      src/bin/e_thumb.c
  3. 53
      src/bin/e_thumb_main.c

@ -1,8 +1,8 @@
#include "e.h"
#define SMART_NAME "e_livethumb"
#define API_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
#define INTERNAL_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
#define SMART_NAME "e_livethumb"
#define API_ENTRY E_Smart_Data * sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
#define INTERNAL_ENTRY E_Smart_Data * sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
typedef struct _E_Smart_Data E_Smart_Data;
typedef struct _E_Smart_Item E_Smart_Item;
@ -10,11 +10,11 @@ struct _E_Smart_Data
{
Evas_Coord x, y, w, h;
Evas_Object *smart_obj;
Evas_Object *evas_obj;
Evas_Object *thumb_obj;
Evas *evas;
Evas_Coord vw, vh;
Evas_Object *smart_obj;
Evas_Object *evas_obj;
Evas_Object *thumb_obj;
Evas *evas;
Evas_Coord vw, vh;
};
/* local subsystem functions */
@ -26,7 +26,7 @@ static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
static void _e_smart_show(Evas_Object *obj);
static void _e_smart_hide(Evas_Object *obj);
static void _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
static void _e_smart_clip_set(Evas_Object *obj, Evas_Object * clip);
static void _e_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
static void _e_smart_clip_unset(Evas_Object *obj);
static void _e_smart_init(void);
@ -73,8 +73,8 @@ e_livethumb_thumb_set(Evas_Object *obj, Evas_Object *thumb)
API_ENTRY return;
if (!thumb)
{
sd->thumb_obj = NULL;
return;
sd->thumb_obj = NULL;
return;
}
sd->thumb_obj = thumb;
evas_object_show(sd->thumb_obj);
@ -175,7 +175,7 @@ _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
}
static void
_e_smart_clip_set(Evas_Object *obj, Evas_Object * clip)
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
{
INTERNAL_ENTRY;
evas_object_clip_set(sd->evas_obj, clip);
@ -194,28 +194,29 @@ static void
_e_smart_init(void)
{
if (_e_smart) return;
{
static const Evas_Smart_Class sc =
{
SMART_NAME,
EVAS_SMART_CLASS_VERSION,
_e_smart_add,
_e_smart_del,
_e_smart_move,
_e_smart_resize,
_e_smart_show,
_e_smart_hide,
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
}
{
static const Evas_Smart_Class sc =
{
SMART_NAME,
EVAS_SMART_CLASS_VERSION,
_e_smart_add,
_e_smart_del,
_e_smart_move,
_e_smart_resize,
_e_smart_show,
_e_smart_hide,
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
}
}

@ -4,27 +4,27 @@ typedef struct _E_Thumb E_Thumb;
struct _E_Thumb
{
int objid;
int w, h;
const char *file;
const char *key;
char *sort_id;
int objid;
int w, h;
const char *file;
const char *key;
char *sort_id;
unsigned char queued : 1;
unsigned char busy : 1;
unsigned char done : 1;
};
/* local subsystem functions */
static void _e_thumb_gen_begin(int objid, const char *file, const char *key, int w, int h);
static void _e_thumb_gen_end(int objid);
static void _e_thumb_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_thumb_hash_add(int objid, Evas_Object *obj);
static void _e_thumb_hash_del(int objid);
static void _e_thumb_gen_begin(int objid, const char *file, const char *key, int w, int h);
static void _e_thumb_gen_end(int objid);
static void _e_thumb_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_thumb_hash_add(int objid, Evas_Object *obj);
static void _e_thumb_hash_del(int objid);
static Evas_Object *_e_thumb_hash_find(int objid);
static void _e_thumb_thumbnailers_kill(void);
static void _e_thumb_thumbnailers_kill_cancel(void);
static Eina_Bool _e_thumb_cb_kill(void *data);
static Eina_Bool _e_thumb_cb_exe_event_del(void *data, int type, void *event);
static void _e_thumb_thumbnailers_kill(void);
static void _e_thumb_thumbnailers_kill_cancel(void);
static Eina_Bool _e_thumb_cb_kill(void *data);
static Eina_Bool _e_thumb_cb_exe_event_del(void *data, int type, void *event);
/* local subsystem globals */
static Eina_List *_thumbnailers = NULL;
@ -42,8 +42,8 @@ EINTERN int
e_thumb_init(void)
{
_exe_del_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_e_thumb_cb_exe_event_del,
NULL);
_e_thumb_cb_exe_event_del,
NULL);
_thumbs = eina_hash_string_superfast_new(NULL);
return 1;
}
@ -86,7 +86,7 @@ e_thumb_icon_add(Evas *evas)
eth->h = 64;
evas_object_data_set(obj, "e_thumbdata", eth);
evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
_e_thumb_del_hook, NULL);
_e_thumb_del_hook, NULL);
_e_thumb_hash_add(eth->objid, obj);
return obj;
}
@ -115,7 +115,7 @@ e_thumb_icon_size_set(Evas_Object *obj, int w, int h)
eth = evas_object_data_get(obj, "e_thumbdata");
if (!eth) return;
if ((w < 1) || (h <1)) return;
if ((w < 1) || (h < 1)) return;
eth->w = w;
eth->h = h;
}
@ -134,26 +134,26 @@ e_thumb_icon_begin(Evas_Object *obj)
if (!eth->file) return;
if (!_thumbnailers)
{
while ((int) eina_list_count(_thumbnailers_exe) < _num_thumbnailers)
{
Ecore_Exe *exe;
snprintf(buf, sizeof(buf), "%s/enlightenment/utils/enlightenment_thumb --nice=%d", e_prefix_lib_get(),
e_config->thumb_nice);
exe = ecore_exe_run(buf, NULL);
_thumbnailers_exe = eina_list_append(_thumbnailers_exe, exe);
}
_thumb_queue = eina_list_append(_thumb_queue, eth);
eth->queued = 1;
return;
while ((int)eina_list_count(_thumbnailers_exe) < _num_thumbnailers)
{
Ecore_Exe *exe;
snprintf(buf, sizeof(buf), "%s/enlightenment/utils/enlightenment_thumb --nice=%d", e_prefix_lib_get(),
e_config->thumb_nice);
exe = ecore_exe_run(buf, NULL);
_thumbnailers_exe = eina_list_append(_thumbnailers_exe, exe);
}
_thumb_queue = eina_list_append(_thumb_queue, eth);
eth->queued = 1;
return;
}
EINA_LIST_FREE(_thumb_queue, eth2)
{
eth2->queued = 0;
eth2->busy = 1;
_pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel();
_e_thumb_gen_begin(eth2->objid, eth2->file, eth2->key, eth2->w, eth2->h);
eth2->queued = 0;
eth2->busy = 1;
_pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel();
_e_thumb_gen_begin(eth2->objid, eth2->file, eth2->key, eth2->w, eth2->h);
}
eth->busy = 1;
_pending++;
@ -170,15 +170,15 @@ e_thumb_icon_end(Evas_Object *obj)
if (!eth) return;
if (eth->queued)
{
_thumb_queue = eina_list_remove(_thumb_queue, eth);
eth->queued = 0;
_thumb_queue = eina_list_remove(_thumb_queue, eth);
eth->queued = 0;
}
if (eth->busy)
{
_e_thumb_gen_end(eth->objid);
eth->busy = 0;
_pending--;
if (_pending == 0) _e_thumb_thumbnailers_kill();
_e_thumb_gen_end(eth->objid);
eth->busy = 0;
_pending--;
if (_pending == 0) _e_thumb_thumbnailers_kill();
}
}
@ -195,11 +195,11 @@ e_thumb_icon_rethumb(Evas_Object *obj)
e_thumb_icon_begin(obj);
}
#define A(v) (((v) >> 24) & 0xff)
#define R(v) (((v) >> 16) & 0xff)
#define G(v) (((v) >> 8 ) & 0xff)
#define B(v) (((v) ) & 0xff)
#define PIX(p, x, y) p[((y) << 2) + (x)]
#define A(v) (((v) >> 24) & 0xff)
#define R(v) (((v) >> 16) & 0xff)
#define G(v) (((v) >> 8) & 0xff)
#define B(v) (((v)) & 0xff)
#define PIX(p, x, y) p[((y) << 2) + (x)]
#define PIX2(p, x, y) p[((y) << 1) + (x)]
static void
@ -245,42 +245,42 @@ e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e)
_thumbnailers = eina_list_prepend(_thumbnailers, e->client);
if (e->minor == 2)
{
objid = e->ref;
icon = e->data;
if ((icon) && (e->size > 1) && (icon[e->size - 1] == 0))
{
obj = _e_thumb_hash_find(objid);
if (obj)
{
eth = evas_object_data_get(obj, "e_thumbdata");
if (eth)
{
eth->busy = 0;
_pending--;
eth->done = 1;
if (_pending == 0) _e_thumb_thumbnailers_kill();
if (ecore_file_exists(icon))
{
e_icon_file_key_set(obj, icon, "/thumbnail/data");
_e_thumb_key_load(eth, icon);
e_icon_preload_set(obj, 1);
}
evas_object_smart_callback_call(obj, "e_thumb_gen", NULL);
}
}
}
objid = e->ref;
icon = e->data;
if ((icon) && (e->size > 1) && (icon[e->size - 1] == 0))
{
obj = _e_thumb_hash_find(objid);
if (obj)
{
eth = evas_object_data_get(obj, "e_thumbdata");
if (eth)
{
eth->busy = 0;
_pending--;
eth->done = 1;
if (_pending == 0) _e_thumb_thumbnailers_kill();
if (ecore_file_exists(icon))
{
e_icon_file_key_set(obj, icon, "/thumbnail/data");
_e_thumb_key_load(eth, icon);
e_icon_preload_set(obj, 1);
}
evas_object_smart_callback_call(obj, "e_thumb_gen", NULL);
}
}
}
}
if (e->minor == 1)
{
/* hello message */
EINA_LIST_FREE(_thumb_queue, eth)
{
eth->queued = 0;
eth->busy = 1;
_pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel();
_e_thumb_gen_begin(eth->objid, eth->file, eth->key, eth->w, eth->h);
}
/* hello message */
EINA_LIST_FREE(_thumb_queue, eth)
{
eth->queued = 0;
eth->busy = 1;
_pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel();
_e_thumb_gen_begin(eth->objid, eth->file, eth->key, eth->w, eth->h);
}
}
}
@ -324,7 +324,7 @@ _e_thumb_gen_end(int objid)
/* send thumb cancel */
EINA_LIST_FOREACH(_thumbnailers, l, cli)
{
ecore_ipc_client_send(cli, E_IPC_DOMAIN_THUMB, 2, objid, 0, 0, NULL, 0);
ecore_ipc_client_send(cli, E_IPC_DOMAIN_THUMB, 2, objid, 0, 0, NULL, 0);
}
}
@ -339,10 +339,10 @@ _e_thumb_del_hook(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, v
_e_thumb_hash_del(eth->objid);
if (eth->busy)
{
_e_thumb_gen_end(eth->objid);
eth->busy = 0;
_pending--;
if (_pending == 0) _e_thumb_thumbnailers_kill();
_e_thumb_gen_end(eth->objid);
eth->busy = 0;
_pending--;
if (_pending == 0) _e_thumb_thumbnailers_kill();
}
if (eth->queued)
_thumb_queue = eina_list_remove(_thumb_queue, eth);
@ -416,24 +416,25 @@ _e_thumb_cb_exe_event_del(void *data __UNUSED__, int type __UNUSED__, void *even
ev = event;
EINA_LIST_FOREACH(_thumbnailers_exe, l, exe)
{
if (exe == ev->exe)
{
_thumbnailers_exe = eina_list_remove_list(_thumbnailers_exe, l);
break;
}
if (exe == ev->exe)
{
_thumbnailers_exe = eina_list_remove_list(_thumbnailers_exe, l);
break;
}
}
if ((!_thumbnailers_exe) && (_thumb_queue))
{
while ((int) eina_list_count(_thumbnailers_exe) < _num_thumbnailers)
{
Ecore_Exe *exe_thumb;
while ((int)eina_list_count(_thumbnailers_exe) < _num_thumbnailers)
{
Ecore_Exe *exe_thumb;
char buf[4096];
snprintf(buf, sizeof(buf), "%s/enlightenment/utils/enlightenment_thumb --nice=%d", e_prefix_lib_get(),
e_config->thumb_nice);
exe_thumb = ecore_exe_run(buf, NULL);
_thumbnailers_exe = eina_list_append(_thumbnailers_exe, exe_thumb);
}
snprintf(buf, sizeof(buf), "%s/enlightenment/utils/enlightenment_thumb --nice=%d", e_prefix_lib_get(),
e_config->thumb_nice);
exe_thumb = ecore_exe_run(buf, NULL);
_thumbnailers_exe = eina_list_append(_thumbnailers_exe, exe_thumb);
}
}
return ECORE_CALLBACK_PASS_ON;
}

@ -44,13 +44,13 @@ struct _E_Thumb
/* local subsystem functions */
static int _e_ipc_init(void);
static Eina_Bool _e_ipc_cb_server_add(void *data,
int type,
int type,
void *event);
static Eina_Bool _e_ipc_cb_server_del(void *data,
int type,
int type,
void *event);
static Eina_Bool _e_ipc_cb_server_data(void *data,
int type,
int type,
void *event);
static Eina_Bool _e_cb_timer(void *data);
static void _e_thumb_generate(E_Thumb *eth);
@ -65,7 +65,7 @@ static char _thumbdir[4096] = "";
/* externally accessible functions */
int
main(int argc,
main(int argc,
char **argv)
{
int i;
@ -152,7 +152,7 @@ _e_ipc_init(void)
static Eina_Bool
_e_ipc_cb_server_add(void *data __UNUSED__,
int type __UNUSED__,
void *event)
void *event)
{
Ecore_Ipc_Event_Server_Add *e;
@ -170,14 +170,14 @@ _e_ipc_cb_server_del(void *data __UNUSED__,
void *event __UNUSED__)
{
/* quit now */
ecore_main_loop_quit();
return ECORE_CALLBACK_PASS_ON;
ecore_main_loop_quit();
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_ipc_cb_server_data(void *data __UNUSED__,
int type __UNUSED__,
void *event)
void *event)
{
Ecore_Ipc_Event_Server_Data *e;
E_Thumb *eth;
@ -197,20 +197,20 @@ _e_ipc_cb_server_data(void *data __UNUSED__,
/* TO a trusted process that WILL send this message properly */
/* formatted. if the thumbnailer dies anyway - it's not a big loss */
/* but it is a sign of a bug in e formattign messages maybe */
file = e->data;
key = file + strlen(file) + 1;
if (!key[0]) key = NULL;
eth = calloc(1, sizeof(E_Thumb));
if (eth)
{
eth->objid = e->ref;
eth->w = e->ref_to;
eth->h = e->response;
eth->file = strdup(file);
if (key) eth->key = strdup(key);
_thumblist = eina_list_append(_thumblist, eth);
if (!_timer) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL);
}
file = e->data;
key = file + strlen(file) + 1;
if (!key[0]) key = NULL;
eth = calloc(1, sizeof(E_Thumb));
if (eth)
{
eth->objid = e->ref;
eth->w = e->ref_to;
eth->h = e->response;
eth->file = strdup(file);
if (key) eth->key = strdup(key);
_thumblist = eina_list_append(_thumblist, eth);
if (!_timer) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL);
}
}
break;
@ -367,7 +367,7 @@ _e_thumb_generate(E_Thumb *eth)
evas_object_image_fill_set(im, 0, 0, ww, hh);
}
}
ecore_evas_alpha_set(ee, alpha);
ecore_evas_alpha_set(ee, alpha);
evas_object_move(im, 0, 0);
evas_object_resize(im, ww, hh);
ecore_evas_resize(ee, ww, hh);
@ -436,7 +436,7 @@ _e_thumb_generate(E_Thumb *eth)
data3 = malloc(ww * hh * sizeof(unsigned int));
memcpy(data3, data, ww * hh * sizeof(unsigned int));
// sort_id
// sort_id
n = 0;
#define A(v) (((v) >> 24) & 0xff)
#define R(v) (((v) >> 16) & 0xff)
@ -449,8 +449,8 @@ _e_thumb_generate(E_Thumb *eth)
vi = 20 * v; \
if (si < 2) hi = 25;
#define SAVEHSV(h, s, v) \
id2[n++] = 'a' + h; \
id2[n++] = 'a' + v; \
id2[n++] = 'a' + h; \
id2[n++] = 'a' + v; \
id2[n++] = 'a' + s;
#define SAVEX(x) \
id2[n++] = 'a' + x;
@ -563,3 +563,4 @@ _e_thumb_file_id(char *file,
s[(i * 2)] = 0;
return strdup(s);
}

Loading…
Cancel
Save