From 6395d57c1887bfba11a50d1d1905dc0f01f6a5a5 Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 16 Jul 2004 03:37:30 +0000 Subject: [PATCH] background computation for control flow viewer git-svn-id: http://ltt.polymtl.ca/svn@625 04897980-b3bd-0310-b5e0-8ef037075253 --- .../poly/lttv/modules/gui/controlflow/cfv.c | 4 + .../lttv/modules/gui/controlflow/drawing.c | 59 +++--- .../lttv/modules/gui/controlflow/drawing.h | 2 - .../lttv/modules/gui/controlflow/eventhooks.c | 181 ++++++++++++++++-- .../lttv/modules/gui/controlflow/eventhooks.h | 1 + 5 files changed, 187 insertions(+), 60 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c index 64254f24..508eb23e 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c @@ -167,6 +167,10 @@ guicontrolflow_destructor(ControlFlowData *control_flow_data) if(tab != NULL) { /* Delete reading hooks */ + lttvwindow_unregister_traceset_notify(tab, + traceset_notify, + control_flow_data); + lttvwindow_unregister_time_window_notify(tab, update_time_window_hook, control_flow_data); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 375ed570..091bcb8a 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -218,7 +218,7 @@ void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState * width = x_end - x; drawing->damage_begin = x+width; - drawing->damage_end = drawing->width; + //drawing->damage_end = drawing->width; /* ask for the buffer to be redrawn */ gtk_widget_queue_draw_area ( drawing->drawing_area, @@ -234,6 +234,9 @@ void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState * /* Create a new backing pixmap of the appropriate size */ /* As the scaling will always change, it's of no use to copy old * pixmap. + * + * Only change the size if width changes. The height is specified and changed + * when process ID are added or removed from the process list. */ static gboolean configure_event( GtkWidget *widget, GdkEventConfigure *event, @@ -256,17 +259,15 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, // widget->allocation.height + SAFETY, // -1); - g_debug("drawing configure event"); - g_debug("New draw size : %i by %i",widget->allocation.width, + if(widget->allocation.width != drawing->width) { + g_debug("drawing configure event"); + g_debug("New draw size : %i by %i",widget->allocation.width, widget->allocation.height); - if (drawing->pixmap) - gdk_pixmap_unref(drawing->pixmap); + if (drawing->pixmap) + gdk_pixmap_unref(drawing->pixmap); - /* If no old pixmap present */ - //if(drawing->pixmap == NULL) - { drawing->pixmap = gdk_pixmap_new( widget->window, widget->allocation.width + SAFETY, @@ -309,12 +310,11 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, &drawing->pixmap, drawing->damage_begin, 0, - drawing->damage_end, + drawing->damage_end - drawing->damage_begin, widget->allocation.height); } - - return TRUE; } + return TRUE; } @@ -568,6 +568,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( gint width, guint x, @@ -583,7 +584,7 @@ void convert_pixels_to_time( *time = ltt_time_add(window_time_begin, *time); } - +//FIXME : could need ceil and floor versions of this function void convert_time_to_pixels( LttTime window_time_begin, @@ -620,19 +621,6 @@ void drawing_draw_line( Drawing_t *drawing, -void drawing_resize(Drawing_t *drawing, guint h, guint w) -{ - drawing->height = h ; - drawing->width = w ; - - gtk_widget_set_size_request ( drawing->drawing_area, - drawing->width, - drawing->height); - - -} - - /* Insert a square corresponding to a new process in the list */ /* Applies to whole drawing->width */ void drawing_insert_square(Drawing_t *drawing, @@ -686,12 +674,11 @@ void drawing_insert_square(Drawing_t *drawing, drawing->height+=height; - /* Rectangle to update, from new drawing dimensions */ - //update_rect.x = 0 ; - //update_rect.y = y ; - //update_rect.width = drawing->width; - //update_rect.height = drawing->height - y ; - //gtk_widget_draw( drawing->drawing_area, &update_rect); + /* ask for the buffer to be redrawn */ + gtk_widget_queue_draw_area ( drawing->drawing_area, + 0, y, + drawing->width, drawing->height-y); + } @@ -735,12 +722,10 @@ void drawing_remove_square(Drawing_t *drawing, drawing->height-=height; - /* Rectangle to update, from new drawing dimensions */ - //update_rect.x = 0 ; - //update_rect.y = y ; - //update_rect.width = drawing->width; - //update_rect.height = drawing->height - y ; - //gtk_widget_draw( drawing->drawing_area, &update_rect); + /* ask for the buffer to be redrawn */ + gtk_widget_queue_draw_area ( drawing->drawing_area, + 0, y, + drawing->width, drawing->height-y); } void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h index 8ee55f18..a36fdf49 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h @@ -102,8 +102,6 @@ void drawing_remove_square(Drawing_t *drawing, guint height); -//void drawing_Resize(Drawing_t *drawing, guint h, guint w); - void convert_pixels_to_time( gint width, guint x, diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index 75609d09..5ac72454 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "eventhooks.h" @@ -52,6 +53,79 @@ #define MAX_PATH_LEN 256 +/* Action to do when background computation completed. + * + * Eventually, will have to check that every requested traces are finished + * before doing the redraw. + */ + +gint background_ready(void *hook_data, void *call_data) +{ + ControlFlowData *control_flow_data = (ControlFlowData *)hook_data; + LttvTrace *trace = (LttvTrace*)call_data; + + g_debug("control flow viewer : background computation data ready."); + + redraw_notify(control_flow_data, NULL); + + return 0; +} + + +/* Request background computation. Verify if it is in progress or ready first. + * + * Right now, for all loaded traces. + * + * Later : must be only for each trace in the tab's traceset. + */ +void request_background_data(ControlFlowData *control_flow_data) +{ + gint num_traces = lttvwindowtraces_get_number(); + gint i; + LttvTrace *trace; + + LttvHooks *background_ready_hook = + lttv_hooks_new(); + lttv_hooks_add(background_ready_hook, background_ready, control_flow_data, + LTTV_PRIO_DEFAULT); + + for(i=0;itime_width); // Unreg done in the GuiControlFlow_Destructor + lttvwindow_register_traceset_notify(tab, + traceset_notify, + control_flow_data); + lttvwindow_register_time_window_notify(tab, update_time_window_hook, control_flow_data); @@ -82,7 +160,8 @@ h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key) lttvwindow_register_continue_notify(tab, continue_notify, control_flow_data); - + request_background_data(control_flow_data); + return guicontrolflow_get_widget(control_flow_data) ; @@ -1271,28 +1350,35 @@ gint update_time_window_hook(void *hook_data, void *call_data) control_flow_data->drawing->pixmap, x, 0, 0, 0, - -1, -1); - + control_flow_data->drawing->width-x+SAFETY, -1); + + if(drawing->damage_begin == drawing->damage_end) + drawing->damage_begin = control_flow_data->drawing->width-x; + else + drawing->damage_begin = 0; + + drawing->damage_end = control_flow_data->drawing->width; + /* Clear the data request background, but not SAFETY */ gdk_draw_rectangle (control_flow_data->drawing->pixmap, + //control_flow_data->drawing->drawing_area->style->black_gc, control_flow_data->drawing->drawing_area->style->black_gc, TRUE, - x+SAFETY, 0, - control_flow_data->drawing->width - x, // do not overlap + drawing->damage_begin+SAFETY, 0, + drawing->damage_end - drawing->damage_begin, // do not overlap control_flow_data->drawing->height+SAFETY); - gtk_widget_queue_draw_area (drawing->drawing_area, + gtk_widget_queue_draw_area (drawing->drawing_area, 0,0, - control_flow_data->drawing->width - x, + control_flow_data->drawing->width, control_flow_data->drawing->height); /* Get new data for the rest. */ drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, - x, 0, - control_flow_data->drawing->width - x, + drawing->damage_begin, 0, + drawing->damage_end - drawing->damage_begin, control_flow_data->drawing->height); - } else { //if(nsdrawing->pixmap, control_flow_data->drawing->drawing_area->style->black_gc, @@ -1321,24 +1408,32 @@ gint update_time_window_hook(void *hook_data, void *call_data) *old_time_window = *new_time_window; - /* Clean the data request background */ + if(drawing->damage_begin == drawing->damage_end) + drawing->damage_end = x; + else + drawing->damage_end = + control_flow_data->drawing->drawing_area->allocation.width; + + drawing->damage_begin = 0; + gdk_draw_rectangle (control_flow_data->drawing->pixmap, control_flow_data->drawing->drawing_area->style->black_gc, TRUE, - 0, 0, - x, // do not overlap + drawing->damage_begin, 0, + drawing->damage_end - drawing->damage_begin, // do not overlap control_flow_data->drawing->height+SAFETY); - gtk_widget_queue_draw_area (drawing->drawing_area, - x,0, - control_flow_data->drawing->width - x, + gtk_widget_queue_draw_area (drawing->drawing_area, + 0,0, + control_flow_data->drawing->width, control_flow_data->drawing->height); + /* Get new data for the rest. */ drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, - 0, 0, - x, + drawing->damage_begin, 0, + drawing->damage_end - drawing->damage_begin, control_flow_data->drawing->height); } else { @@ -1362,6 +1457,9 @@ gint update_time_window_hook(void *hook_data, void *call_data) control_flow_data->drawing->width, control_flow_data->drawing->height); + drawing->damage_begin = 0; + drawing->damage_end = control_flow_data->drawing->width; + drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, 0, 0, @@ -1387,12 +1485,14 @@ gint update_time_window_hook(void *hook_data, void *call_data) control_flow_data->drawing->width, control_flow_data->drawing->height); + drawing->damage_begin = 0; + drawing->damage_end = control_flow_data->drawing->width; + drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, 0, 0, control_flow_data->drawing->width, control_flow_data->drawing->height); - } @@ -1400,6 +1500,45 @@ gint update_time_window_hook(void *hook_data, void *call_data) return 0; } +gint traceset_notify(void *hook_data, void *call_data) +{ + ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; + Drawing_t *drawing = control_flow_data->drawing; + GtkWidget *widget = drawing->drawing_area; + + drawing->damage_begin = 0; + drawing->damage_end = widget->allocation.width; + + + // Clear the image + gdk_draw_rectangle (drawing->pixmap, + widget->style->black_gc, + TRUE, + 0, 0, + widget->allocation.width+SAFETY, + widget->allocation.height+SAFETY); + + + if(drawing->damage_begin < drawing->damage_end) + { + drawing_data_request(drawing, + &drawing->pixmap, + drawing->damage_begin, + 0, + drawing->damage_end-drawing->damage_begin, + widget->allocation.height); + } + + gtk_widget_queue_draw_area(drawing->drawing_area, + 0,0, + drawing->width, + drawing->height); + + request_background_data(control_flow_data); + + return FALSE; +} + gint redraw_notify(void *hook_data, void *call_data) { ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; @@ -1445,7 +1584,7 @@ gint continue_notify(void *hook_data, void *call_data) Drawing_t *drawing = control_flow_data->drawing; GtkWidget *widget = drawing->drawing_area; - g_assert(widget->allocation.width == drawing->damage_end); + //g_assert(widget->allocation.width == drawing->damage_end); if(drawing->damage_begin < drawing->damage_end) { diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h index 75cde72b..1f528be7 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h @@ -98,6 +98,7 @@ int after_data_request(void *hook_data, void *call_data); gint update_time_window_hook(void *hook_data, void *call_data); gint update_current_time_hook(void *hook_data, void *call_data); +gint traceset_notify(void *hook_data, void *call_data); gint redraw_notify(void *hook_data, void *call_data); gint continue_notify(void *hook_data, void *call_data); -- 2.34.1