formatting

SVN revision: 72948
This commit is contained in:
Mike Blumenkrantz 2012-06-27 13:30:40 +00:00
parent 329a7b1d03
commit 36c7e47745
3 changed files with 161 additions and 158 deletions

View File

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

View File

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

View File

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