Add config.h support : will fix the LARGEFILE problem
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / drawing.c
index 28934be2dc5f27b271f668e6d451bb903ed1b851..b4411bc422b1eb15bcfe14a5ef264bf3e01f3532 100644 (file)
  * MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
+#include <string.h>
+
+#include <ltt/trace.h>
 
 #include <lttv/lttv.h>
 #include <lttv/tracecontext.h>
 #include "drawing.h"
 #include "eventhooks.h"
 #include "cfv.h"
-#include "cfv-private.h"
 
 #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)
 
 //FIXME
 #define TRACE_NUMBER 0
+#define EXTRA_ALLOC 1024 // pixels
 
 
+#if 0 /* colors for two lines representation */
 GdkColor drawing_colors[NUM_COLORS] =
 { /* Pixel, R, G, B */
   { 0, 0, 0, 0 }, /* COL_BLACK */
@@ -54,6 +62,27 @@ GdkColor drawing_colors[NUM_COLORS] =
   { 0, 0xFFFF, 0xFFFF, 0xFFFF }  /* COL_MODE_UNKNOWN : white */
 
 };
+#endif //0
+
+
+GdkColor drawing_colors[NUM_COLORS] =
+{ /* Pixel, R, G, B */
+  { 0, 0, 0, 0 }, /* COL_BLACK */
+  { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_WHITE */
+  { 0, 0x0000, 0xFF00, 0x0000 }, /* COL_RUN_USER_MODE : green */
+  { 0, 0x0100, 0x9E00, 0xFFFF }, /* COL_RUN_SYSCALL : pale blue */
+  { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_RUN_TRAP : yellow */
+  { 0, 0xFFFF, 0x5E00, 0x0000 }, /* COL_RUN_IRQ : red */
+  { 0, 0x6600, 0x0000, 0x0000 }, /* COL_WAIT : dark red */
+  { 0, 0x7700, 0x7700, 0x0000 }, /* COL_WAIT_CPU : dark yellow */
+  { 0, 0x6400, 0x0000, 0x5D00 }, /* COL_ZOMBIE : dark purple */
+  { 0, 0x0700, 0x6400, 0x0000 }, /* COL_WAIT_FORK : dark green */
+  { 0, 0x8900, 0x0000, 0x8400 }, /* COL_EXIT : "less dark" magenta */
+  { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_MODE_UNKNOWN : white */
+  { 0, 0xFFFF, 0xFFFF, 0xFFFF }  /* COL_UNNAMED : white */
+
+};
+
 /*
 RUN+USER MODE green
 RUN+SYSCALL
@@ -86,7 +115,6 @@ motion_notify_ruler(GtkWidget *widget, GdkEventMotion *event, gpointer user_data
  * erase drawing already present (SAFETY).
  */
 void drawing_data_request(Drawing_t *drawing,
-      GdkPixmap **pixmap,
       gint x, gint y,
       gint width,
       gint height)
@@ -94,12 +122,6 @@ void drawing_data_request(Drawing_t *drawing,
   if(width < 0) return ;
   if(height < 0) return ;
 
-  if(drawing->gc == NULL) {
-    drawing->gc = gdk_gc_new(drawing->drawing_area->window);
-    gdk_gc_copy(drawing->gc, drawing->drawing_area->style->black_gc);
-  }
-
-
   Tab *tab = drawing->control_flow_data->tab;
   TimeWindow time_window =
               lttvwindow_get_time_window(tab);
@@ -109,29 +131,28 @@ void drawing_data_request(Drawing_t *drawing,
   //               G_OBJECT(drawing->drawing_area), "control_flow_data");
 
   LttTime start, time_end;
-  LttTime window_end = ltt_time_add(time_window.time_width,
-                                    time_window.start_time);
+  LttTime window_end = time_window.end_time;
 
-  g_debug("req : window start_time : %u, %u", time_window.start_time.tv_sec, 
+  g_debug("req : window start_time : %lu, %lu", time_window.start_time.tv_sec, 
                                        time_window.start_time.tv_nsec);
 
-  g_debug("req : window time width : %u, %u", time_window.time_width.tv_sec, 
+  g_debug("req : window time width : %lu, %lu", time_window.time_width.tv_sec, 
                                        time_window.time_width.tv_nsec);
   
-  g_debug("req : window_end : %u, %u", window_end.tv_sec, 
+  g_debug("req : window_end : %lu, %lu", window_end.tv_sec, 
                                        window_end.tv_nsec);
 
   g_debug("x is : %i, x+width is : %i", x, x+width);
 
   convert_pixels_to_time(drawing->width, x,
-        time_window.start_time,
-        window_end,
+        time_window,
         &start);
 
   convert_pixels_to_time(drawing->width, x+width,
-        time_window.start_time,
-        window_end,
+        time_window,
         &time_end);
+  time_end = ltt_time_add(time_end, ltt_time_one); // because main window
+                                                   // doesn't deliver end time.
 
   lttvwindow_events_request_remove_all(tab,
                                        control_flow_data);
@@ -152,13 +173,10 @@ void drawing_data_request(Drawing_t *drawing,
 
     LttvTraceHook hook;
 
-    LttvAttributeValue val;
-
     nb_trace = lttv_traceset_number(traceset);
     // FIXME : eventually request for more traces
     // for(i = 0 ; i < nb_trace ; i++) {
-    g_assert(TRACE_NUMBER < nb_trace);
-    i = TRACE_NUMBER;
+    for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++)
     {
       EventsRequest *events_request = g_new(EventsRequest, 1);
       // Create the hooks
@@ -196,7 +214,7 @@ void drawing_data_request(Drawing_t *drawing,
          associated by id hooks. */
 
       hooks = g_array_new(FALSE, FALSE, sizeof(LttvTraceHook));
-      g_array_set_size(hooks, 16);
+      g_array_set_size(hooks, 10);
 
       /* before hooks */
       
@@ -236,31 +254,38 @@ void drawing_data_request(Drawing_t *drawing,
 
       /* after hooks */
       
+#if 0
+      /**** DESACTIVATED ****/
       lttv_trace_find_hook(ts->parent.t, "core","syscall_entry","syscall_id", 
     NULL, NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 8));
-
+      /**** DESACTIVATED ****/
       lttv_trace_find_hook(ts->parent.t, "core", "syscall_exit", NULL, NULL, 
           NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 9));
 
+      /**** DESACTIVATED ****/
       lttv_trace_find_hook(ts->parent.t, "core", "trap_entry", "trap_id",
     NULL, NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 10));
 
+      /**** DESACTIVATED ****/
       lttv_trace_find_hook(ts->parent.t, "core", "trap_exit", NULL, NULL, NULL, 
           after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 11));
 
+      /**** DESACTIVATED ****/
       lttv_trace_find_hook(ts->parent.t, "core", "irq_entry", "irq_id", NULL, 
           NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 12));
 
+      /**** DESACTIVATED ****/
       lttv_trace_find_hook(ts->parent.t, "core", "irq_exit", NULL, NULL, NULL, 
           after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 13));
+#endif //0
 
       lttv_trace_find_hook(ts->parent.t, "core", "schedchange", "in", "out", 
         "out_state", after_schedchange_hook, 
-        &g_array_index(hooks, LttvTraceHook, 14));
+        &g_array_index(hooks, LttvTraceHook, 8));
 
       lttv_trace_find_hook(ts->parent.t, "core", "process", "event_sub_id", 
           "event_data1", "event_data2", after_process_hook,
-          &g_array_index(hooks, LttvTraceHook, 15));
+          &g_array_index(hooks, LttvTraceHook, 9));
 
 #if 0
       lttv_trace_find_hook(ts->parent.t, "core", "process_fork", "child_pid", 
@@ -274,7 +299,7 @@ void drawing_data_request(Drawing_t *drawing,
       
       /* Add these hooks to each event_by_id hooks list */
       /* add before */
-      for(k = 0 ; k < hooks->len/2 ; k++) {
+      for(k = 0 ; k < 8 ; k++) {
         hook = g_array_index(hooks, LttvTraceHook, k);
         lttv_hooks_add(lttv_hooks_by_id_find(event_by_id, 
                         hook.id), hook.h,
@@ -283,7 +308,7 @@ void drawing_data_request(Drawing_t *drawing,
       }
 
       /* add after */
-      for(k = hooks->len/2 ; k < hooks->len ; k++) {
+      for(k = 8 ; k < 10 ; k++) {
         hook = g_array_index(hooks, LttvTraceHook, k);
         lttv_hooks_add(lttv_hooks_by_id_find(event_by_id, 
                        hook.id), hook.h,
@@ -315,10 +340,10 @@ void drawing_data_request(Drawing_t *drawing,
       events_request->before_request = before_request_hook;
       events_request->after_request = after_request_hook;
 
-      g_debug("req : start : %u, %u", start.tv_sec, 
+      g_debug("req : start : %lu, %lu", start.tv_sec, 
                                           start.tv_nsec);
 
-      g_debug("req : end : %u, %u", time_end.tv_sec, 
+      g_debug("req : end : %lu, %lu", time_end.tv_sec, 
                                          time_end.tv_nsec);
 
       lttvwindow_events_request(tab, events_request);
@@ -364,8 +389,15 @@ static void set_last_start(gpointer key, gpointer value, gpointer user_data)
   guint x = (guint)user_data;
 
   hashed_process_data->x.over = x;
+  hashed_process_data->x.over_used = FALSE;
+  hashed_process_data->x.over_marked = FALSE;
   hashed_process_data->x.middle = x;
+  hashed_process_data->x.middle_used = FALSE;
+  hashed_process_data->x.middle_marked = FALSE;
   hashed_process_data->x.under = x;
+  hashed_process_data->x.under_used = FALSE;
+  hashed_process_data->x.under_marked = FALSE;
+  hashed_process_data->next_good_time = ltt_time_zero;
 
   return;
 }
@@ -377,22 +409,21 @@ void drawing_data_request_begin(EventsRequest *events_request, LttvTracesetState
   LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
   TimeWindow time_window = 
     lttvwindow_get_time_window(cfd->tab);
-  LttTime end_time = ltt_time_add(time_window.start_time,
-                                    time_window.time_width);
+
   guint width = cfd->drawing->width;
   guint x=0;
 
   cfd->drawing->last_start = events_request->start_time;
 
   convert_time_to_pixels(
-          time_window.start_time,
-          end_time,
+          time_window,
           events_request->start_time,
           width,
           &x);
 
   g_hash_table_foreach(cfd->process_list->process_hash, set_last_start,
                             (gpointer)x);
+
 }
 
 void drawing_chunk_begin(EventsRequest *events_request, LttvTracesetState *tss)
@@ -400,8 +431,13 @@ void drawing_chunk_begin(EventsRequest *events_request, LttvTracesetState *tss)
   g_debug("Begin of chunk");
   ControlFlowData *cfd = events_request->viewer_data;
   LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
-  LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
+  //LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
+  guint num_cpu = 
+    ltt_trace_per_cpu_tracefile_number(tss->parent.traces[TRACE_NUMBER]->t);
 
+  cfd->process_list->current_hash_data = g_new(HashedProcessData*,num_cpu);
+  memset(cfd->process_list->current_hash_data, 0,
+         sizeof(HashedProcessData*)*num_cpu);
   //cfd->drawing->last_start = LTT_TIME_MIN(current_time,
   //                                        events_request->end_time);
 }
@@ -414,7 +450,7 @@ void drawing_request_expose(EventsRequest *events_request,
   gint x, x_end, width;
 
   ControlFlowData *cfd = events_request->viewer_data;
-  LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
+  LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
   Drawing_t *drawing = cfd->drawing;
   
   TimeWindow time_window = 
@@ -422,42 +458,21 @@ void drawing_request_expose(EventsRequest *events_request,
 
   g_debug("request expose");
   
-  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,
-        cfd->drawing->last_start,
-        drawing->width,
-        &x);
-
-#endif //0
   convert_time_to_pixels(
-        time_window.start_time,
-        window_end,
+        time_window,
         end_time,
         drawing->width,
         &x_end);
   x = drawing->damage_begin;
- // x_end = drawing->damage_end;
+
   width = x_end - x;
 
   drawing->damage_begin = x+width;
-  //drawing->damage_end = drawing->width;
-
-  /* ask for the buffer to be redrawn */
-
-  //gtk_widget_queue_draw_area ( drawing->drawing_area,
-  //                             0, 0,
-  //                             drawing->width, drawing->height);
 
-  /* FIXME
-   * will need more precise pixel_to_time and time_to_pixel conversion
-   * functions to redraw only the needed area. */
+  // FIXME ?
   gtk_widget_queue_draw_area ( drawing->drawing_area,
                                x, 0,
-                               width, drawing->height);
+                               width, drawing->drawing_area->allocation.height);
  
 }
 
@@ -498,28 +513,34 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
     g_debug("New alloc draw size : %i by %i",widget->allocation.width,
                                     widget->allocation.height);
   
-    
-    if (drawing->pixmap)
-      gdk_pixmap_unref(drawing->pixmap);
-  
     drawing->width = widget->allocation.width;
+    
+    if(drawing->alloc_width < widget->allocation.width) {
+      //if(drawing->pixmap)
+      //  gdk_pixmap_unref(drawing->pixmap);
+
+      //drawing->pixmap = gdk_pixmap_new(widget->window,
+      //                                 drawing->width + SAFETY + EXTRA_ALLOC,
+      //                                 drawing->height + EXTRA_ALLOC,
+      //                                 -1);
+      drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
+      drawing->alloc_height = drawing->height + EXTRA_ALLOC;
+      update_pixmap_size(drawing->control_flow_data->process_list,
+                         drawing->alloc_width);
+    }
     //drawing->height = widget->allocation.height;
 
-    drawing->pixmap = gdk_pixmap_new(widget->window,
-                                     drawing->width + SAFETY,
-                                     drawing->height,
-                                     -1);
     //ProcessList_get_height
     // (GuiControlFlow_get_process_list(drawing->control_flow_data)),
     
 
     // Clear the image
-    gdk_draw_rectangle (drawing->pixmap,
-          widget->style->black_gc,
-          TRUE,
-          0, 0,
-          drawing->width+SAFETY,
-          drawing->height);
+    //gdk_draw_rectangle (drawing->pixmap,
+    //      widget->style->black_gc,
+    //      TRUE,
+    //      0, 0,
+    //      drawing->width+SAFETY,
+    //      drawing->height);
 
     //g_info("init data request");
 
@@ -538,10 +559,20 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
     drawing->damage_begin = 0;
     drawing->damage_end = widget->allocation.width;
 
-    if(drawing->damage_begin < drawing->damage_end)
+    if((widget->allocation.width != 1 &&
+        widget->allocation.height != 1)
+        && drawing->damage_begin < drawing->damage_end)
     {
+
+      rectangle_pixmap (drawing->control_flow_data->process_list,
+        drawing->drawing_area->style->black_gc,
+        TRUE,
+        0, 0,
+        drawing->alloc_width, // do not overlap
+        -1);
+
+
       drawing_data_request(drawing,
-                           &drawing->pixmap,
                            drawing->damage_begin,
                            0,
                            drawing->damage_end - drawing->damage_begin,
@@ -562,6 +593,10 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
       (ControlFlowData*)g_object_get_data(
                 G_OBJECT(widget),
                 "control_flow_data");
+  if(unlikely(drawing->gc == NULL)) {
+    drawing->gc = gdk_gc_new(drawing->drawing_area->window);
+    gdk_gc_copy(drawing->gc, drawing->drawing_area->style->black_gc);
+  }
 
   TimeWindow time_window = 
       lttvwindow_get_time_window(control_flow_data->tab);
@@ -570,26 +605,41 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 
   guint cursor_x=0;
 
-  LttTime window_end = ltt_time_add(time_window.time_width,
-                                    time_window.start_time);
-
+  LttTime window_end = time_window.end_time;
 
   /* update the screen from the pixmap buffer */
+#if 0
   gdk_draw_pixmap(widget->window,
       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
       drawing->pixmap,
       event->area.x, event->area.y,
       event->area.x, event->area.y,
       event->area.width, event->area.height);
-
+#endif //0
+  drawing->height = processlist_get_height(control_flow_data->process_list);
+  copy_pixmap_to_screen(control_flow_data->process_list,
+                        widget->window,
+                        widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+                        event->area.x, event->area.y,
+                        event->area.width, event->area.height);
+                        
   
+  /* Erase the dotted lines left.. */
+  if(widget->allocation.height > drawing->height)
+  {
+    gdk_draw_rectangle (widget->window,
+      drawing->drawing_area->style->black_gc,
+      TRUE,
+      event->area.x, drawing->height,
+      event->area.width,  // do not overlap
+      widget->allocation.height - drawing->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,
+          time_window,
           current_time,
           drawing->width,
           &cursor_x);
@@ -611,11 +661,11 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
                         dash_list,
                         2);
     }
-
-    drawing_draw_line(NULL, widget->window,
+    gint height_tot = MAX(widget->allocation.height, drawing->height);
+    gdk_draw_line(widget->window,
+                  drawing->dotted_gc,
                   cursor_x, 0,
-                  cursor_x, drawing->height,
-                  drawing->dotted_gc);
+                  cursor_x, height_tot);
   }
   return FALSE;
 }
@@ -670,16 +720,11 @@ button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data
   {
     LttTime time;
 
-    LttTime window_end = ltt_time_add(time_window.time_width,
-                                      time_window.start_time);
-
-
     /* left mouse button click */
     g_debug("x click is : %f", event->x);
 
     convert_pixels_to_time(drawing->width, (guint)event->x,
-        time_window.start_time,
-        window_end,
+        time_window,
         &time);
 
     lttvwindow_report_current_time(control_flow_data->tab, time);
@@ -767,6 +812,8 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   drawing->height = 1;
   drawing->width = 1;
   drawing->depth = 0;
+  drawing->alloc_height = 1;
+  drawing->alloc_width = 1;
   
   drawing->damage_begin = 0;
   drawing->damage_end = 0;
@@ -801,7 +848,7 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   //    drawing->height,
   //    drawing->depth);
   
-  drawing->pixmap = NULL;
+  //drawing->pixmap = NULL;
 
 //  drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
 //        drawing->drawing_area->allocation.width,
@@ -860,10 +907,9 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
 
   /* Allocate the colors */
   GdkColormap* colormap = gdk_colormap_get_system();
-
+  gboolean success[NUM_COLORS];
   gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE,
-                            TRUE, NULL);
-  
+                            TRUE, success);
   
   return drawing;
 }
@@ -885,7 +931,7 @@ void drawing_destroy(Drawing_t *drawing)
     gdk_gc_unref(drawing->gc);
   
   g_free(drawing->pango_layout);
-  if(!drawing->dotted_gc) gdk_gc_unref(drawing->dotted_gc);
+  if(drawing->dotted_gc != NULL) gdk_gc_unref(drawing->dotted_gc);
   g_free(drawing);
   g_info("drawing_destroy end");
 }
@@ -900,53 +946,6 @@ GtkWidget *drawing_get_widget(Drawing_t *drawing)
   return drawing->vbox;
 }
 
-/* convert_pixels_to_time
- *
- * Convert from window pixel and time interval to an absolute time.
- */
-__inline void convert_pixels_to_time(
-    gint width,
-    guint x,
-    LttTime window_time_begin,
-    LttTime window_time_end,
-    LttTime *time)
-{
-  LttTime window_time_interval;
-  guint64 time_ll;
-  
-  window_time_interval = ltt_time_sub(window_time_end, 
-            window_time_begin);
-  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);
-}
-
-
-__inline void convert_time_to_pixels(
-    LttTime window_time_begin,
-    LttTime window_time_end,
-    LttTime time,
-    int width,
-    guint *x)
-{
-  LttTime window_time_interval;
-  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);
-  
-  time_ll = ltt_time_to_uint64(time);
-  interval_ll = ltt_time_to_uint64(window_time_interval);
-
-  *x = (guint)(time_ll * width / interval_ll);
-  
-}
-
 void drawing_draw_line( Drawing_t *drawing,
       GdkPixmap *pixmap,
       guint x1, guint y1,
@@ -960,28 +959,37 @@ void drawing_draw_line( Drawing_t *drawing,
 
 void drawing_clear(Drawing_t *drawing)
 { 
-  if (drawing->pixmap)
-    gdk_pixmap_unref(drawing->pixmap);
+  //if (drawing->pixmap)
+  //  gdk_pixmap_unref(drawing->pixmap);
+  ControlFlowData *cfd = drawing->control_flow_data;
 
-  drawing->height = 1;
+  
+  rectangle_pixmap(cfd->process_list,
+      drawing->drawing_area->style->black_gc,
+      TRUE,
+      0, 0,
+      drawing->alloc_width,  // do not overlap
+      -1);
+  
+  //drawing->height = 1;
   /* Allocate a new pixmap with new height */
-  drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
-                                   drawing->width + SAFETY,
-                                   drawing->height,
-                                     -1);
-
-  gtk_widget_set_size_request(drawing->drawing_area,
-                             -1,
-                             drawing->height);
-  gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
+  //drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
+  //                                 drawing->width + SAFETY + EXTRA_ALLOC,
+  //                                 drawing->height + EXTRA_ALLOC,
+  //                                   -1);
+  //drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
+  //drawing->alloc_height = drawing->height + EXTRA_ALLOC;
+
+  //gtk_widget_set_size_request(drawing->drawing_area,
+  //                           -1,
+  //                           drawing->height);
+  //gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
   
   /* ask for the buffer to be redrawn */
-  gtk_widget_queue_draw_area ( drawing->drawing_area,
-                               0, 0,
-                               drawing->width, drawing->height);
+  gtk_widget_queue_draw ( drawing->drawing_area);
 }
 
-
+#if 0
 /* Insert a square corresponding to a new process in the list */
 /* Applies to whole drawing->width */
 void drawing_insert_square(Drawing_t *drawing,
@@ -989,36 +997,47 @@ void drawing_insert_square(Drawing_t *drawing,
         guint height)
 {
   //GdkRectangle update_rect;
+  gboolean reallocate = FALSE;
+  GdkPixmap *new_pixmap;
 
   /* Allocate a new pixmap with new height */
-  GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
-        drawing->width + SAFETY,
-        drawing->height + height,
-        -1);
-  
-  /* Copy the high region */
-  gdk_draw_drawable (pixmap,
-    drawing->drawing_area->style->black_gc,
-    drawing->pixmap,
-    0, 0,
-    0, 0,
-    drawing->width + SAFETY, y);
+  if(drawing->alloc_height < drawing->height + height) {
 
+    new_pixmap = gdk_pixmap_new(drawing->drawing_area->window,
+                                     drawing->width + SAFETY + EXTRA_ALLOC,
+                                     drawing->height + height + EXTRA_ALLOC,
+                                     -1);
+    drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
+    drawing->alloc_height = drawing->height + height + EXTRA_ALLOC;
+    reallocate = TRUE;
 
+    /* Copy the high region */
+    gdk_draw_pixmap (new_pixmap,
+      drawing->drawing_area->style->black_gc,
+      drawing->pixmap,
+      0, 0,
+      0, 0,
+      drawing->width + SAFETY, y);
 
+  } else {
+    new_pixmap = drawing->pixmap;
+  }
 
+  //GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
+  //      drawing->width + SAFETY,
+  //      drawing->height + height,
+  //      -1);
+  
   /* add an empty square */
-  gdk_draw_rectangle (pixmap,
+  gdk_draw_rectangle (new_pixmap,
     drawing->drawing_area->style->black_gc,
     TRUE,
     0, y,
     drawing->width + SAFETY,  // do not overlap
     height);
 
-
-
   /* copy the bottom of the region */
-  gdk_draw_drawable (pixmap,
+  gdk_draw_pixmap (new_pixmap,
     drawing->drawing_area->style->black_gc,
     drawing->pixmap,
     0, y,
@@ -1026,12 +1045,12 @@ void drawing_insert_square(Drawing_t *drawing,
     drawing->width+SAFETY, drawing->height - y);
 
 
-  if (drawing->pixmap)
+  if(reallocate && likely(drawing->pixmap)) {
     gdk_pixmap_unref(drawing->pixmap);
-
-  drawing->pixmap = pixmap;
+    drawing->pixmap = new_pixmap;
+  }
   
-  if(drawing->height==1) drawing->height = height;
+  if(unlikely(drawing->height==1)) drawing->height = height;
   else drawing->height += height;
   
   gtk_widget_set_size_request(drawing->drawing_area,
@@ -1053,23 +1072,26 @@ void drawing_remove_square(Drawing_t *drawing,
 {
   GdkPixmap *pixmap;
 
-  if(drawing->height == height) {
-    pixmap = gdk_pixmap_new(
-        drawing->drawing_area->window,
-        drawing->width + SAFETY,
-        1,
-        -1);
+  if(unlikely((guint)drawing->height == height)) {
+    //pixmap = gdk_pixmap_new(
+    //    drawing->drawing_area->window,
+    //    drawing->width + SAFETY,
+    //    1,
+    //    -1);
+    pixmap = drawing->pixmap;
     drawing->height=1;
   } else {
     /* Allocate a new pixmap with new height */
-     pixmap = gdk_pixmap_new(
-        drawing->drawing_area->window,
-        drawing->width + SAFETY,
-        drawing->height - height,
-        -1);
+     //pixmap = gdk_pixmap_new(
+     //   drawing->drawing_area->window,
+     //   drawing->width + SAFETY,
+     //   drawing->height - height,
+     //   -1);
+     /* Keep the same preallocated pixmap */
+    pixmap = drawing->pixmap;
    
     /* Copy the high region */
-    gdk_draw_drawable (pixmap,
+    gdk_draw_pixmap (pixmap,
       drawing->drawing_area->style->black_gc,
       drawing->pixmap,
       0, 0,
@@ -1077,7 +1099,7 @@ void drawing_remove_square(Drawing_t *drawing,
       drawing->width + SAFETY, y);
 
     /* Copy up the bottom of the region */
-    gdk_draw_drawable (pixmap,
+    gdk_draw_pixmap (pixmap,
       drawing->drawing_area->style->black_gc,
       drawing->pixmap,
       0, y + height,
@@ -1087,10 +1109,10 @@ void drawing_remove_square(Drawing_t *drawing,
     drawing->height-=height;
   }
 
-  if (drawing->pixmap)
-    gdk_pixmap_unref(drawing->pixmap);
+  //if(likely(drawing->pixmap))
+  //  gdk_pixmap_unref(drawing->pixmap);
 
-  drawing->pixmap = pixmap;
+  //drawing->pixmap = pixmap;
   
   gtk_widget_set_size_request(drawing->drawing_area,
                              -1,
@@ -1101,6 +1123,7 @@ void drawing_remove_square(Drawing_t *drawing,
                                0, y,
                                drawing->width, MAX(drawing->height-y, 1));
 }
+#endif //0
 
 void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window)
 {
@@ -1124,23 +1147,21 @@ void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window)
 static gboolean
 expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 {
+  /* ruler desactivated */
+  return 0;
   Drawing_t *drawing = (Drawing_t*)user_data;
   TimeWindow time_window = lttvwindow_get_time_window(drawing->control_flow_data->tab);
   gchar text[255];
   
   PangoContext *context;
   PangoLayout *layout;
-  PangoAttribute *attribute;
   PangoFontDescription *FontDesc;
-  gint Font_Size;
   PangoRectangle ink_rect;
-  guint global_width=0;
+  gint global_width=0;
   GdkColor foreground = { 0, 0, 0, 0 };
   GdkColor background = { 0, 0xffff, 0xffff, 0xffff };
 
-  LttTime window_end = 
-    ltt_time_add(time_window.time_width,
-                 time_window.start_time);
+  LttTime window_end = time_window.end_time;
   LttTime half_width =
     ltt_time_div(time_window.time_width,2.0);
   LttTime window_middle =
This page took 0.033859 seconds and 4 git commands to generate.