[xiph-commits] r12259 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Dec 29 11:21:29 PST 2006


Author: xiphmont
Date: 2006-12-29 11:21:27 -0800 (Fri, 29 Dec 2006)
New Revision: 12259

Modified:
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel.c
Log:
Fix several update races that caused cosmetic errors 



Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2006-12-29 05:35:12 UTC (rev 12258)
+++ trunk/sushivision/panel-1d.c	2006-12-29 19:21:27 UTC (rev 12259)
@@ -50,6 +50,16 @@
 
 static void update_context_menus(sushiv_panel_t *p);
 
+static int ilog10(int x){
+  int count=0;
+  if(x<0)x=-x;
+  while(x){
+    count++;
+    x/=10;
+  }
+  return count;
+}
+
 // called internally, assumes we hold lock
 // redraws the data, does not compute the data
 static void _sushiv_panel1d_remap(sushiv_panel_t *p){
@@ -130,35 +140,6 @@
   }
 }
 
-void _sushiv_panel1d_map_redraw(sushiv_panel_t *p){
-  Plot *plot = PLOT(p->private->graph);
-
-  gdk_threads_enter (); // misuse me as a global mutex
-  
-  _sushiv_panel1d_remap(p);
-  if(plot)
-    plot_expose_request(plot);
- 
-  gdk_threads_leave (); // misuse me as a global mutex
-}
-
-void _sushiv_panel1d_legend_redraw(sushiv_panel_t *p){
-  Plot *plot = PLOT(p->private->graph);
-
-  if(plot)
-    plot_draw_scales(plot);
-}
-
-static int ilog10(int x){
-  int count=0;
-  if(x<0)x=-x;
-  while(x){
-    count++;
-    x/=10;
-  }
-  return count;
-}
-
 static void update_legend(sushiv_panel_t *p){  
   sushiv_panel1d_t *p1 = p->subtype->p1;
   Plot *plot = PLOT(p->private->graph);
@@ -212,32 +193,54 @@
     {
       double val = (p1->flip?plot->sely:plot->selx);
       int bin = scalespace_pixel(&p1->vs, val);
+      u_int32_t color = mapping_calc(p1->mappings+i,0,0);
+	  
+      for(i=0;i<p->objectives;i++){
 
-      if(bin>=0 && bin<p1->data_size){
+	snprintf(buffer,320,"%s",
+		 p->objective_list[i].o->name);
 	
-	for(i=0;i<p->objectives;i++){
+	if(bin>=0 && bin<p1->data_size){
+	  
 	  float val = p1->data_vec[i][bin];
-	  u_int32_t color = mapping_calc(p1->mappings+i,0,0);
-
+	  
 	  if(!isnan(val)){
 	    snprintf(buffer,320,"%s = %f",
 		     p->objective_list[i].o->name,
 		     val);
-	  }else{
-	    snprintf(buffer,320,"%s",
-		     p->objective_list[i].o->name);
 	  }
-	  plot_legend_add_with_color(plot,buffer,color);
 	}
+	
+	plot_legend_add_with_color(plot,buffer,color);
+
       }
     }
     gdk_threads_leave ();
-    
-    _sushiv_panel_dirty_legend(p);
-    
   }
 }
 
+void _sushiv_panel1d_map_redraw(sushiv_panel_t *p){
+  Plot *plot = PLOT(p->private->graph);
+
+  gdk_threads_enter (); // misuse me as a global mutex
+  
+  _sushiv_panel1d_remap(p);
+  if(plot)
+    plot_expose_request(plot);
+ 
+  gdk_threads_leave (); // misuse me as a global mutex
+}
+
+void _sushiv_panel1d_legend_redraw(sushiv_panel_t *p){
+  Plot *plot = PLOT(p->private->graph);
+
+  gdk_threads_enter (); // misuse me as a global mutex
+  update_legend(p);
+  if(plot)
+    plot_draw_scales(plot);
+  gdk_threads_leave (); // misuse me as a global mutex
+}
+
 static void mapchange_callback_1d(GtkWidget *w,gpointer in){
   sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
   sushiv_panel_t *p = optr->p;
@@ -252,8 +255,8 @@
   solid_set_func(&p1->mappings[onum],
 		 gtk_combo_box_get_active(GTK_COMBO_BOX(w)));
 
-  update_legend(p);
   _sushiv_panel_dirty_map(p);
+  _sushiv_panel_dirty_legend(p);
   _sushiv_panel_undo_resume(p);
 }
 
@@ -269,7 +272,6 @@
   // update colormap
   p1->linetype[onum]=gtk_combo_box_get_active(GTK_COMBO_BOX(w));
 
-  //update_legend(p);
   _sushiv_panel_dirty_map(p);
   _sushiv_panel_undo_resume(p);
 }
@@ -535,7 +537,7 @@
 	d->val = scalespace_value(&plot->x,plot_get_crosshair_xpixel(plot));
     }
   }
-  update_legend(p);
+  _sushiv_panel_dirty_legend(p);
 }
 
 void _sushiv_panel1d_update_linked_crosshairs(sushiv_panel_t *p){
@@ -741,20 +743,12 @@
   sy = p1->y;
   sv = p1->vs;
   
-  if(p1->last_line==2){
+  if(p1->last_line){
     gdk_threads_leave ();
     return 0;
   }
 
   plot = PLOT(p->private->graph);
-
-  if(p1->last_line){
-    p1->last_line++;
-    gdk_threads_leave ();
-    plot_expose_request(plot);
-    update_legend(p); 
-    return 0;
-  }
   
   serialno = p1->serialno;
   d = p->dimensions;
@@ -805,7 +799,11 @@
     
     /* compute */
     compute_1d(p, serialno, x_d, x_min, x_max, dw, dim_vals);
-    _sushiv_panel1d_map_redraw(p);
+    gdk_threads_enter ();
+    _sushiv_panel_dirty_map(p);
+    _sushiv_panel_dirty_legend(p);
+    gdk_threads_leave ();
+
   }else
     gdk_threads_leave ();
 

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-12-29 05:35:12 UTC (rev 12258)
+++ trunk/sushivision/panel-2d.c	2006-12-29 19:21:27 UTC (rev 12259)
@@ -806,20 +806,13 @@
   sx = p2->x;
   sy = p2->y;
 
-  if(p2->last_line>h){
+  if(p2->last_line>=h){
     gdk_threads_leave ();
     return 0;
   }
 
   plot = PLOT(p->private->graph);
 
-  if(p2->last_line==h){
-    p2->last_line++;
-    gdk_threads_leave ();
-    update_legend(p); 
-    return 0;
-  }
-  
   serialno = p2->serialno;
   invh = 1./h;
   d = p->dimensions;
@@ -906,6 +899,11 @@
       u_int32_t *line = plot_get_background_line(plot, y);
       memcpy(line,render,w*sizeof(*render));
       plot_expose_request_line(plot,y);
+
+      if(p2->last_line==h){
+	_sushiv_panel_dirty_map(p);
+	_sushiv_panel_dirty_legend(p);
+      }
     }else
       break;
   }

Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2006-12-29 05:35:12 UTC (rev 12258)
+++ trunk/sushivision/panel.c	2006-12-29 19:21:27 UTC (rev 12259)
@@ -85,41 +85,67 @@
    synchronous in the interests of responsiveness. */
 static gboolean _map_idle_work(gpointer ptr){
   sushiv_instance_t *s = (sushiv_instance_t *)ptr;
-  int i;
+  int i,flag=1;
   
-  for(i=0;i<s->panels;i++){
-    sushiv_panel_t *p = s->panel_list[i];
-    if(p->private->maps_dirty){
-      p->private->maps_dirty = 0;
-      p->private->map_redraw(p);
+  while(flag){
+    flag = 0;
+    
+    for(i=0;i<s->panels;i++){
+      sushiv_panel_t *p = s->panel_list[i];
+      gdk_threads_enter ();
+      if(p->private->maps_dirty){
+	p->private->maps_dirty = 0;
+	flag=1;
+	gdk_threads_leave ();
+      
+	p->private->map_redraw(p);
+
+      }else
+	gdk_threads_leave ();
     }
-  }  
+  }
+
   return FALSE;
 }
 
 static gboolean _legend_idle_work(gpointer ptr){
   sushiv_instance_t *s = (sushiv_instance_t *)ptr;
-  int i;
+  int i,flag=1;
   
-  for(i=0;i<s->panels;i++){
-    sushiv_panel_t *p = s->panel_list[i];
-    if(p->private->legend_dirty){
-      p->private->legend_dirty = 0;
-      p->private->legend_redraw(p);
+  while(flag){
+    flag = 0;
+
+    for(i=0;i<s->panels;i++){
+      sushiv_panel_t *p = s->panel_list[i];
+      gdk_threads_enter ();
+      if(p->private->legend_dirty){
+	p->private->legend_dirty = 0;
+	flag=1;
+	gdk_threads_leave ();
+      
+	p->private->legend_redraw(p);
+
+      }else
+	gdk_threads_leave ();
     }
   }
+
   return FALSE;
 }
 
 
 void _sushiv_panel_dirty_map(sushiv_panel_t *p){
+  gdk_threads_enter ();
   p->private->maps_dirty = 1;
   g_idle_add(_map_idle_work,p->sushi);
+  gdk_threads_leave ();
 }
 
 void _sushiv_panel_dirty_legend(sushiv_panel_t *p){
+  gdk_threads_enter ();
   p->private->legend_dirty = 1;
   g_idle_add(_legend_idle_work,p->sushi);
+  gdk_threads_leave ();
 }
 
 int _sushiv_new_panel(sushiv_instance_t *s,



More information about the commits mailing list