X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Fcontrolflow%2Fdrawing.c;h=d1b631006bedd4fb0583642f5393396f7ac3d79d;hb=41a9e0c379c701161640b4b87d5b92ecb6f654e0;hp=d9d4a03d48f7c4c490db7102a5256eec83c96776;hpb=b9a010a28d9625c9d31968aa44f1a553daccb294;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index d9d4a03d..d1b63100 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -33,6 +33,27 @@ #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) + +GdkColor drawing_colors[NUM_COLORS] = +{ /* Pixel, R, G, B */ + { 0, 0, 0, 0 }, /* COL_BLACK */ + { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_WHITE */ + { 0, 0x0FFF, 0xFFFF, 0xFFFF }, /* COL_WAIT_FORK : pale blue */ + { 0, 0xFFFF, 0xFFFF, 0x0000 }, /* COL_WAIT_CPU : yellow */ + { 0, 0xFFFF, 0xA000, 0xFCFF }, /* COL_EXIT : pale magenta */ + { 0, 0xFFFF, 0x0000, 0xFFFF }, /* COL_ZOMBIE : purple */ + { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_WAIT : red */ + { 0, 0x0000, 0xFFFF, 0x0000 }, /* COL_RUN : green */ + { 0, 0x8800, 0xFFFF, 0x8A00 }, /* COL_USER_MODE : pale green */ + { 0, 0x09FF, 0x01FF, 0xFFFF }, /* COL_SYSCALL : blue */ + { 0, 0xF900, 0x4200, 0xFF00 }, /* COL_TRAP : pale purple */ + { 0, 0xFFFF, 0x5AFF, 0x01FF }, /* COL_IRQ : orange */ + { 0, 0xFFFF, 0xFFFF, 0xFFFF } /* COL_MODE_UNKNOWN : white */ + +}; + + + /***************************************************************************** * drawing functions * *****************************************************************************/ @@ -44,28 +65,6 @@ static gboolean motion_notify_ruler(GtkWidget *widget, GdkEventMotion *event, gpointer user_data); -//FIXME Colors will need to be dynamic. Graphic context part not done so far. -typedef enum -{ - RED, - GREEN, - BLUE, - WHITE, - BLACK - -} ControlFlowColors; - -/* Vector of unallocated colors */ -static GdkColor CF_Colors [] = -{ - { 0, 0xffff, 0x0000, 0x0000 }, // RED - { 0, 0x0000, 0xffff, 0x0000 }, // GREEN - { 0, 0x0000, 0x0000, 0xffff }, // BLUE - { 0, 0xffff, 0xffff, 0xffff }, // WHITE - { 0, 0x0000, 0x0000, 0x0000 } // BLACK -}; - - /* Function responsible for updating the exposed area. * It must do an events request to the lttvwindow API to ask for this update. * Note : this function cannot clear the background, because it may @@ -148,13 +147,32 @@ void drawing_data_request(Drawing_t *drawing, events_request, LTTV_PRIO_DEFAULT); - + /* FIXME : hooks are registered global instead of by ID. + * This is due to the lack of granularity of main window's events requests. + * Should be fixed for gain of performance. + */ + lttv_hooks_add(event, + before_schedchange_hook, + events_request, + LTTV_PRIO_STATE-5); + lttv_hooks_add(event, + after_schedchange_hook, + events_request, + LTTV_PRIO_STATE+5); + lttv_hooks_add(event, + before_execmode_hook, + events_request, + LTTV_PRIO_STATE-5); + lttv_hooks_add(event, + after_execmode_hook, + events_request, + LTTV_PRIO_STATE+5); lttv_hooks_add(event, - draw_before_hook, + before_process_hook, events_request, LTTV_PRIO_STATE-5); lttv_hooks_add(event, - draw_after_hook, + after_process_hook, events_request, LTTV_PRIO_STATE+5); @@ -168,6 +186,7 @@ void drawing_data_request(Drawing_t *drawing, events_request->end_time = time_end; events_request->num_events = G_MAXUINT; events_request->end_position = NULL; + events_request->trace = 0; /* FIXME */ events_request->before_chunk_traceset = before_chunk_traceset; events_request->before_chunk_trace = NULL; events_request->before_chunk_tracefile = NULL; @@ -197,7 +216,9 @@ static void set_last_start(gpointer key, gpointer value, gpointer user_data) HashedProcessData *hashed_process_data = (HashedProcessData*)value; guint x = (guint)user_data; - hashed_process_data->x = x; + hashed_process_data->x.over = x; + hashed_process_data->x.middle = x; + hashed_process_data->x.under = x; return; } @@ -234,7 +255,8 @@ void drawing_chunk_begin(EventsRequest *events_request, LttvTracesetState *tss) LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss); LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp; - cfd->drawing->last_start = current_time; + //cfd->drawing->last_start = LTT_TIME_MIN(current_time, + // events_request->end_time); } @@ -255,7 +277,7 @@ void drawing_request_expose(EventsRequest *events_request, LttTime window_end = ltt_time_add(time_window.time_width, time_window.start_time); - +#if 0 convert_time_to_pixels( time_window.start_time, window_end, @@ -263,13 +285,15 @@ void drawing_request_expose(EventsRequest *events_request, drawing->width, &x); +#endif //0 convert_time_to_pixels( time_window.start_time, window_end, end_time, drawing->width, &x_end); - + x = drawing->damage_begin; + // x_end = drawing->damage_end; width = x_end - x; drawing->damage_begin = x+width; @@ -402,14 +426,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) LttTime window_end = ltt_time_add(time_window.time_width, time_window.start_time); - convert_time_to_pixels( - time_window.start_time, - window_end, - current_time, - drawing->width, - &cursor_x); - /* update the screen from the pixmap buffer */ gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], @@ -418,30 +435,41 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) event->area.x, event->area.y, event->area.width, event->area.height); + + if(ltt_time_compare(time_window.start_time, current_time) <= 0 && + ltt_time_compare(window_end, current_time) >= 0) + { + /* Draw the dotted lines */ + convert_time_to_pixels( + time_window.start_time, + window_end, + current_time, + drawing->width, + &cursor_x); - /* Draw the dotted lines */ - if(drawing->dotted_gc == NULL) { + if(drawing->dotted_gc == NULL) { - drawing->dotted_gc = gdk_gc_new(drawing->drawing_area->window); - gdk_gc_copy(drawing->dotted_gc, widget->style->white_gc); - - gint8 dash_list[] = { 1, 2 }; - gdk_gc_set_line_attributes(drawing->dotted_gc, - 1, - GDK_LINE_ON_OFF_DASH, - GDK_CAP_BUTT, - GDK_JOIN_MITER); - gdk_gc_set_dashes(drawing->dotted_gc, - 0, - dash_list, - 2); - } + drawing->dotted_gc = gdk_gc_new(drawing->drawing_area->window); + gdk_gc_copy(drawing->dotted_gc, widget->style->white_gc); + + gint8 dash_list[] = { 1, 2 }; + gdk_gc_set_line_attributes(drawing->dotted_gc, + 1, + GDK_LINE_ON_OFF_DASH, + GDK_CAP_BUTT, + GDK_JOIN_MITER); + gdk_gc_set_dashes(drawing->dotted_gc, + 0, + dash_list, + 2); + } - drawing_draw_line(NULL, widget->window, - cursor_x, 0, - cursor_x, drawing->height, - drawing->dotted_gc); + drawing_draw_line(NULL, widget->window, + cursor_x, 0, + cursor_x, drawing->height, + drawing->dotted_gc); + } return FALSE; } @@ -456,6 +484,27 @@ after_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data } +#if 0 +void +tree_row_activated(GtkTreeModel *treemodel, + GtkTreePath *arg1, + GtkTreeViewColumn *arg2, + gpointer user_data) +{ + ControlFlowData *cfd = (ControlFlowData*)user_data; + Drawing_t *drawing = cfd->drawing; + GtkTreeView *treeview = cfd->process_list->process_list_widget; + gint *path_indices; + gint height; + + path_indices = gtk_tree_path_get_indices (arg1); + + height = get_cell_height(cfd->process_list, + GTK_TREE_VIEW(treeview)); + drawing->horizontal_sel = height * path_indices[0]; + g_critical("new hor sel : %i", drawing->horizontal_sel); +} +#endif //0 /* mouse click */ static gboolean @@ -486,13 +535,10 @@ button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data window_end, &time); - lttvwindow_report_current_time(control_flow_data->tab, &time); + lttvwindow_report_current_time(control_flow_data->tab, time); } - lttvwindow_report_focus(control_flow_data->tab, - gtk_widget_get_parent(guicontrolflow_get_widget(control_flow_data))); - return FALSE; } @@ -523,11 +569,9 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) drawing->ruler_hbox = gtk_hbox_new(FALSE, 1); drawing->ruler = gtk_drawing_area_new (); - gtk_widget_add_events(drawing->ruler, GDK_BUTTON_PRESS_MASK); //gtk_widget_set_size_request(drawing->ruler, -1, 27); drawing->padding = gtk_drawing_area_new (); - gtk_widget_add_events(drawing->padding, GDK_BUTTON_PRESS_MASK); //gtk_widget_set_size_request(drawing->padding, -1, 27); gtk_box_pack_start(GTK_BOX(drawing->ruler_hbox), drawing->ruler, TRUE, TRUE, 0); @@ -579,6 +623,7 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) drawing->damage_begin = 0; drawing->damage_end = 0; + drawing->horizontal_sel = -1; //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50); g_object_set_data_full( @@ -616,8 +661,6 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) // drawing->drawing_area->allocation.height, // -1); - gtk_widget_add_events(drawing->drawing_area, GDK_BUTTON_PRESS_MASK); - g_signal_connect (G_OBJECT(drawing->drawing_area), "configure_event", G_CALLBACK (configure_event), @@ -700,8 +743,7 @@ GtkWidget *drawing_get_widget(Drawing_t *drawing) * * Convert from window pixel and time interval to an absolute time. */ -//FIXME : could need ceil and floor versions of this function -void convert_pixels_to_time( +__inline void convert_pixels_to_time( gint width, guint x, LttTime window_time_begin, @@ -709,16 +751,18 @@ void convert_pixels_to_time( LttTime *time) { LttTime window_time_interval; + guint64 time_ll; window_time_interval = ltt_time_sub(window_time_end, window_time_begin); - *time = ltt_time_mul(window_time_interval, (x/(float)width)); + time_ll = ltt_time_to_uint64(window_time_interval); + time_ll = time_ll * x / width; + *time = ltt_time_from_uint64(time_ll); *time = ltt_time_add(window_time_begin, *time); } -//FIXME : could need ceil and floor versions of this function -void convert_time_to_pixels( +__inline void convert_time_to_pixels( LttTime window_time_begin, LttTime window_time_end, LttTime time, @@ -726,17 +770,19 @@ void convert_time_to_pixels( guint *x) { LttTime window_time_interval; - double interval_double, time_double; + guint64 time_ll, interval_ll; + + g_assert(ltt_time_compare(window_time_begin, time) <= 0 && + ltt_time_compare(window_time_end, time) >= 0); window_time_interval = ltt_time_sub(window_time_end,window_time_begin); time = ltt_time_sub(time, window_time_begin); - /* LttTime to double conversions here should really be under 4000 hours.. */ - interval_double = ltt_time_to_double(window_time_interval); - time_double = ltt_time_to_double(time); + time_ll = ltt_time_to_uint64(time); + interval_ll = ltt_time_to_uint64(window_time_interval); - *x = (guint)(time_double/interval_double * width); + *x = (guint)(time_ll * width / interval_ll); }