summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-10-16 12:25:02 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-10-16 12:25:02 +0900
commit9bb1c1531b6fe1f774d70c5df7786e210ac1a0a0 (patch)
treee85764028d7cb228a987e1ec5bcfbfc086d17bf3
parentbfea06faaba4ab40b78f1f826c6bdf923df134ea (diff)
evlog - update tool to look and work better
-rwxr-xr-xbuild.sh2
-rw-r--r--evlog.c1276
-rw-r--r--evlog.edc58
-rw-r--r--img/box_glow.pngbin470 -> 0 bytes
-rw-r--r--img/box_outline.pngbin115 -> 0 bytes
-rw-r--r--img/diagonal_stripes.pngbin0 -> 1076 bytes
-rw-r--r--img/runner_vert.pngbin99 -> 0 bytes
7 files changed, 842 insertions, 494 deletions
diff --git a/build.sh b/build.sh
index f144398..34c1c2e 100755
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2gcc evlog.c -o evlog `pkg-config --cflags --libs elementary` 2gcc evlog.c -o evlog `pkg-config --cflags --libs elementary` -g
3edje_cc evlog.edc -id ./img 3edje_cc evlog.edc -id ./img
4 4
5### minimal docs! 5### minimal docs!
diff --git a/evlog.c b/evlog.c
index 509edb4..4bc5244 100644
--- a/evlog.c
+++ b/evlog.c
@@ -5,255 +5,248 @@ edje_cc evlog.edc -id ./img
5 5
6#include <Elementary.h> 6#include <Elementary.h>
7 7
8#define RES 1000000.0 8#define RES 100000.0
9 9
10Evas_Object *win; 10Evas_Object *win;
11Evas_Object *zoom_slider; 11Evas_Object *zoom_slider;
12 12
13typedef struct _Evlog Evlog; 13typedef struct _Evlog Evlog;
14typedef struct _Evlog_Block Evlog_Block; 14typedef struct _Evlog_Thread Evlog_Thread;
15typedef struct _Evlog_Stack Evlog_Stack; 15typedef struct _Evlog_Event Evlog_Event;
16typedef struct _Evlog_Stack_Item Evlog_Stack_Item;
17 16
18struct _Evlog 17struct _Evlog
19{ 18{
20 FILE *file; 19 FILE *file;
21 double start_t; 20 double first_timestamp;
22 double end_t; 21 double last_timestamp;
23 Evlog_Block *blocks; 22 int state_num;
24 unsigned int blocks_num; 23 int thread_num;
24 Evlog_Event *states;
25 Evlog_Thread *threads;
25}; 26};
26 27
27struct _Evlog_Stack_Item 28struct _Evlog_Event
28{ 29{
29 long offset; 30 const char *event;
30 void *ptr; 31// const char *detail;
31 Eina_Evlog_Item item; 32 double timestamp;
33 double latency;
32}; 34};
33 35
34struct _Evlog_Stack 36struct _Evlog_Thread
35{ 37{
36 unsigned long long thread; 38 unsigned long long id;
37 unsigned int items_num; 39 int event_num;
38 unsigned int items_alloc; 40 Evlog_Event *events;
39 Evlog_Stack_Item *items;
40}; 41};
41 42
42struct _Evlog_Block 43typedef struct
43{ 44{
44 unsigned int overflow; 45 Evlog *evlog;
45 unsigned int num; 46 Evas_Object *win;
46 unsigned int end_stacks_num; 47 Evas_Object *scroller;
47 long start; 48 Evas_Object *table;
48 long end; 49 struct {
49 Evlog_Stack *end_stacks; 50 Evas_Object *state;
50 double start_t; 51 Evas_Object **thread;
51 double end_t; 52 Evas_Object *over;
52}; 53 } grid;
53 54 Eina_List *objs;
54static long 55 struct {
55_evlog_item_fetch(Evlog *evlog, Eina_Evlog_Item *item) 56 Ecore_Job *job;
57 Ecore_Thread *thread;
58 double t0, t1, tmin;
59 Eina_Bool redo : 1;
60 Eina_List *remobjs;
61 } update;
62} Inf;
63
64typedef struct
56{ 65{
57 long pos; 66 void *src;
67 char *event;
68 Evas_Object *obj;
69 double t0, t1;
70 int n;
71 int slot;
72 Eina_Bool nuke : 1;
73} Event;
74
75#define ROUND_AMOUNT 1024
76#define ROUND(x) ((x + (ROUND_AMOUNT - 1)) / ROUND_AMOUNT) * ROUND_AMOUNT;
77
78static void _fill_begin(Inf *inf);
79
80
81
82
83
84
85
86
87
88
89
90
91
58 92
59 pos = ftell(evlog->file);
60 if (fread(item, sizeof(Eina_Evlog_Item), 1, evlog->file) != 1) return -1;
61 if (item->event_offset != sizeof(Eina_Evlog_Item)) return -1;
62 if (item->event_offset >= item->event_next) return -1;
63 if (item->detail_offset >= item->event_next) return -1;
64 if (fseek(evlog->file, -sizeof(Eina_Evlog_Item), SEEK_CUR) != 0) return -1;
65 return pos;
66}
67 93
68static char *
69_evlog_item_event_fetch(Evlog *evlog, long pos, Eina_Evlog_Item *item)
70{
71 long ppos = ftell(evlog->file);
72 char *str = malloc(item->event_next);
73 if (!str) return NULL;
74 fseek(evlog->file, pos + item->event_offset, SEEK_SET);
75 if (fread(str, item->event_next, 1, evlog->file) != 1)
76 {
77 free(str);
78 str = NULL;
79 }
80 fseek(evlog->file, ppos, SEEK_SET);
81 return str;
82}
83 94
84static void 95static void
85_evlog_stack_push(Evlog_Stack *stack, long pos, Eina_Evlog_Item *item) 96evlog_state_event_register(Evlog *evlog, Evlog_Event *ev)
86{ 97{
87 stack->items_num++; 98 int n0, n;
88 if (!stack->items) 99
89 { 100 n0 = evlog->state_num;
90 stack->items_alloc = 16; 101 evlog->state_num++;
91 stack->items = malloc(sizeof(Evlog_Stack_Item) * 102 n = evlog->state_num;
92 stack->items_alloc); 103 n0 = ROUND(n0);
93 if (!stack->items) return; 104 n = ROUND(n);
94 } 105 if (n != n0)
95 else if (stack->items_num > stack->items_alloc)
96 { 106 {
97 Evlog_Stack_Item *items; 107 Evlog_Event *tmp;
98 108
99 stack->items_alloc += 16; 109 tmp = realloc(evlog->states, n * sizeof(Evlog_Event));
100 items = realloc(stack->items, sizeof(Evlog_Stack_Item) * 110 if (!tmp)
101 stack->items_alloc); 111 {
102 if (!items) return; 112 eina_stringshare_del(ev->event);
103 stack->items = items; 113 return;
114 }
115 evlog->states = tmp;
104 } 116 }
105 stack->items[stack->items_num - 1].offset = pos; 117 evlog->states[evlog->state_num - 1] = *ev;
106 stack->items[stack->items_num - 1].item = *item;
107} 118}
108 119
109static void 120static void
110_evlog_stack_pop(Evlog_Stack *stack) 121evlog_thread_event_register(Evlog_Thread *th, Evlog_Event *ev)
111{ 122{
112 stack->items_num--; 123 int n0, n;
113 if (stack->items_num == 0) 124
125 n0 = th->event_num;
126 th->event_num++;
127 n = th->event_num;
128 n0 = ROUND(n0);
129 n = ROUND(n);
130 if (n != n0)
114 { 131 {
115 free(stack->items); 132 Evlog_Event *tmp;
116 stack->items_alloc = 0; 133
117 stack->items = NULL; 134 tmp = realloc(th->events, n * sizeof(Evlog_Event));
135 if (!tmp)
136 {
137 eina_stringshare_del(ev->event);
138 return;
139 }
140 th->events = tmp;
118 } 141 }
142 th->events[th->event_num - 1] = *ev;
119} 143}
120 144
121static void 145static void
122_evlog_stack_dup(Evlog_Stack *stack, Evlog_Stack *dst) 146evlog_event_register(Evlog *evlog, unsigned long long thread, Evlog_Event *ev)
123{ 147{
124 *dst = *stack;
125 dst->items = malloc(sizeof(Evlog_Stack_Item) * stack->items_num);
126 if (!dst->items) return;
127 memcpy(dst->items, stack->items, sizeof(Evlog_Stack_Item) * stack->items_num);
128 dst->items_alloc = dst->items_num;
129}
130
131static Evlog_Stack *
132_evlog_stack_get(Evlog_Stack **stacks, int *stacks_num, unsigned long long thread)
133{
134 Evlog_Stack *stack = NULL;
135 int i; 148 int i;
136 149
137 for (i = 0; i < *stacks_num; i++) 150 if ((ev->event[0] == '<') || (ev->event[0] == '>'))
138 { 151 {
139 if ((*stacks)[i].thread == thread) 152 evlog_state_event_register(evlog, ev);
140 {
141 stack = &((*stacks)[i]);
142 break;
143 }
144 } 153 }
145 if (!(*stacks)) 154 else
146 { 155 {
147 (*stacks_num)++; 156 for (i = 0; i < evlog->thread_num; i++)
148 stack = realloc(*stacks, sizeof(Evlog_Stack) * (*stacks_num));
149 if (stack)
150 { 157 {
151 *stacks = stack; 158 if (evlog->threads[i].id == thread) break;
152 stack = &((*stacks)[(*stacks_num) - 1]); 159 }
153 memset(stack, 0, sizeof(Evlog_Stack)); 160 if (i >= evlog->thread_num)
154 stack->thread = thread; 161 {
162 Evlog_Thread *tmp;
163
164 evlog->thread_num++;
165 tmp = realloc(evlog->threads,
166 evlog->thread_num * sizeof(Evlog_Thread));
167 if (!tmp)
168 {
169 eina_stringshare_del(ev->event);
170 return;
171 }
172 evlog->threads = tmp;
173 evlog->threads[i].id = thread;
174 evlog->threads[i].event_num = 0;
175 evlog->threads[i].events = NULL;
155 } 176 }
177 evlog_thread_event_register(&(evlog->threads[i]), ev);
156 } 178 }
157 return stack;
158} 179}
159 180
160static void 181static void *
161_evlog_block_list(Evlog *evlog) 182evlog_event_read(Evlog *evlog, void *ptr, void *end)
162{ 183{
163 unsigned int header[3]; 184 unsigned char *data = ptr;
164 Eina_Binbuf *buf; 185 unsigned char *dataend = end;
165 unsigned int num = 0, blocksize, evnum; 186 const char *eventstr = NULL, *detailstr = NULL;
166 long pos; 187 Eina_Evlog_Item item;
167 Evlog_Block block = { 0 };
168 Eina_Evlog_Item item = { 0 };
169 int stacks_num = 0, i;
170 Evlog_Stack *stacks = NULL;
171
172 buf = eina_binbuf_new();
173 rewind(evlog->file);
174 for (;;)
175 {
176 block.start_t = 0.0;
177 block.num = 0;
178 if (fread(header, 12, 1, evlog->file) != 1) break;
179 if (header[0] == 0xffee211)
180 {
181 blocksize = header[1];
182 block.overflow = header[2];
183 block.start = ftell(evlog->file);
184 if (fseek(evlog->file, blocksize, SEEK_CUR) != 0) break;
185 block.end = ftell(evlog->file);
186 if (fseek(evlog->file, block.start, SEEK_SET) != 0) break;
187 }
188 else break;
189 while ((pos = _evlog_item_fetch(evlog, &item)) >= 0)
190 {
191 char *event = _evlog_item_event_fetch(evlog, pos, &item);
192 if (event)
193 {
194 if (block.start_t == 0.0) block.start_t = item.tim;
195 block.end_t = item.tim;
196 if (event[0] == '+')
197 {
198 Evlog_Stack *stack;
199 188
200 stack = _evlog_stack_get(&stacks, &stacks_num, item.thread); 189 if ((dataend - data) < sizeof(Eina_Evlog_Item)) return NULL;
201 if (stack) _evlog_stack_push(stack, pos, &item);
202 }
203 else if (event[0] == '-')
204 {
205 Evlog_Stack *stack = NULL;
206 190
207 stack = _evlog_stack_get(&stacks, &stacks_num, item.thread); 191 memcpy(&item, data, sizeof(Eina_Evlog_Item));
208 if ((stack) && (stack->items_num > 0)) 192
209 { 193 if (item.event_offset >= sizeof(Eina_Evlog_Item))
210 char *event_top = _evlog_item_event_fetch 194 eventstr = data + item.event_offset;
211 (evlog, stack->items[stack->items_num - 1].offset, 195 if (item.detail_offset >= sizeof(Eina_Evlog_Item))
212 &(stack->items[stack->items_num - 1].item)); 196 detailstr = data + item.detail_offset;
213 if ((event_top) && 197 if (eventstr)
214 (!strcmp(event + 1, event_top + 1))) 198 {
215 _evlog_stack_pop(stack); 199 Evlog_Event ev;
216 free(event_top); 200 ev.event = eina_stringshare_add(eventstr);
217 } 201 ev.timestamp = (item.srctim == 0.0) ? item.tim : item.srctim;
218 } 202 ev.latency = (item.srctim != 0.0) ? item.tim - item.srctim : 0.0;
219 free(event); 203 if (evlog->first_timestamp == 0.0)
220 block.num++; 204 evlog->first_timestamp = ev.timestamp;
221 } 205 if (ev.timestamp > evlog->last_timestamp)
222 fseek(evlog->file, item.event_next, SEEK_CUR); 206 evlog->last_timestamp = ev.timestamp;
223 } 207 evlog_event_register(evlog, item.thread, &ev);
224 block.end_stacks = stacks;
225 block.end_stacks_num = stacks_num;
226 stacks = NULL;
227 stacks_num = 0;
228 printf("BLOCK %i, %i events, o=%i %1.7f (%1.7f)\n",
229 num, block.num, block.overflow,
230 block.start_t, block.end_t - block.start_t);
231 eina_binbuf_append_length(buf, (unsigned char *)(&block), sizeof(Evlog_Block));
232 fseek(evlog->file, block.end, SEEK_SET);
233 num++;
234 } 208 }
235 printf("have %i blocks\n", num); 209
236 rewind(evlog->file); 210 data += item.event_next;
237 evlog->blocks = (Evlog_Block *)eina_binbuf_string_steal(buf); 211 if (data >= dataend) return NULL;
238 evlog->blocks_num = num; 212 return data;
239 eina_binbuf_free(buf);
240} 213}
241 214
242static int 215static Eina_Bool
243evlog_block_find(Evlog *evlog, double t) 216evlog_block_read(Evlog *evlog)
244{ 217{
245 int i; 218 unsigned int header[3];
219 Eina_Bool bigendian = EINA_FALSE;
220
221 if (fread(header, 12, 1, evlog->file) != 1) return EINA_FALSE;
222 if (header[0] == 0x0ffee211) bigendian = EINA_FALSE;
223 else if (header[0] == 0x11e2fe0f) bigendian = EINA_TRUE;
224 else return EINA_FALSE;
225 if (!bigendian)
226 {
227 unsigned int blocksize = header[1];
228 unsigned int overflow = header[2];
229 void *buf = malloc(blocksize);
230 if (buf)
231 {
232 void *ptr, *end;
246 233
247 t += evlog->start_t; 234 if (fread(buf, blocksize, 1, evlog->file) != 1)
248 for (i = 0; i < evlog->blocks_num; i++) 235 {
236 free(buf);
237 return EINA_FALSE;
238 }
239 ptr = buf;
240 end = ptr + blocksize;
241 while ((ptr = evlog_event_read(evlog, ptr, end)));
242 free(buf);
243 }
244 }
245 else
249 { 246 {
250 if ((t < evlog->blocks[i].start_t) && (i > 0)) 247 // XXX: handle bigendian
251 return i -1;
252 else if ((i == (evlog->blocks_num - 1)) &&
253 (t <= evlog->blocks[i].end_t))
254 return i;
255 } 248 }
256 return -1; 249 return EINA_TRUE;
257} 250}
258 251
259static Evlog * 252static Evlog *
@@ -267,18 +260,14 @@ evlog_new(const char *file)
267 free(evlog); 260 free(evlog);
268 return EINA_FALSE; 261 return EINA_FALSE;
269 } 262 }
270 _evlog_block_list(evlog); 263 while (evlog_block_read(evlog));
271 if (evlog->blocks_num > 0)
272 {
273 evlog->start_t = evlog->blocks[0].start_t;
274 evlog->end_t = evlog->blocks[evlog->blocks_num - 1].end_t;
275 }
276 return evlog; 264 return evlog;
277} 265}
278 266
279static void 267static void
280evlog_free(Evlog *evlog) 268evlog_free(Evlog *evlog)
281{ 269{
270 // XXX free other stuff
282 fclose(evlog->file); 271 fclose(evlog->file);
283 free(evlog); 272 free(evlog);
284} 273}
@@ -289,368 +278,724 @@ evlog_free(Evlog *evlog)
289 278
290 279
291 280
292typedef struct _Evlog_View Evlog_View;
293typedef struct _Evlog_View_Block Evlog_View_Block;
294typedef struct _Evlog_View_Item Evlog_View_Item;
295 281
296struct _Evlog_View_Item
297{
298 double start_t;
299 double end_t;
300 unsigned long long thread;
301 int level;
302 Evas_Object *obj;
303 char *event;
304};
305 282
306struct _Evlog_View_Block
307{
308 int src_block;
309 Eina_List *items;
310};
311 283
312struct _Evlog_View 284
285
286static Eina_Bool
287_can_see(double t0, double t1, double tmin, double t0in, double t1in)
313{ 288{
314 Evas_Object *scroller, *zoom, *table, *rect, *grid; 289 if (t1in >= 0.0)
315 Evlog *evlog; 290 {
316 double pzoom; 291 if ((t0in <= t1) &&
317 int blocks_start; 292 (t1in >= t0) &&
318 int blocks_end; 293 ((t1in - t0in) >= tmin))
319 Eina_List *blocks; 294 return EINA_TRUE;
320}; 295 }
296 else
297 {
298 if ((t0in <= t1) &&
299 (t0in >= t0))
300 return EINA_TRUE;
301 }
302 return EINA_FALSE;
303}
321 304
322static void 305static Evas_Object *
323evlog_view_zoom_update(Evas_Object *sc) 306_create_log_states(Evas_Object *win, Evlog *evlog, Evas_Object *zoom)
324{ 307{
325 Evlog_View *view = evas_object_data_get(sc, "view"); 308 Evas_Object *o, *oo;
326 double zoom = elm_slider_value_get(view->zoom); 309 double len = evlog->last_timestamp - evlog->first_timestamp;
327 double tlen; 310 int i;
311 int h = 0;
312 Eina_List *events = NULL, *l;
313 Event *ev;
314 Evlog_Event *e;
315 double t;
316
317 o = elm_grid_add(win);
318 for (i = 0; i < evlog->state_num; i++)
319 {
320 e = &(evlog->states[i]);
321 t = e->timestamp - evlog->first_timestamp;
322 if (e->event[0] == '>')
323 {
324 ev = calloc(1, sizeof(Event));
325 if (ev)
326 {
327 ev->src = e;
328 ev->event = strdup(e->event + 1);
329 ev->t0 = t;
330 events = eina_list_append(events, ev);
331 ev->n = eina_list_count(events) - 1;
332 if ((ev->n + 1) > h) h = ev->n + 1;
333 }
334 }
335 else if (e->event[0] == '<')
336 {
337 EINA_LIST_FOREACH(events, l, ev)
338 {
339 if (!strcmp(ev->event, e->event + 1))
340 {
341 ev->t1 = t;
342 free(ev->event);
343 free(ev);
344 events = eina_list_remove_list(events, l);
345 break;
346 }
347 }
348 }
349 }
350 t = evlog->last_timestamp - evlog->first_timestamp;
351 EINA_LIST_FREE(events, ev)
352 {
353 ev->t1 = t;
354 free(ev->event);
355 free(ev);
356 }
328 357
329 tlen = view->evlog->end_t - view->evlog->start_t; 358 if (h < 1) h = 1;
330 evas_object_size_hint_min_set(view->rect, 359 elm_grid_size_set(o, len * RES, h);
331 tlen * zoom * 100.0, 360 double res = elm_slider_value_get(zoom);
332 400); 361 res = res * res;
362 evas_object_size_hint_min_set(o, len * res, h * 20);
363
364 oo = evas_object_rectangle_add(evas_object_evas_get(win));
365 evas_object_color_set(oo, 24, 24, 24, 255);
366 elm_grid_pack(o, oo, 0, 0, len * RES, h);
367 evas_object_show(oo);
368 return o;
333} 369}
334 370
335static void 371static void
336evlog_blocks_clear(Evas_Object *sc) 372_add_log_state(Inf *inf, Event *ev)
337{ 373{
338 Evlog_View *view = evas_object_data_get(sc, "view"); 374 Eina_List *l;
339 Evlog_View_Item *vi; 375 Event *ev2;
340 Evlog_View_Block *b;
341 int i;
342 376
343 EINA_LIST_FREE(view->blocks, b) 377 EINA_LIST_FOREACH(inf->objs, l, ev2)
344 { 378 {
345 EINA_LIST_FREE(b->items, vi) 379 if (ev2->src == ev->src)
346 { 380 {
347 if (vi->obj) evas_object_del(vi->obj); 381 free(ev->event);
348 free(vi->event); 382 free(ev);
349 free(vi); 383 return;
350 } 384 }
351 free(b);
352 } 385 }
386 inf->objs = eina_list_append(inf->objs, ev);
353} 387}
354 388
355static void 389static void
356evlog_view_block_fill(Evas_Object *sc, Evlog_View_Block *b) 390_fill_log_states(Inf *inf, Evlog *evlog, double t0, double t1, double tmin)
357{ 391{
358 Evlog_View *view = evas_object_data_get(sc, "view"); 392 int i;
359 Evlog_View_Item *vi; 393 Eina_List *events = NULL, *l;
360 Evlog_Block *bl; 394 Event *ev;
361 Evlog_Stack *stacks = NULL; 395 Evlog_Event *e;
362 int i, j, stacks_num = 0; 396 double t;
363 int items_num = 0; 397
364 long pos; 398 for (i = 0; i < evlog->state_num; i++)
365 Eina_Evlog_Item item = { 0 };
366
367 if (b->src_block > 0)
368 { 399 {
369 bl = &(view->evlog->blocks[b->src_block - 1]); 400 e = &(evlog->states[i]);
370 for (i = 0; i < bl->end_stacks_num; i++) 401 t = e->timestamp - evlog->first_timestamp;
402 if (e->event[0] == '>')
371 { 403 {
372 Evlog_Stack *stack; 404 ev = calloc(1, sizeof(Event));
373 405 if (ev)
374 stack = _evlog_stack_get(&stacks, &stacks_num, bl->end_stacks[i].thread);
375 if (stack)
376 { 406 {
377 _evlog_stack_dup(&(bl->end_stacks[i]), stack); 407 ev->src = e;
378 for (j = 0; j < stack->items_num; j++) 408 ev->event = strdup(e->event + 1);
409 ev->t0 = t;
410 events = eina_list_append(events, ev);
411 ev->n = eina_list_count(events) - 1;
412 ev->slot = 0;
413 }
414 }
415 else if (e->event[0] == '<')
416 {
417 EINA_LIST_FOREACH(events, l, ev)
418 {
419 if (!strcmp(ev->event, e->event + 1))
379 { 420 {
380 vi = calloc(1, sizeof(Evlog_View_Item)); 421 ev->t1 = t;
381 vi->start_t = stack->items[j].item.tim - view->evlog->start_t; 422 if (_can_see(t0, t1, tmin, ev->t0, ev->t1))
382 vi->end_t = 0.0; 423 _add_log_state(inf, ev);
383 vi->thread = stack->thread; 424 else
384 vi->level = j; 425 {
385 vi->obj = NULL; 426 free(ev->event);
386 vi->event = _evlog_item_event_fetch(view->evlog, stack->items[j].offset, &(stack->items[j].item)); 427 free(ev);
387 b->items = eina_list_append(b->items, vi); 428 }
388 stack->items[j].ptr = vi; 429 events = eina_list_remove_list(events, l);
430 break;
389 } 431 }
390 } 432 }
391 } 433 }
392 } 434 }
393 bl = &(view->evlog->blocks[b->src_block]); 435 t = evlog->last_timestamp - evlog->first_timestamp;
394 fseek(view->evlog->file, bl->start, SEEK_SET); 436 EINA_LIST_FREE(events, ev)
395 while ((pos = _evlog_item_fetch(view->evlog, &item)) >= 0) 437 {
438 ev->t1 = t;
439 if (_can_see(t0, t1, tmin, ev->t0, ev->t1))
440 _add_log_state(inf, ev);
441 else
442 {
443 free(ev->event);
444 free(ev);
445 }
446 }
447}
448
449
450
451
452
453
454
455
456
457static Evas_Object *
458_create_log_thread(Evas_Object *win, Evlog *evlog, Evlog_Thread *th, int slot, Evas_Object *zoom)
459{
460 Evas_Object *o, *oo;
461 double len = evlog->last_timestamp - evlog->first_timestamp;
462 int i, c;
463 int h = 0;
464 Eina_List *stack = NULL, *l;
465 Event *ev;
466 Evlog_Event *e;
467 double t;
468
469 o = elm_grid_add(win);
470 for (i = 0; i < th->event_num; i++)
396 { 471 {
397 char *event = _evlog_item_event_fetch(view->evlog, pos, &item); 472 e = &(th->events[i]);
398 if (event) 473 t = e->timestamp - evlog->first_timestamp;
474 if (e->event[0] == '+')
399 { 475 {
400 printf("EV %s\n", event); 476 ev = calloc(1, sizeof(Event));
401 if (event[0] == '!') 477 if (ev)
402 { 478 {
403 vi = calloc(1, sizeof(Evlog_View_Item)); 479 ev->src = e;
404 vi->start_t = item.tim - view->evlog->start_t; 480 stack = eina_list_append(stack, ev);
405 vi->end_t = -1.0; 481 ev->event = strdup(e->event + 1);
406 vi->thread =item.thread; 482 ev->t0 = t;
407 vi->level = -1; 483 ev->n = eina_list_count(stack) - 1;
408 vi->obj = NULL; 484 if ((ev->n + 1) > h) h = ev->n + 1;
409 vi->event = _evlog_item_event_fetch(view->evlog, pos, &item);
410 b->items = eina_list_append(b->items, vi);
411 } 485 }
412 else if (event[0] == '+') 486 }
487 else if (e->event[0] == '-')
488 {
489 l = eina_list_last(stack);
490 if (l)
413 { 491 {
414 Evlog_Stack *stack; 492 ev = l->data;
493 ev->t1 = t;
494 free(ev->event);
495 free(ev);
496 stack = eina_list_remove_list(stack, l);
497 }
498 }
499 else if (e->event[0] == '!')
500 {
501 }
502 else if (e->event[0] == '*')
503 {
504 }
505 }
506 t = evlog->last_timestamp - evlog->first_timestamp;
507 EINA_LIST_FREE(stack, ev)
508 {
509 ev->t1 = t;
510 free(ev->event);
511 free(ev);
512 }
513 if (h < 1) h = 1;
514 elm_grid_size_set(o, len * RES, h);
515 evas_object_size_hint_min_set(o, 1, h * 20);
516
517 oo = evas_object_rectangle_add(evas_object_evas_get(win));
518 c = 32 + ((slot % 2) * 16);
519 evas_object_color_set(oo, c, c, c, 255);
520 elm_grid_pack(o, oo, 0, 0, len * RES, h);
521 evas_object_show(oo);
522 return o;
523}
415 524
416 stack = _evlog_stack_get(&stacks, &stacks_num, item.thread); 525static void
417 if (stack) 526_add_log_event(Inf *inf, Event *ev)
527{
528 Eina_List *l;
529 Event *ev2;
530
531 EINA_LIST_FOREACH(inf->objs, l, ev2)
532 {
533 if (ev2->src == ev->src)
534 {
535 free(ev->event);
536 free(ev);
537 return;
538 }
539 }
540 inf->objs = eina_list_append(inf->objs, ev);
541}
542
543static void
544_fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0, double t1, double tmin)
545{
546 Eina_List *stack = NULL, *l;
547 Event *ev;
548 int i;
549 int h = 0;
550 Evlog_Event *e;
551 double t;
552
553 for (i = 0; i < th->event_num; i++)
554 {
555 e = &(th->events[i]);
556 t = e->timestamp - evlog->first_timestamp;
557 if (e->event[0] == '+')
558 {
559 ev = calloc(1, sizeof(Event));
560 if (ev)
561 {
562 ev->src = e;
563 stack = eina_list_append(stack, ev);
564 ev->event = strdup(e->event + 1);
565 ev->t0 = t;
566 ev->n = eina_list_count(stack) - 1;
567 ev->slot = slot;
568 if ((ev->n + 1) > h) h = ev->n + 1;
569 }
570 }
571 else if (e->event[0] == '-')
572 {
573 l = eina_list_last(stack);
574 if (l)
575 {
576 ev = l->data;
577 ev->t1 = t;
578 if (_can_see(t0, t1, tmin, ev->t0, ev->t1))
579 _add_log_event(inf, ev);
580 else
418 { 581 {
419 _evlog_stack_push(stack, pos, &item); 582 free(ev->event);
420 j = stack->items_num - 1; 583 free(ev);
421 printf(" %i\n", j);
422 vi = calloc(1, sizeof(Evlog_View_Item));
423 vi->start_t = item.tim - view->evlog->start_t;
424 vi->end_t = 0.0;
425 vi->thread = item.thread;
426 vi->level = j;
427 vi->obj = NULL;
428 vi->event = _evlog_item_event_fetch(view->evlog, pos, &(stack->items[j].item));
429 b->items = eina_list_append(b->items, vi);
430 stack->items[j].ptr = vi;
431 } 584 }
585 stack = eina_list_remove_list(stack, l);
432 } 586 }
433 else if (event[0] == '-') 587 }
588 else if (e->event[0] == '!')
589 {
590 ev = calloc(1, sizeof(Event));
591 if (ev)
434 { 592 {
435 Evlog_Stack *stack = NULL; 593 ev->src = e;
436 594 ev->event = strdup(e->event + 1);
437 stack = _evlog_stack_get(&stacks, &stacks_num, item.thread); 595 ev->t0 = t;
438 if ((stack) && (stack->items_num > 0)) 596 ev->t1 = -1.0;
597 ev->n = 0;
598 ev->slot = -1;
599 if (_can_see(t0, t1, tmin, ev->t0, ev->t1))
600 _add_log_event(inf, ev);
601 else
439 { 602 {
440 char *event_top = _evlog_item_event_fetch 603 free(ev->event);
441 (view->evlog, 604 free(ev);
442 stack->items[stack->items_num - 1].offset,
443 &(stack->items[stack->items_num - 1].item));
444 if ((event_top) &&
445 (!strcmp(event + 1, event_top + 1)))
446 {
447 j = stack->items_num - 1;
448 vi = stack->items[j].ptr;
449 if (vi)
450 {
451 vi->end_t = item.tim - view->evlog->start_t;
452 }
453 _evlog_stack_pop(stack);
454 }
455 free(event_top);
456 } 605 }
457 } 606 }
458 free(event);
459 } 607 }
460 fseek(view->evlog->file, item.event_next, SEEK_CUR); 608 else if (e->event[0] == '*')
609 {
610 }
611 }
612 t = evlog->last_timestamp - evlog->first_timestamp;
613 EINA_LIST_FREE(stack, ev)
614 {
615 ev->t1 = t;
616 if (_can_see(t0, t1, tmin, ev->t0, ev->t1))
617 _add_log_event(inf, ev);
618 else
619 {
620 free(ev->event);
621 free(ev);
622 }
623 }
624}
625
626static void
627_fill_event_clean(Inf *inf, double t0, double t1, double tmin)
628{
629 Eina_List *l;
630 Event *ev;
631
632 EINA_LIST_FOREACH(inf->objs, l, ev)
633 {
634 if (_can_see(t0, t1, tmin, ev->t0, ev->t1))
635 {
636 if (ev->nuke)
637 {
638 inf->update.remobjs = eina_list_remove(inf->update.remobjs, ev);
639 ev->nuke = 0;
640 }
641 }
642 else
643 {
644 if (!ev->nuke)
645 {
646 inf->update.remobjs = eina_list_append(inf->update.remobjs, ev);
647 ev->nuke = 1;
648 }
649 }
461 } 650 }
462} 651}
463 652
464static void 653static void
465evlog_view_update(Evas_Object *sc) 654_fill_log_table(Evas_Object *win, Evas_Object *tb, Evlog *evlog, Evas_Object *zoom)
466{ 655{
467 Evlog_View *view = evas_object_data_get(sc, "view"); 656 Inf *inf = evas_object_data_get(zoom, "inf");
468 double zoom = elm_slider_value_get(view->zoom); 657 Evas_Object *o;
469 Evas_Coord x, y, w, h, ww, hh, xx; 658 char buf[256];
470 double tlen, t0, t1; 659 int i, y = 0;
471 int b0, b1, i;
472 Evlog_View_Block *b;
473 Evlog_View_Item *vi;
474 Eina_List *l, *ln;
475 660
476 evas_output_viewport_get(evas_object_evas_get(sc), NULL, NULL, &ww, &hh); 661 o = elm_label_add(win);
477 evas_object_geometry_get(view->rect, &x, &y, &w, &h); 662 elm_object_text_set(o, "<b>STATES</b>");
478 if (w == 0) return; 663 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
664 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
665 elm_table_pack(tb, o, 0, y, 1, 1);
666 evas_object_show(o);
479 667
480 tlen = view->evlog->end_t - view->evlog->start_t; 668 o = _create_log_states(win, evlog, zoom);
669 inf->grid.state = o;
670 evas_object_size_hint_weight_set(o, 0.0, 0.0);
671 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
672 elm_table_pack(tb, o, 2, y++, 1, 1);
673 evas_object_show(o);
481 674
482 if (x <= 0) t0 = (double)(-x * tlen) / (double)w; 675 inf->grid.thread = calloc(1, evlog->thread_num * sizeof(Evas_Object *));
483 else t0 = 0.0;
484 676
485 xx = x + w; 677 for (i = 0; i < evlog->thread_num; i++)
486 if (xx < ww) t1 = tlen; 678 {
487 else t1 = (double)((ww - x) * tlen) / (double)w; 679 snprintf(buf, sizeof(buf), "<b>%i</b>", i + 1);
488 if (t0 < 0.0) t0 = 0.0; 680
489 if (t1 > tlen) t1 = tlen; 681 o = elm_label_add(win);
682 elm_object_text_set(o, buf);
683 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
684 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
685 elm_table_pack(tb, o, 0, y, 1, 1);
686 evas_object_show(o);
687
688 o = _create_log_thread(win, evlog, &(evlog->threads[i]), i ,zoom);
689 inf->grid.thread[i] = o;
690 evas_object_size_hint_weight_set(o, 0.0, 0.0);
691 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
692 elm_table_pack(tb, o, 2, y++, 1, 1);
693 evas_object_show(o);
694 }
695
696 o = elm_separator_add(win);
697 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
698 evas_object_size_hint_align_set(o, 0.5, EVAS_HINT_FILL);
699 elm_table_pack(tb, o, 1, 0, 1, y);
700 evas_object_show(o);
701
702 o = elm_grid_add(win);
703 inf->grid.over = o;
704 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
705 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
706 elm_grid_size_set(o, (evlog->last_timestamp - evlog->first_timestamp) * RES, 1);
707 elm_table_pack(tb, o, 2, 0, 1, y);
708 evas_object_show(o);
709}
710
711
712
713
714
715
716static void
717_cb_fill_blocking(void *data, Ecore_Thread *thread)
718{
719 Inf *inf = data;
720 int i;
721
722 _fill_event_clean(inf,
723 inf->update.t0 - inf->evlog->first_timestamp,
724 inf->update.t1 - inf->evlog->first_timestamp,
725 inf->update.tmin);
726
727 _fill_log_states(inf, inf->evlog,
728 inf->update.t0 - inf->evlog->first_timestamp,
729 inf->update.t1 - inf->evlog->first_timestamp,
730 inf->update.tmin);
490 731
491 b0 = evlog_block_find(view->evlog, t0); 732 for (i = 0; i < inf->evlog->thread_num; i++)
492 b1 = evlog_block_find(view->evlog, t1);
493 printf("can see from %1.7f to %1.7f [%i %i]\n", t0, t1, b0, b1);
494 if (view->pzoom != zoom)
495 { 733 {
496 evlog_blocks_clear(sc); 734 _fill_log_thread(inf, inf->evlog, &(inf->evlog->threads[i]), i + 1,
497 view->blocks_start = 0; 735 inf->update.t0 - inf->evlog->first_timestamp,
498 view->blocks_end = 0; 736 inf->update.t1 - inf->evlog->first_timestamp,
737 inf->update.tmin);
499 } 738 }
500 if ((view->blocks_start != b0) || (view->blocks_end != (b1 + 1))) 739}
740
741
742
743
744
745
746
747
748
749static Evas_Object *
750_add_log_state_object(Evas_Object *win, Evas_Object *grid, Event *ev)
751{
752 Evas_Object *o, *oe;
753 int col[4] = {255, 255, 255, 255}, i;
754 char *s;
755
756 o = elm_layout_add(win);
757 oe = elm_layout_edje_get(o);
758 elm_layout_file_set(o, "./evlog.edj", "state");
759 i = 0;
760 for (s = ev->event; *s; s++)
501 { 761 {
502 Eina_List *blocks = NULL; 762 col[i % 3] ^= *s;
503 Eina_Bool ok; 763 i++;
764 }
765 edje_object_color_class_set(oe, "state",
766 col[0] / 2, col[1] / 2, col[2] / 2, col[3],
767 255, 255, 255, 255,
768 255, 255, 255, 255);
769 edje_object_part_text_set(oe, "text", ev->event);
770 elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
771 elm_object_tooltip_text_set(o, ev->event);
772 evas_object_show(o);
773 return o;
774}
504 775
505 for (i = b0; i <= b1; i++) 776static Evas_Object *
777_add_log_event_object(Evas_Object *win, Evas_Object *grid, Event *ev)
778{
779 Evas_Object *o, *oe;
780 int col[4] = {255, 255, 255, 255}, i;
781 char *s;
782
783 o = elm_layout_add(win);
784 oe = elm_layout_edje_get(o);
785 elm_layout_file_set(o, "./evlog.edj", "range");
786 i = 0;
787 for (s = ev->event; *s; s++)
788 {
789 col[i % 3] ^= *s;
790 i++;
791 }
792 edje_object_color_class_set(oe, "range",
793 col[0] / 2, col[1] / 2, col[2] / 2, col[3],
794 255, 255, 255, 255,
795 255, 255, 255, 255);
796 edje_object_part_text_set(oe, "text", ev->event);
797 elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
798 elm_object_tooltip_text_set(o, ev->event);
799 evas_object_show(o);
800 return o;
801}
802
803static Evas_Object *
804_add_log_frame_object(Evas_Object *win, Evas_Object *grid, Event *ev)
805{
806 Evas_Object *o, *oe;
807
808 o = elm_layout_add(win);
809 oe = elm_layout_edje_get(o);
810 elm_layout_file_set(o, "./evlog.edj", "frame");
811 elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
812 elm_object_tooltip_text_set(o, ev->event);
813 evas_object_show(o);
814 return o;
815}
816
817static void
818_cb_fill_end(void *data, Ecore_Thread *thread)
819{
820 Inf *inf = data;
821 Event *ev;
822 Evas_Object *o;
823 Eina_List *l;
824
825 inf->update.thread = NULL;
826 EINA_LIST_FOREACH(inf->objs, l, ev)
827 {
828 if ((!ev->obj) && (!ev->nuke))
506 { 829 {
507 ok = EINA_FALSE; 830 if (ev->slot == 0) // state
508 EINA_LIST_FOREACH_SAFE(view->blocks, l, ln, b)
509 { 831 {
510 if (b->src_block == i) 832 o = _add_log_state_object(inf->win,
511 { 833 inf->grid.state,
512 blocks = eina_list_append(blocks, b); 834 ev);
513 view->blocks = eina_list_remove_list(view->blocks, l); 835 ev->obj = o;
514 ok = EINA_TRUE;
515 break;
516 }
517 } 836 }
518 if (!ok) 837 else if (ev->slot > 0) // thread
519 { 838 {
520 b = calloc(1, sizeof(Evlog_View_Block)); 839 o = _add_log_event_object(inf->win,
521 blocks = eina_list_append(blocks, b); 840 inf->grid.thread[ev->slot - 1],
522 b->src_block = i; 841 ev);
523 evlog_view_block_fill(sc, b); 842 ev->obj = o;
524 } 843 }
525 } 844 else if (ev->slot == -1) // frames
526 evlog_blocks_clear(sc);
527 view->blocks = blocks;
528 view->blocks_start = b0;
529 view->blocks_end = b1 + 1;
530 }
531 EINA_LIST_FOREACH(view->blocks, l, b)
532 {
533 EINA_LIST_FOREACH(b->items, ln, vi)
534 {
535 if (!vi->obj)
536 { 845 {
537 double vt0, vt1; 846 if (!strcmp(ev->event, "FRAME"))
538
539 vt0 = vi->start_t;
540 vt1 = vi->end_t;
541// if (vt1 == 0.0) vt1 = t1;
542/*
543 if (vt1 > 0.0)
544 else if (vt1 < 0.0)
545 */
546 if ((vt0 < t1) &&
547 ((vt1 < 0.0) || (vt1 >= t0))
548 )
549 { 847 {
550 if ((vt1 > 0.0) && 848 o = _add_log_frame_object(inf->win,
551 ((((vt1 - vt0) * w) / tlen) >= 4)) 849 inf->grid.over,
552 { 850 ev);
553 vi->obj = edje_object_add(evas_object_evas_get(sc)); 851 ev->obj = o;
554 edje_object_file_set(vi->obj, "./evlog.edj", "range");
555 edje_object_part_text_set(vi->obj, "text", vi->event + 1);
556 elm_grid_pack(view->grid, vi->obj,
557 vt0 * RES,
558 400 - ((vi->level + 1) * 14),
559 (vt1 - vt0) * RES,
560 14);
561 evas_object_show(vi->obj);
562 }
563 else if (vt1 < 0.0)
564 {
565 vi->obj = edje_object_add(evas_object_evas_get(sc));
566 if (!strcmp(vi->event, "!FRAME"))
567 edje_object_file_set(vi->obj, "./evlog.edj", "frame");
568 else
569 edje_object_file_set(vi->obj, "./evlog.edj", "event");
570 edje_object_part_text_set(vi->obj, "text", vi->event + 1);
571 elm_grid_pack(view->grid, vi->obj,
572 (vt0 * RES),
573 0,
574 1,
575 400);
576 evas_object_show(vi->obj);
577 evas_object_lower(vi->obj);
578 }
579 } 852 }
580 } 853 }
581 } 854 }
582 } 855 }
583 view->pzoom = zoom; 856 EINA_LIST_FREE(inf->update.remobjs, ev)
857 {
858 inf->objs = eina_list_remove(inf->objs, ev);
859 if (ev->obj) evas_object_del(ev->obj);
860 free(ev->event);
861 free(ev);
862 }
863 if (inf->update.redo)
864 {
865 inf->update.redo = EINA_FALSE;
866 _fill_begin(inf);
867 }
868}
869
870
871
872
873
874
875
876
877
878
879static void
880_cb_fill_cancel(void *data, Ecore_Thread *thread)
881{
882 Inf *inf = data;
883 inf->update.thread = NULL;
884}
885
886static void
887_fill_begin(Inf *inf)
888{
889 Evas_Coord x, w, wx, ww;
890 double t, t0, t1;
891 Evas_Coord gw;
892
893 if (inf->update.thread)
894 {
895 inf->update.redo = EINA_TRUE;
896 return;
897 }
898 elm_grid_size_get(inf->grid.state, &gw, NULL);
899 evas_object_geometry_get(inf->grid.state, &x, NULL, &w, NULL);
900 evas_output_viewport_get(evas_object_evas_get(inf->grid.state),
901 &wx, NULL, &ww, NULL);
902 if (ww < 1) ww = 1;
903 if (w < 1) w = 1;
904 if (w < ww) w = ww;
905 if (gw < 1) gw = 1;
906
907 t0 = inf->evlog->first_timestamp;
908 t1 = inf->evlog->last_timestamp;
909
910 inf->update.tmin = (1.0 * (double)gw) / ((double)w * RES);
911
912 wx -= 100;
913 ww += 200;
914
915 t = ((t1 - t0) * (double)ww) / ((double)w);
916 t0 = ((wx - x) * (t1 - t0)) / ((double)w);
917 if (t0 < 0.0) t0 = 0.0;
918 inf->update.t0 = t0 + inf->evlog->first_timestamp;
919 inf->update.t1 = inf->update.t0 + t;
920 inf->update.thread = ecore_thread_run(_cb_fill_blocking,
921 _cb_fill_end,
922 _cb_fill_cancel,
923 inf);
924}
925
926static void
927_cb_fill_job(void *data)
928{
929 Inf *inf = evas_object_data_get(data, "inf");
930 inf->update.job = NULL;
931 _fill_begin(inf);
932}
933
934static void
935_fill_update(Evas_Object *zoom)
936{
937 Inf *inf = evas_object_data_get(zoom, "inf");
938 if (inf->update.job) ecore_job_del(inf->update.job);
939 inf->update.job = ecore_job_add(_cb_fill_job, zoom);
584} 940}
585 941
586static void 942static void
587_cb_zoom(void *data, Evas_Object *obj, void *info) 943_cb_zoom(void *data, Evas_Object *obj, void *info)
588{ 944{
589 evlog_view_zoom_update(data); 945 Inf *inf = evas_object_data_get(data, "inf");
946 Evas_Coord w = 0, h = 1;
947 evas_object_size_hint_min_get(inf->grid.state, &w, &h);
948 if (w < 1) w = 1;
949 double len = inf->evlog->last_timestamp - inf->evlog->first_timestamp;
950 double res = elm_slider_value_get(obj);
951 Evas_Coord sx, sy, sw, sh;
952 elm_scroller_region_get(inf->scroller, &sx, &sy, &sw, &sh);
953 res = res * res;
954 evas_object_size_hint_min_set(inf->grid.state, len * res, h);
955 double snx = ((double)(sx + (sw / 2)) * (len * res)) / (double)w;
956 double snw = ((double)(sw) * (len * res)) / (double)w;
957 elm_scroller_region_show(inf->scroller, snx - (snw / 2), sy, snw, sh);
590} 958}
591 959
592static void 960static void
593_cb_move(void *data, Evas *e, Evas_Object *obj, void *info) 961_cb_move(void *data, Evas *e, Evas_Object *obj, void *info)
594{ 962{
595 evlog_view_update(data); 963 _fill_update(data);
596} 964}
597 965
598static void 966static void
599_cb_resize(void *data, Evas *e, Evas_Object *obj, void *info) 967_cb_resize(void *data, Evas *e, Evas_Object *obj, void *info)
600{ 968{
601 evlog_view_update(data); 969 _fill_update(data);
602} 970}
603 971
604static void 972static void
605_cb_sc_resize(void *data, Evas *e, Evas_Object *obj, void *info) 973_cb_sc_resize(void *data, Evas *e, Evas_Object *obj, void *info)
606{ 974{
607 evlog_view_update(data); 975 _fill_update(data);
608} 976}
609 977
610static Evas_Object * 978static Evas_Object *
611evlog_view_add(Evas_Object *win, Evlog *evlog, Evas_Object *zoom) 979evlog_view_add(Evas_Object *win, Evlog *evlog, Evas_Object *zoom)
612{ 980{
981 Inf *inf = evas_object_data_get(zoom, "inf");
613 Evas_Object *o; 982 Evas_Object *o;
614 Evas_Object *sc, *tb, *gr, *rc; 983 Evas_Object *sc, *tb;
615 Evlog_View *view;
616 984
617 sc = o = elm_scroller_add(win); 985 sc = o = elm_scroller_add(win);
618 986 inf->scroller = o;
619 view = calloc(1, sizeof(Evlog_View)); 987 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _cb_sc_resize, zoom);
620 evas_object_data_set(sc, "view", view);
621 view->scroller = sc;
622 view->zoom = zoom;
623 view->evlog = evlog;
624
625 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _cb_sc_resize, sc);
626 988
627 tb = o = elm_table_add(win); 989 tb = o = elm_table_add(win);
628 view->table = o; 990 evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _cb_move, zoom);
629 evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _cb_move, sc); 991 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _cb_resize, zoom);
630 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _cb_resize, sc);
631 992
632 rc = o = evas_object_rectangle_add(evas_object_evas_get(win)); 993 _fill_log_table(win, tb, evlog, zoom);
633 view->rect = o;
634 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
635 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
636 evas_object_color_set(o, 48, 48, 48, 255);
637 elm_table_pack(tb, o, 0, 0, 1, 1);
638 evas_object_show(o);
639
640 gr = o = elm_grid_add(win);
641 view->grid = o;
642 elm_grid_size_set(o, (evlog->end_t - evlog->start_t) * RES, 400);
643 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
644 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
645 elm_table_pack(tb, o, 0, 0, 1, 1);
646 evas_object_show(o);
647 994
648 elm_object_content_set(sc, tb); 995 elm_object_content_set(sc, tb);
649 evas_object_show(tb); 996 evas_object_show(tb);
650 997
651 evas_object_smart_callback_add(zoom, "changed", _cb_zoom, sc); 998 evas_object_smart_callback_add(zoom, "changed", _cb_zoom, zoom);
652 evlog_view_zoom_update(sc);
653 evlog_view_update(sc);
654 return sc; 999 return sc;
655} 1000}
656 1001
@@ -660,15 +1005,21 @@ elm_main(int argc, char **argv)
660 Evlog *evl; 1005 Evlog *evl;
661 Evas_Object *o; 1006 Evas_Object *o;
662 Evas_Object *box; 1007 Evas_Object *box;
1008 Inf *inf;
663 1009
664 if (argc < 2) return -1; 1010 if (argc < 2) return -1;
665 evl = evlog_new(argv[1]); 1011 evl = evlog_new(argv[1]);
666 if (!evl) return -1; 1012 if (!evl) return -1;
667 1013
1014 inf = calloc(1, sizeof(Inf));
1015 inf->evlog = evl;
1016
668 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 1017 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
669 1018
670 win = elm_win_util_standard_add("evlog", "Event Log"); 1019 win = elm_win_util_standard_add("evlog", "Event Log");
1020 inf->win = win;
671 elm_win_autodel_set(win, EINA_TRUE); 1021 elm_win_autodel_set(win, EINA_TRUE);
1022 evas_object_data_set(win, "inf", inf);
672 1023
673 box = o = elm_box_add(win); 1024 box = o = elm_box_add(win);
674 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1025 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -677,9 +1028,10 @@ elm_main(int argc, char **argv)
677 evas_object_show(o); 1028 evas_object_show(o);
678 1029
679 zoom_slider = o = elm_slider_add(win); 1030 zoom_slider = o = elm_slider_add(win);
680 elm_slider_min_max_set(o, 1.0, 10000.0); 1031 evas_object_data_set(o, "inf", inf);
1032 elm_slider_min_max_set(o, 1.0, 500.0);
681 elm_slider_step_set(o, 0.1); 1033 elm_slider_step_set(o, 0.1);
682 elm_slider_value_set(o, 500.0); 1034 elm_slider_value_set(o, 20.0);
683 elm_object_text_set(o, "Zoom"); 1035 elm_object_text_set(o, "Zoom");
684 elm_slider_unit_format_set(o, "%1.1f"); 1036 elm_slider_unit_format_set(o, "%1.1f");
685 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); 1037 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@@ -693,7 +1045,7 @@ elm_main(int argc, char **argv)
693 elm_box_pack_end(box, o); 1045 elm_box_pack_end(box, o);
694 evas_object_show(o); 1046 evas_object_show(o);
695 1047
696 evas_object_resize(win, 480, 480); 1048 evas_object_resize(win, 620, 400);
697 1049
698 evas_object_show(win); 1050 evas_object_show(win);
699 elm_run(); 1051 elm_run();
diff --git a/evlog.edc b/evlog.edc
index edaef04..f480ee4 100644
--- a/evlog.edc
+++ b/evlog.edc
@@ -1,66 +1,56 @@
1#define TILED_PATTERN(_WIDTH, _HEIGHT) \
2 fill { size { relative: 0.0 0.0; offset: _WIDTH _HEIGHT; } }
3
1collections { 4collections {
2 images.image: "box_glow.png" COMP; 5 images.image: "box_glow.png" COMP;
3 images.image: "box_outline.png" COMP; 6 images.image: "box_outline.png" COMP;
4 7
5 group { name: "range"; 8 group { name: "range";
6 parts { 9 parts {
7 part { name: "bg"; 10 part { name: "bg"; type: RECT;
8 description { state: "default" 0.0; 11 description { state: "default" 0.0;
9 rel1.offset: -9 -9; 12 rel1.offset: 1 1;
10 rel2.offset: 8 8; 13 rel2.offset: -2 -2;
11 image.normal: "box_glow.png"; 14 color_class: "range";
12 image.border: 12 12 12 12;
13 } 15 }
14 } 16 }
15 part { name: "text"; type: TEXT; 17 part { name: "text"; type: TEXT;
16 effect: SHADOW BOTTOM;
17 scale: 1; 18 scale: 1;
18 description { state: "default" 0.0; 19 description { state: "default" 0.0;
20 rel1.to: "bg";
21 rel2.to: "bg";
19 color: 255 255 255 255; 22 color: 255 255 255 255;
20 color3: 0 0 0 128;
21 text { font: "Sans"; size: 10; 23 text { font: "Sans"; size: 10;
22 min: 0 1; 24 min: 0 1;
23 align: 0.0 1.0; 25 align: 0.0 1.0;
24 text_class: "fileman_icon";
25 } 26 }
26 } 27 }
27 } 28 }
28 part { name: "over";
29 description { state: "default" 0.0;
30 rel1.to: "bg";
31 rel2.to: "bg";
32 image.normal: "box_outline.png";
33 image.border: 12 12 12 12;
34 }
35 }
36 } 29 }
37 } 30 }
38 31
39 images.image: "runner_vert.png" COMP; 32 images.image: "diagonal_stripes.png" COMP;
40 33
41 group { name: "event"; 34 group { name: "state";
42 parts { 35 parts {
43 part { name: "bg"; 36 part { name: "bg";
44 description { state: "default" 0.0; 37 description { state: "default" 0.0;
45 image.normal: "runner_vert.png"; 38 rel1.offset: 1 1;
46 image.border: 1 1 2 2; 39 rel2.offset: -2 -2;
47 fill.smooth: 0; 40 color_class: "state";
48 min: 3 6; 41 TILED_PATTERN(240, 240)
49 max: 3 9999; 42 image.normal: "diagonal_stripes.png";
50 } 43 }
51 } 44 }
52 part { name: "text"; type: TEXT; 45 part { name: "text"; type: TEXT;
53 effect: SHADOW BOTTOM;
54 scale: 1; 46 scale: 1;
55 description { state: "default" 0.0; 47 description { state: "default" 0.0;
56 rel1.offset: 4 0; 48 rel1.to: "bg";
57 rel2.offset: 4 -1; 49 rel2.to: "bg";
58 color: 21 21 21 255; 50 color: 255 255 255 255;
59 color3: 255 255 255 25;
60 align: 0.0 0.0;
61 text { font: "Sans"; size: 10; 51 text { font: "Sans"; size: 10;
62 min: 1 1; 52 min: 0 1;
63 align: 0.0 0.0; 53 align: 0.0 1.0;
64 } 54 }
65 } 55 }
66 } 56 }
@@ -71,6 +61,12 @@ collections {
71 61
72 group { name: "frame"; 62 group { name: "frame";
73 parts { 63 parts {
64 part { name: "base"; type: RECT;
65 description { state: "default" 0.0;
66 color: 51 153 255 128;
67 min: 1 1;
68 }
69 }
74 part { name: "bg"; 70 part { name: "bg";
75 description { state: "default" 0.0; 71 description { state: "default" 0.0;
76 image.normal: "handle_pick_up_right.png"; 72 image.normal: "handle_pick_up_right.png";
diff --git a/img/box_glow.png b/img/box_glow.png
deleted file mode 100644
index 785eb6d..0000000
--- a/img/box_glow.png
+++ /dev/null
Binary files differ
diff --git a/img/box_outline.png b/img/box_outline.png
deleted file mode 100644
index b171359..0000000
--- a/img/box_outline.png
+++ /dev/null
Binary files differ
diff --git a/img/diagonal_stripes.png b/img/diagonal_stripes.png
new file mode 100644
index 0000000..6fa9138
--- /dev/null
+++ b/img/diagonal_stripes.png
Binary files differ
diff --git a/img/runner_vert.png b/img/runner_vert.png
deleted file mode 100644
index 1db8e6c..0000000
--- a/img/runner_vert.png
+++ /dev/null
Binary files differ