background computation for control flow viewer
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 16 Jul 2004 03:37:30 +0000 (03:37 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 16 Jul 2004 03:37:30 +0000 (03:37 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@625 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h

index 64254f24f87361324e941e5bfdfbf6f220328364..508eb23e865a8468fe0d4b0fea1440e3090c213a 100644 (file)
@@ -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);
index 375ed57007780e053deb0716bed976c93a1d69bb..091bcb8a62cf39afbb646803c7519b0303aee6f8 100644 (file)
@@ -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)
index 8ee55f18dfb1caa5e1301824da19ffd8afb0519d..a36fdf49944e7f7093b4242edec69877f9952ccb 100644 (file)
@@ -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,
index 75609d09544dd8599ed0701c8dbf2fb83d591ac4..5ac72454b9550fdae956fb0d8b2de897078d2274 100644 (file)
@@ -40,6 +40,7 @@
 #include <lttv/hook.h>
 #include <lttv/state.h>
 #include <lttvwindow/lttvwindow.h>
+#include <lttvwindow/lttvwindowtraces.h>
 
 
 #include "eventhooks.h"
 #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;i<num_traces;i++) {
+    trace = lttvwindowtraces_get_trace(i);
+
+    if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) {
+
+      if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
+                                          trace) == FALSE) {
+        /* We first remove requests that could have been done for the same
+         * information. Happens when two viewers ask for it before servicing
+         * starts.
+         */
+        lttvwindowtraces_background_request_remove(trace, "state");
+        lttvwindowtraces_background_request_queue(trace,
+                                                  "state");
+        lttvwindowtraces_background_notify_queue(control_flow_data,
+                                                 trace,
+                                                 ltt_time_infinite,
+                                                 NULL,
+                                                 background_ready_hook);
+      } else { /* in progress */
+      
+        lttvwindowtraces_background_notify_current(control_flow_data,
+                                                   trace,
+                                                   ltt_time_infinite,
+                                                   NULL,
+                                                   background_ready_hook);
+      
+      }
+    }
+  }
+
+  lttv_hooks_destroy(background_ready_hook);
+}
+
+
+
+
 /**
  * Event Viewer's constructor hook
  *
@@ -70,6 +144,10 @@ h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key)
   
   //g_debug("time width2 : %u",time_window->time_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(ns<os<ns+w)
       //if(ns<os && os<ns+w)
@@ -1310,7 +1396,8 @@ gint update_time_window_hook(void *hook_data, void *call_data)
             *os,
             width,
             &x);
-  
+        
+
         /* Copy old data to new location */
         gdk_draw_drawable (control_flow_data->drawing->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)
   {
index 75cde72b5fbd20c2bd2f90ca1beef07ff0a388c7..1f528be7ca13299265c7afe5514599edf2aabec5 100644 (file)
@@ -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);
 
This page took 0.035038 seconds and 4 git commands to generate.