1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2006 Parisa heidari (inspired from CFV by Mathieu Desnoyers)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 /*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
25 /* Event hooks are the drawing hooks called during traceset read. They draw the
26 * icons, text, lines and background color corresponding to the events read.
28 * Two hooks are used for drawing : before_schedchange and after_schedchange hooks. The
29 * before_schedchange is called before the state update that occurs with an event and
30 * the after_schedchange hook is called after this state update.
32 * The before_schedchange hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the after_schedchange hook.
35 * The after_schedchange hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next before_schedchange hook will draw what that
37 * queue contains. That's the Right Way (TM) of drawing items on the screen,
38 * because we need to draw the background first (and then add icons, text, ...
39 * over it), but we only know the length of a background region once the state
40 * corresponding to it is over, which happens to be at the next before_schedchange
43 * We also have a hook called at the end of a chunk to draw the information left
44 * undrawn in each process queue. We use the current time as end of
52 //#define PANGO_ENABLE_BACKEND
60 //#include <pango/pango.h>
62 #include <ltt/event.h>
64 #include <ltt/trace.h>
66 #include <lttv/lttv.h>
67 #include <lttv/hook.h>
68 #include <lttv/state.h>
69 #include <lttvwindow/lttvwindow.h>
70 #include <lttvwindow/lttvwindowtraces.h>
71 #include <lttvwindow/support.h>
74 #include "histoeventhooks.h"
76 #include "histobuttonwidget.h"
77 #include "histodrawing.h"
80 #define MAX_PATH_LEN 256
81 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
83 // fixed #define TRACE_NUMBER 0
84 #define EXTRA_ALLOC 1024 // pixels
86 /* Action to do when background computation completed.
88 * Wait for all the awaited computations to be over.
91 static gint
histo_background_ready(void *hook_data
, void *call_data
)
93 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*)hook_data
;
94 LttvTrace
*trace
= (LttvTrace
*)call_data
;
96 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
97 histocontrol_flow_data
->background_info_waiting
--;
99 if(histocontrol_flow_data
->background_info_waiting
== 0) {
100 g_message("Histocontrol flow viewer : background computation data ready.");
102 histo_drawing_clear(drawing
,0,drawing
->width
);
104 gtk_widget_set_size_request(drawing
->drawing_area
,
106 histo_redraw_notify(histocontrol_flow_data
, NULL
);
113 /* Request background computation. Verify if it is in progress or ready first.
114 * Only for each trace in the tab's traceset.
116 static void histo_request_background_data(HistoControlFlowData
*histocontrol_flow_data
)
118 LttvTracesetContext
* tsc
=
119 lttvwindow_get_traceset_context(histocontrol_flow_data
->tab
);
120 gint num_traces
= lttv_traceset_number(tsc
->ts
);
123 LttvTraceState
*tstate
;
125 LttvHooks
*histo_background_ready_hook
=
127 lttv_hooks_add(histo_background_ready_hook
, histo_background_ready
, histocontrol_flow_data
,
129 histocontrol_flow_data
->background_info_waiting
= 0;
131 for(i
=0;i
<num_traces
;i
++) {
132 trace
= lttv_traceset_get(tsc
->ts
, i
);
133 tstate
= LTTV_TRACE_STATE(tsc
->traces
[i
]);
135 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
136 && !tstate
->has_precomputed_states
) {
138 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
140 /* We first remove requests that could have been done for the same
141 * information. Happens when two viewers ask for it before servicing
144 if(!lttvwindowtraces_background_request_find(trace
, "state"))
145 lttvwindowtraces_background_request_queue(
146 main_window_get_widget(histocontrol_flow_data
->tab
), trace
, "state");
147 lttvwindowtraces_background_notify_queue(histocontrol_flow_data
,
151 histo_background_ready_hook
);
152 histocontrol_flow_data
->background_info_waiting
++;
153 } else { /* in progress */
155 lttvwindowtraces_background_notify_current(histocontrol_flow_data
,
159 histo_background_ready_hook
);
160 histocontrol_flow_data
->background_info_waiting
++;
163 /* Data ready. Be its nature, this viewer doesn't need to have
164 * its data ready hook called there, because a background
165 * request is always linked with a redraw.
171 lttv_hooks_destroy(histo_background_ready_hook
);
175 * Histogram Viewer's constructor hook
177 * This constructor is given as a parameter to the menuitem and toolbar button
178 * registration. It creates the list.
179 * @param tab A pointer to the parent tab.
180 * @return The widget created.
183 h_guihistocontrolflow(LttvPlugin
*plugin
)
185 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
186 g_info("h_guihistocontrolflow, %p", ptab
);
187 HistoControlFlowData
*histocontrol_flow_data
= guihistocontrolflow(ptab
) ;
189 Tab
*tab
= ptab
->tab
;
190 histocontrol_flow_data
->tab
= tab
;
192 // Unreg done in the GuiHistoControlFlow_Destructor
193 lttvwindow_register_traceset_notify(tab
,
194 histo_traceset_notify
,
195 histocontrol_flow_data
);
197 lttvwindow_register_time_window_notify(tab
,
198 histo_update_time_window_hook
,
199 histocontrol_flow_data
);
200 lttvwindow_register_current_time_notify(tab
,
201 histo_update_current_time_hook
,
202 histocontrol_flow_data
);
203 lttvwindow_register_redraw_notify(tab
,
205 histocontrol_flow_data
);
206 lttvwindow_register_continue_notify(tab
,
207 histo_continue_notify
,
208 histocontrol_flow_data
);
209 //added for histogram, enable filter:
210 lttvwindow_register_filter_notify(tab
,
211 histo_filter_changed
,histocontrol_flow_data
);
212 histocontrol_flow_data
->histo_main_win_filter
= lttvwindow_get_filter(tab
);
214 // histo_request_background_data(histocontrol_flow_data);
216 return guihistocontrolflow_get_widget(histocontrol_flow_data
) ;
222 /// added for histogram.
223 void histo_request_event( HistoControlFlowData
*histocontrol_flow_data
, guint x
, guint width
)
225 if(width
< 0) return ;
228 Tab
*tab
= histocontrol_flow_data
->tab
;
229 TimeWindow time_window
= lttvwindow_get_time_window( tab
);
230 LttTime time_start
, time_end
;
234 //find the tracehooks
235 LttvTracesetContext
*tsc
= lttvwindow_get_traceset_context(tab
);
237 LttvTraceset
*traceset
= tsc
->ts
;
238 nb_trace
= lttv_traceset_number(traceset
);
239 guint drawing_width
= histocontrol_flow_data
->drawing
->width
;
240 //start time for chunk.
241 histo_convert_pixels_to_time(drawing_width
, /*0*/x
, time_window
,
243 //end time for chunk.
244 histo_convert_pixels_to_time(drawing_width
,
245 /*width*/x
+width
,time_window
,
247 time_end
= ltt_time_add(time_end
, ltt_time_one
); // because main window
248 // doesn't deliver end time.
250 lttvwindow_events_request_remove_all(tab
,
251 histocontrol_flow_data
);
254 // LttvHooksById *histo_event_by_id = lttv_hooks_by_id_new();//if necessary for filter!
255 // FIXME : eventually request for more traces
256 // fixed for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
257 for(i
=0;i
<nb_trace
;i
++) {
258 //should be in the loop or before?
259 EventsRequest
*histo_events_request
= g_new(EventsRequest
, 1);
261 LttvHooks
*histo_before_trace_hooks
= lttv_hooks_new();
262 lttv_hooks_add(histo_before_trace_hooks
, histo_before_trace
,
263 histo_events_request
, LTTV_PRIO_DEFAULT
);
265 LttvHooks
*histo_count_event_hooks
= lttv_hooks_new();
266 lttv_hooks_add(histo_count_event_hooks
, histo_count_event
,
267 histo_events_request
, LTTV_PRIO_DEFAULT
);
269 LttvHooks
*histo_after_trace_hooks
= lttv_hooks_new();
270 lttv_hooks_add(histo_after_trace_hooks
, histo_after_trace
,
271 histo_events_request
, LTTV_PRIO_DEFAULT
);
274 LttvHooks
*histo_before_chunk_traceset
= lttv_hooks_new();
275 LttvHooks
*histo_after_chunk_traceset
= lttv_hooks_new();
277 lttv_hooks_add(histo_before_chunk_traceset
,
279 histo_events_request
,
282 lttv_hooks_add(histo_after_chunk_traceset
,
284 histo_events_request
,
286 ts
= (LttvTraceState
*)tsc
->traces
[i
];
287 // Fill the events request
288 histo_events_request
->owner
= histocontrol_flow_data
;
289 histo_events_request
->viewer_data
= histocontrol_flow_data
;
290 histo_events_request
->servicing
= FALSE
;
291 histo_events_request
->start_time
= time_start
;//time_window.start_time;
293 histo_events_request
->start_position
= NULL
;
294 histo_events_request
->stop_flag
= FALSE
;
295 histo_events_request
->end_time
= time_end
;//time_window.end_time;
297 histo_events_request
->num_events
= G_MAXUINT
;
298 histo_events_request
->end_position
= NULL
;
299 histo_events_request
->trace
= i
;
300 histo_events_request
->hooks
= NULL
;
301 histo_events_request
->before_chunk_traceset
= histo_before_chunk_traceset
;//NULL;
302 histo_events_request
->before_chunk_trace
= NULL
;
303 histo_events_request
->before_chunk_tracefile
= NULL
;
304 histo_events_request
->event
= histo_count_event_hooks
;
305 histo_events_request
->event_by_id
= NULL
;//histo_event_by_id;//NULL;
306 histo_events_request
->after_chunk_tracefile
= NULL
;
307 histo_events_request
->after_chunk_trace
= NULL
;
308 histo_events_request
->after_chunk_traceset
= histo_after_chunk_traceset
;//NULL;
309 histo_events_request
->before_request
= histo_before_trace_hooks
;
310 histo_events_request
->after_request
= histo_after_trace_hooks
;
312 lttvwindow_events_request(histocontrol_flow_data
->tab
, histo_events_request
);
317 //hook,added for histogram
318 int histo_count_event(void *hook_data
, void *call_data
){
320 guint x
;//time to pixel
321 guint i
;// number of events
326 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
327 HistoControlFlowData
*histocontrol_flow_data
= events_request
->viewer_data
;
329 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
330 int width
= drawing
->width
;
332 g_info("Histogram: count_event() \n");
335 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
336 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
338 e
= ltt_tracefile_get_event(tfc
->tf
);
340 LttvFilter
*histo_filter
= histocontrol_flow_data
->histo_main_win_filter
;
341 if(histo_filter
!= NULL
&& histo_filter
->head
!= NULL
)
342 if(!lttv_filter_tree_parse(histo_filter
->head
,e
,tfc
->tf
,
343 tfc
->t_context
->t
,tfc
,NULL
,NULL
))
346 TimeWindow time_window
= lttvwindow_get_time_window(histocontrol_flow_data
->tab
);
347 event_time
= ltt_event_time(e
);
349 histo_convert_time_to_pixels(
354 element
= &g_array_index(histocontrol_flow_data
->number_of_process
, guint
, x
);
359 ///befor hook:Added for histogram
360 int histo_before_trace(void *hook_data
, void *call_data
){
362 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
363 HistoControlFlowData
*histocontrol_flow_data
= events_request
->viewer_data
;
365 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
367 //in order to reset all of the array elements.
369 end
= MIN(histocontrol_flow_data
->number_of_process
->len
,drawing
->damage_end
);
370 for(i
=drawing
->damage_begin
/*0*/;
371 i
< end
/*histocontrol_flow_data->number_of_process->len*/;i
++)
373 g_array_index(histocontrol_flow_data
->number_of_process
, guint
, i
) = 0;
375 histo_drawing_clear(drawing
,drawing
->damage_begin
/*0*/,
376 drawing
->damage_end
- drawing
->damage_begin
/*drawing->width*/);
377 //g_array_free(histocontrol_flow_data->number_of_process,TRUE);
378 //histocontrol_flow_data->number_of_process =g_array_new (FALSE,
380 // sizeof(guint));//4 byte for guint
381 //g_array_set_size (histocontrol_flow_data->number_of_process,
382 // drawing->drawing_area->allocation.width);
383 // gtk_widget_set_size_request(drawing->drawing_area,-1,-1);
384 gtk_widget_queue_draw(drawing
->drawing_area
);
387 //after hook,added for histogram
388 int histo_after_trace(void *hook_data
, void *call_data
){
390 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
391 HistoControlFlowData
*histocontrol_flow_data
= events_request
->viewer_data
;
392 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
393 guint x
, x_end
, width
;
394 LttTime end_time
= events_request
->end_time
;
395 TimeWindow time_window
=
396 lttvwindow_get_time_window(histocontrol_flow_data
->tab
);
398 g_debug("histo after trace");
400 histo_convert_time_to_pixels(
405 x
= drawing
->damage_begin
;
407 drawing
->damage_begin
= x
+width
;
408 histogram_show (histocontrol_flow_data
,x
,x_end
);
413 void histogram_show(HistoControlFlowData
*histocontrol_flow_data
,guint draw_begin
,
416 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
417 GtkWidget
*drawingarea
= histo_drawing_get_drawing_area(drawing
);
418 guint width
= drawing
->width
;
419 guint height
= drawing
->height
;//drawingarea->allocation.height;
421 /* gdk_gc_set_line_attributes(drawing->gc,
427 histo_drawing_clear(drawing
,draw_begin
,draw_end
);
429 TimeWindow time_window
=
430 lttvwindow_get_time_window(histocontrol_flow_data
->tab
);
434 guint i
,line_src
,line_end
;
435 guint end_chunk
=MIN(draw_end
,(histocontrol_flow_data
->number_of_process
)->len
);
437 for (i
=draw_begin
/*0*/;i
<end_chunk
/* (histocontrol_flow_data->number_of_process)->len*/;i
++){
438 val
=g_array_index(histocontrol_flow_data
->number_of_process
,guint
,i
);
439 h_val
= height
-((height
*val
)/histocontrol_flow_data
->max_height
);
441 histo_convert_pixels_to_time(width
, i
,
444 histo_convert_pixels_to_time(width
, i
+1,
449 //check if zoom in is used and more than 1 pixel correspond to each 1nsec
450 //used for drawing point (not line) on the screen.
451 /* while (ltt_time_compare(t1,t2)==0)
453 histo_convert_pixels_to_time(width, i++,
456 histo_convert_pixels_to_time(width, i+1,
462 */ //replaced later for lines.
464 if(val
> drawing
->histo_control_flow_data
->max_height
){
465 //overlimit, yellow color
466 gdk_gc_set_foreground(drawing
->gc
,&histo_drawing_colors
[COL_WHITE
] );//COL_RUN_TRAP
467 gdk_draw_line (drawing
->pixmap
,
473 gdk_gc_set_foreground(drawing
->gc
,&histo_drawing_colors
[COL_RUN_USER_MODE
] );
474 gdk_draw_line (drawing
->pixmap
,
480 while ((ltt_time_compare(t1
,t2
)==0)&&(i
<end_chunk
))//-1 , i to be incremented later
484 if(val
> drawing
->histo_control_flow_data
->max_height
){
485 //overlimit, yellow color
486 gdk_gc_set_foreground(drawing
->gc
,
487 &histo_drawing_colors
[COL_RUN_TRAP
] );
488 gdk_draw_line (drawing
->pixmap
,
494 gdk_gc_set_foreground(drawing
->gc
,&histo_drawing_colors
[COL_RUN_USER_MODE
] );
495 gdk_draw_line (drawing
->pixmap
,
500 histo_convert_pixels_to_time(width
, i
,
504 histo_convert_pixels_to_time(width
, i
+1,
508 }//while (t1==t2)////
512 histo_drawing_update_vertical_ruler(drawing
);
513 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
515 draw_end
-draw_begin
, drawing
->height
);
516 gdk_window_process_updates(drawingarea
->window
,TRUE
);
519 int histo_event_selected_hook(void *hook_data
, void *call_data
)
521 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*) hook_data
;
522 guint
*event_number
= (guint
*) call_data
;
524 g_debug("DEBUG : event selected by main window : %u", *event_number
);
531 /* histo_before_schedchange_hook
533 * This function basically draw lines and icons. Two types of lines are drawn :
534 * one small (3 pixels?) representing the state of the process and the second
535 * type is thicker (10 pixels?) representing on which CPU a process is running
536 * (and this only in running state).
538 * Extremums of the lines :
539 * x_min : time of the last event context for this process kept in memory.
540 * x_max : time of the current event.
541 * y : middle of the process in the process list. The process is found in the
542 * list, therefore is it's position in pixels.
544 * The choice of lines'color is defined by the context of the last event for this
549 int histo_before_schedchange_hook(void *hook_data, void *call_data)
555 gint
histo_update_time_window_hook(void *hook_data
, void *call_data
)
557 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*) hook_data
;
558 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
560 const TimeWindowNotifyData
*histo_time_window_nofify_data
=
561 ((const TimeWindowNotifyData
*)call_data
);
563 TimeWindow
*histo_old_time_window
=
564 histo_time_window_nofify_data
->old_time_window
;
565 TimeWindow
*histo_new_time_window
=
566 histo_time_window_nofify_data
->new_time_window
;
569 histo_drawing_update_ruler(drawing
,
570 histo_new_time_window
);
572 /* Two cases : zoom in/out or scrolling */
574 /* In order to make sure we can reuse the old drawing, the scale must
575 * be the same and the new time interval being partly located in the
576 * currently shown time interval. (reuse is only for scrolling)
579 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
580 histo_old_time_window
->start_time
.tv_sec
,
581 histo_old_time_window
->start_time
.tv_nsec
,
582 histo_old_time_window
->time_width
.tv_sec
,
583 histo_old_time_window
->time_width
.tv_nsec
);
585 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
586 histo_new_time_window
->start_time
.tv_sec
,
587 histo_new_time_window
->start_time
.tv_nsec
,
588 histo_new_time_window
->time_width
.tv_sec
,
589 histo_new_time_window
->time_width
.tv_nsec
);
591 //For Histo,redraw always except if zoom fit is pushed 2 times consequently
592 if( histo_new_time_window
->start_time
.tv_sec
== histo_old_time_window
->start_time
.tv_sec
593 && histo_new_time_window
->start_time
.tv_nsec
== histo_old_time_window
->start_time
.tv_nsec
594 && histo_new_time_window
->time_width
.tv_sec
== histo_old_time_window
->time_width
.tv_sec
595 && histo_new_time_window
->time_width
.tv_nsec
== histo_old_time_window
->time_width
.tv_nsec
)
599 histo_rectangle_pixmap (drawing
->drawing_area
->style
->black_gc
,
602 drawing
->width
,//+SAFETY, // do not overlap
605 drawing
->damage_begin
= 0;
606 drawing
->damage_end
= drawing
->width
;
608 gtk_widget_queue_draw(drawing
->drawing_area
);
609 histo_request_event(histocontrol_flow_data
,drawing
->damage_begin
,
610 drawing
->damage_end
- drawing
->damage_begin
);
612 gdk_window_process_updates(drawing
->drawing_area
->window
,TRUE
);
614 //show number of event at current time
616 histo_drawing_update_vertical_ruler(drawing
);
620 /*// if( histo_new_time_window->time_width.tv_sec == histo_old_time_window->time_width.tv_sec
621 && histo_new_time_window->time_width.tv_nsec == histo_old_time_window->time_width.tv_nsec)
623 // Same scale (scrolling)
626 while scrolling no matter far or near ,
627 right or left it's necessary to redraw whole screen!*/
628 /*// LttTime *ns = &histo_new_time_window->start_time;
629 LttTime *nw = &histo_new_time_window->time_width;
630 LttTime *os = &histo_old_time_window->start_time;
631 LttTime *ow = &histo_old_time_window->time_width;
632 LttTime histo_old_end = histo_old_time_window->end_time;
633 LttTime histo_new_end = histo_new_time_window->end_time;
635 //if(ns<os+w && os+w<ns+w)
636 //if(ns<histo_old_end && os<ns)
638 //added for histogram
639 gtk_widget_queue_draw(drawing->drawing_area);
641 drawing->damage_begin = 0;
642 drawing->damage_end = drawing->width;
644 //replaced for hisogram
645 histo_request_event(histocontrol_flow_data,drawing->damage_begin,
646 drawing->damage_end- drawing->damage_begin);
648 if(ltt_time_compare(*ns, histo_old_end) == -1
649 && ltt_time_compare(*os, *ns) == -1)
651 g_info("scrolling near right");
652 // Scroll right, keep right part of the screen
654 guint width = drawing->width;
655 histo_convert_time_to_pixels(
656 *histo_old_time_window,
661 // Copy old data to new location
662 //replaced for histogram:
663 histo_copy_pixmap_region(drawing,NULL,
664 drawing->drawing_area->style->black_gc,//drawing->gc,
667 0, 0, (drawing->width-x)
670 if(drawing->damage_begin == drawing->damage_end)
671 drawing->damage_begin = drawing->width-x;
673 drawing->damage_begin = 0;
675 drawing->damage_end = drawing->width;
677 //(histo) copy corresponding array region too:
680 for(i=0; i < histocontrol_flow_data->number_of_process->len-x;i++)
682 g_array_index(histocontrol_flow_data->number_of_process, guint, i) =
683 g_array_index(histocontrol_flow_data->number_of_process, guint, i+x);
686 // Clear the data request background, but not SAFETY
689 //not necessary for histo, because in before chunk ,it clears the area
690 /* histo_rectangle_pixmap (
691 drawing->drawing_area->style->black_gc,
693 drawing->damage_begin, 0,
694 drawing->damage_end - drawing->damage_begin, // do not overlap
697 /* gtk_widget_queue_draw(drawing->drawing_area);
698 //gtk_widget_queue_draw_area (drawing->drawing_area,
700 // histocontrol_flow_data->drawing->width,
701 // histocontrol_flow_data->drawing->height);
703 // Get new data for the rest.
704 //replaced for hisogram
705 histo_request_event(histocontrol_flow_data,drawing->damage_begin,
706 drawing->damage_end- drawing->damage_begin);
709 //if(ns<os && os<ns+w)
710 //if(ns<os && os<histo_new_end)
711 if(ltt_time_compare(*ns,*os) == -1
712 && ltt_time_compare(*os,histo_new_end) == -1)
714 g_info("scrolling near left");
715 // Scroll left, keep left part of the screen
717 guint width = drawing->width;
718 histo_convert_time_to_pixels(
719 *histo_new_time_window,
724 // Copy old data to new location
725 //replaced for histogram
727 histo_copy_pixmap_region(drawing,NULL,
728 drawing->drawing_area->style->black_gc,//drawing->gc,
732 //(histo) copy corresponding array region too:
734 for(i=histocontrol_flow_data->number_of_process->len; i > x-1;i--)
736 g_array_index(histocontrol_flow_data->number_of_process, guint, i) =
737 g_array_index(histocontrol_flow_data->number_of_process, guint, i-x);
740 if(drawing->damage_begin == drawing->damage_end)
741 drawing->damage_end = x;
743 drawing->damage_end =
746 drawing->damage_begin = 0;
749 //not necessary for histo, because in before chunk ,it clears the area
750 /* histo_rectangle_pixmap (drawing->drawing_area->style->black_gc,
752 drawing->damage_begin, 0,
753 drawing->damage_end - drawing->damage_begin, // do not overlap
756 /* gtk_widget_queue_draw(drawing->drawing_area);
757 //gtk_widget_queue_draw_area (drawing->drawing_area,
759 // histocontrol_flow_data->drawing->width,
760 // histocontrol_flow_data->drawing->height);
763 // Get new data for the rest.
765 //replaced for hisogram
766 histo_request_event(histocontrol_flow_data,drawing->damage_begin,
767 drawing->damage_end- drawing->damage_begin);
770 if(ltt_time_compare(*ns,*os) == 0)
772 g_info("not scrolling");
774 g_info("scrolling far");
775 // Cannot reuse any part of the screen : far jump
777 //not necessary for histo, because in before chunk ,it clears the area
778 /* histo_rectangle_pixmap (histocontrol_flow_data->drawing->drawing_area->style->black_gc,
781 histocontrol_flow_data->drawing->width,//+SAFETY, // do not overlap
784 //gtk_widget_queue_draw_area (drawing->drawing_area,
786 // histocontrol_flow_data->drawing->width,
787 // histocontrol_flow_data->drawing->height);
788 /* gtk_widget_queue_draw(drawing->drawing_area);
790 drawing->damage_begin = 0;
791 drawing->damage_end = histocontrol_flow_data->drawing->width;
793 histo_drawing_data_request(histocontrol_flow_data->drawing,
795 histocontrol_flow_data->drawing->width,
796 histocontrol_flow_data->drawing->height);*/
797 //replaced for hisogram
798 /* histo_request_event(histocontrol_flow_data,drawing->damage_begin,
799 drawing->damage_end- drawing->damage_begin);
804 // Different scale (zoom)
807 //not necessary for histo, because in before chunk ,it clears the area
809 histo_rectangle_pixmap (drawing->drawing_area->style->black_gc,
812 histocontrol_flow_data->drawing->width+SAFETY, // do not overlap
815 //gtk_widget_queue_draw_area (drawing->drawing_area,
817 // histocontrol_flow_data->drawing->width,
818 // histocontrol_flow_data->drawing->height);
819 /*// gtk_widget_queue_draw(drawing->drawing_area);
821 drawing->damage_begin = 0;
822 drawing->damage_end = drawing->width;
824 //replaced for hisogram
825 histo_request_event(histocontrol_flow_data,drawing->damage_begin,
826 drawing->damage_end- drawing->damage_begin);
829 // Update directly when scrolling
830 gdk_window_process_updates(drawing->drawing_area->window,
833 //show number of event at current time
835 histo_drawing_update_vertical_ruler(drawing);
837 //disabled for histogram, always redraw whole screen.
841 gint
histo_traceset_notify(void *hook_data
, void *call_data
)
843 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*) hook_data
;
844 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
846 if(unlikely(drawing
->gc
== NULL
)) {
849 if(drawing
->dotted_gc
== NULL
) {
853 histo_drawing_clear(drawing
,0,drawing
->width
);
856 for(i
=0;i
< histocontrol_flow_data
->number_of_process
->len
;i
++)
858 g_array_index(histocontrol_flow_data
->number_of_process
, guint
, i
) = 0;
860 gtk_widget_set_size_request(
861 drawing
->drawing_area
,
863 histo_redraw_notify(histocontrol_flow_data
, NULL
);
865 ///histo_request_background_data(histocontrol_flow_data);
870 gint
histo_redraw_notify(void *hook_data
, void *call_data
)
872 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*) hook_data
;
873 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
874 GtkWidget
*widget
= drawing
->drawing_area
;
876 drawing
->damage_begin
= 0;
877 drawing
->damage_end
= drawing
->width
;
879 // fun feature, to be separated someday...
881 histo_drawing_clear(drawing
,0,drawing
->width
);
883 gtk_widget_set_size_request(
884 drawing
->drawing_area
,
888 histo_rectangle_pixmap (widget
->style
->black_gc
,
891 drawing
->alloc_width
,
893 gtk_widget_queue_draw(widget
);
896 if(drawing
->damage_begin
< drawing
->damage_end
)
898 //replaced for histogram
899 histo_request_event(histocontrol_flow_data
,0,drawing
->width
);
903 //gtk_widget_queue_draw_area(drawing->drawing_area,
912 gint
histo_continue_notify(void *hook_data
, void *call_data
)
914 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*) hook_data
;
915 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
917 //g_assert(widget->allocation.width == drawing->damage_end);
919 if(drawing
->damage_begin
< drawing
->damage_end
)
921 histo_request_event(histocontrol_flow_data
,drawing
->damage_begin
,
922 drawing
->damage_end
-drawing
->damage_begin
);
929 gint
histo_update_current_time_hook(void *hook_data
, void *call_data
)
931 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*)hook_data
;
932 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
934 LttTime current_time
= *((LttTime
*)call_data
);
936 TimeWindow time_window
=
937 lttvwindow_get_time_window(histocontrol_flow_data
->tab
);
939 LttTime time_begin
= time_window
.start_time
;
940 LttTime width
= time_window
.time_width
;
943 guint64 time_ll
= ltt_time_to_uint64(width
);
944 time_ll
= time_ll
>> 1; /* divide by two */
945 half_width
= ltt_time_from_uint64(time_ll
);
947 LttTime time_end
= ltt_time_add(time_begin
, width
);
949 LttvTracesetContext
* tsc
=
950 lttvwindow_get_traceset_context(histocontrol_flow_data
->tab
);
952 LttTime trace_start
= tsc
->time_span
.start_time
;
953 LttTime trace_end
= tsc
->time_span
.end_time
;
955 g_info("Histogram: New current time HOOK : %lu, %lu", current_time
.tv_sec
,
956 current_time
.tv_nsec
);
960 /* If current time is inside time interval, just move the highlight
963 /* Else, we have to change the time interval. We have to tell it
964 * to the main window. */
965 /* The time interval change will take care of placing the current
966 * time at the center of the visible area, or nearest possible if we are
967 * at one end of the trace. */
970 if(ltt_time_compare(current_time
, time_begin
) < 0)
972 TimeWindow histo_new_time_window
;
974 if(ltt_time_compare(current_time
,
975 ltt_time_add(trace_start
,half_width
)) < 0)
976 time_begin
= trace_start
;
978 time_begin
= ltt_time_sub(current_time
,half_width
);
980 histo_new_time_window
.start_time
= time_begin
;
981 histo_new_time_window
.time_width
= width
;
982 histo_new_time_window
.time_width_double
= ltt_time_to_double(width
);
983 histo_new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
985 lttvwindow_report_time_window(histocontrol_flow_data
->tab
, histo_new_time_window
);
987 else if(ltt_time_compare(current_time
, time_end
) > 0)
989 TimeWindow histo_new_time_window
;
991 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
992 time_begin
= ltt_time_sub(trace_end
,width
);
994 time_begin
= ltt_time_sub(current_time
,half_width
);
996 histo_new_time_window
.start_time
= time_begin
;
997 histo_new_time_window
.time_width
= width
;
998 histo_new_time_window
.time_width_double
= ltt_time_to_double(width
);
999 histo_new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1001 lttvwindow_report_time_window(histocontrol_flow_data
->tab
, histo_new_time_window
);
1004 gtk_widget_queue_draw(drawing
->drawing_area
);
1006 /* Update directly when scrolling */
1007 gdk_window_process_updates(drawing
->drawing_area
->window
,
1010 histo_drawing_update_vertical_ruler(drawing
);
1015 gboolean
histo_filter_changed(void * hook_data
, void * call_data
)
1017 HistoControlFlowData
*histocontrol_flow_data
= (HistoControlFlowData
*)hook_data
;
1018 histoDrawing_t
*drawing
=histocontrol_flow_data
->drawing
;
1020 LttvTracesetContext
* tsc
=
1021 lttvwindow_get_traceset_context(histocontrol_flow_data
->tab
);
1023 histocontrol_flow_data
->histo_main_win_filter
=
1024 (LttvFilter
*)call_data
;
1025 //get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
1026 gtk_widget_set_size_request(
1027 drawing
->drawing_area
,
1029 drawing
->damage_begin
= 0;
1030 drawing
->damage_end
= drawing
->width
;
1032 /* //done in, before request!
1033 histo_drawing_clear(drawing,0,drawing->width);
1035 for(i=0;i < histocontrol_flow_data->number_of_process->len;i++)
1037 g_array_index(histocontrol_flow_data->number_of_process, guint, i) = 0;
1040 histo_request_event(histocontrol_flow_data
,0,drawing
->width
);
1045 typedef struct _histo_ClosureData
{
1046 EventsRequest
*events_request
;
1047 LttvTracesetState
*tss
;
1050 } histo_ClosureData
;
1054 int histo_before_chunk(void *hook_data
, void *call_data
)
1056 EventsRequest
*histo_events_request
= (EventsRequest
*)hook_data
;
1057 LttvTracesetState
*histo_tss
= (LttvTracesetState
*)call_data
;
1058 HistoControlFlowData
*histo_cfd
= (HistoControlFlowData
*)histo_events_request
->viewer_data
;
1060 /* Desactivate sort */
1061 gtk_tree_sortable_set_sort_column_id(
1062 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
1064 GTK_SORT_ASCENDING
);
1066 histo_drawing_chunk_begin(histo_events_request
, histo_tss
);
1071 /*int histo_before_request(void *hook_data, void *call_data)
1073 EventsRequest *events_request = (EventsRequest*)hook_data;
1074 LttvTracesetState *tss = (LttvTracesetState*)call_data;
1076 histo_drawing_data_request_begin(events_request, tss);
1084 * after request is necessary in addition of after chunk in order to draw
1085 * lines until the end of the screen. after chunk just draws lines until
1092 /*int histo_after_request(void *hook_data, void *call_data)
1103 int histo_after_chunk(void *hook_data
, void *call_data
)
1105 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1106 HistoControlFlowData
*histocontrol_flow_data
= events_request
->viewer_data
;
1107 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
1108 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
1109 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
1112 histoDrawing_t
*drawing
= histocontrol_flow_data
->drawing
;
1114 if(!histocontrol_flow_data
->chunk_has_begun
) return;
1115 histocontrol_flow_data
->chunk_has_begun
= TRUE
;
1118 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
1119 else /* end of traceset, or position now out of request : end */
1120 end_time
= events_request
->end_time
;
1122 guint x
, x_end
, width
;
1124 TimeWindow time_window
=
1125 lttvwindow_get_time_window(histocontrol_flow_data
->tab
);
1127 g_debug("histo after chunk");
1129 histo_convert_time_to_pixels(
1134 x
= drawing
->damage_begin
;
1136 drawing
->damage_begin
= x
+width
;
1138 histogram_show (histocontrol_flow_data
,x
,x_end
);