accelerate double useage for time
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / drawing.c
index b71dafacfab65307aaf54ff45d2798ebd7a1a70a..aaf8b03005d0b47d0ac6600a745db1ef50f717c9 100644 (file)
@@ -115,12 +115,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);
@@ -588,6 +582,10 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
       (ControlFlowData*)g_object_get_data(
                 G_OBJECT(widget),
                 "control_flow_data");
+  if(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);
@@ -937,13 +935,13 @@ __inline void convert_pixels_to_time(
     LttTime *time)
 {
   LttTime window_time_interval;
-  guint64 time_ll;
+  double time_d;
   
   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_d = ltt_time_to_double(window_time_interval);
+  time_d = time_d / (double)width * (double)x;
+  *time = ltt_time_from_double(time_d);
   *time = ltt_time_add(window_time_begin, *time);
 }
 
@@ -956,23 +954,23 @@ __inline void convert_time_to_pixels(
     guint *x)
 {
   LttTime window_time_interval;
-  guint64 time_ll, interval_ll;
-  
+  double time_d, interval_d;
+#ifdef EXTRA_CHECK 
   g_assert(ltt_time_compare(window_time_begin, time) <= 0 &&
            ltt_time_compare(window_time_end, time) >= 0);
-  
+#endif //EXTRA_CHECK
   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);
+  time_d = ltt_time_to_double(time);
+  interval_d = ltt_time_to_double(window_time_interval);
   
-  if(interval_ll == 0) {
-    g_assert(time_ll == 0);
+  if(interval_d == 0.0) {
+    g_assert(time_d == 0.0);
     *x = 0;
   } else {
-    *x = (guint)(time_ll * width / interval_ll);
+    *x = (guint)(time_d / interval_d * (double)width);
   }
   
 }
This page took 0.023488 seconds and 4 git commands to generate.