[xiph-commits] r14040 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Oct 24 03:57:28 PDT 2007


Author: xiphmont
Date: 2007-10-24 03:57:28 -0700 (Wed, 24 Oct 2007)
New Revision: 14040

Modified:
   trunk/sushivision/panel.c
   trunk/sushivision/plane-2d.c
   trunk/sushivision/plane-bg.c
   trunk/sushivision/plane.h
Log:
Work in progress, moving to another machine


Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2007-10-23 22:25:31 UTC (rev 14039)
+++ trunk/sushivision/panel.c	2007-10-24 10:57:28 UTC (rev 14040)
@@ -245,7 +245,8 @@
     // wait till all these ops are done
     p->expose = 0;
     bg_expose(p);
-    return done_working(p);
+    // bg_expose does not reclaim loks before exit
+    return STATUS_WORKING;
   }    
 
   // data resize

Modified: trunk/sushivision/plane-2d.c
===================================================================
--- trunk/sushivision/plane-2d.c	2007-10-23 22:25:31 UTC (rev 14039)
+++ trunk/sushivision/plane-2d.c	2007-10-24 10:57:28 UTC (rev 14040)
@@ -1174,6 +1174,21 @@
   }
 }
 
+GtkWidget *_sv_plane_2d_label_widget(sv_plane2d_t *pl){
+  GtkWidget *label = gtk_label_new(o->name);
+  gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
+  return label;
+}
+
+
+GtkWidget *_sv_plane_2d_obj_widget(sv_plane2d_t *pl){
+  GtkWidget *table = gtk_table_new
+
+
+}
+
+
+
 sv_plane_t *sv_plane_2d_new(){
   sv_plane_2d_t *ret = calloc(1,sizeof(*ret));
   ret->recompute_setup = recompute_setup;
@@ -1183,62 +1198,20 @@
   ret->data_work = data_work;
   ret->plane_remap = plane_remap;
   ret->plane_free = plane_free;
-  return (sv_plane_t *)ret;
-}
 
+  ret->plane_label = _sv_plane_2d_label_widget;
+  ret->plane_obj = _sv_plane_2d_obj_widget;
 
-// subtype entry point for legend redraws; lock held
-static int _sv_panel2d_legend_redraw(sv_panel_t *p){
-  _sv_plot_t *plot = PLOT(p->private->graph);
-
-  if(p->private->legend_progress_count)return 0;
-  p->private->legend_progress_count++;
-  _sv_panel2d_update_legend(p);
-  _sv_panel_clean_legend(p);
-
-  gdk_unlock();
-  _sv_plot_draw_scales(plot);
-  gdk_lock();
-
-  _sv_plot_expose_request(plot);
-  return 1;
+  return (sv_plane_t *)ret;
 }
 
+
 static void _sv_panel2d_realize(sv_panel_t *p){
   _sv_panel2d_t *p2 = p->subtype->p2;
   int i;
 
-  _sv_undo_suspend();
 
-  p->private->toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  g_signal_connect_swapped (G_OBJECT (p->private->toplevel), "delete-event",
-			    G_CALLBACK (_sv_clean_exit), (void *)SIGINT);
- 
-  // add border to sides with hbox/padding
-  GtkWidget *borderbox =  gtk_hbox_new(0,0);
-  gtk_container_add (GTK_CONTAINER (p->private->toplevel), borderbox);
 
-  // main layout vbox
-  p->private->topbox = gtk_vbox_new(0,0);
-  gtk_box_pack_start(GTK_BOX(borderbox), p->private->topbox, 1,1,4);
-  gtk_container_set_border_width (GTK_CONTAINER (p->private->toplevel), 1);
-
-  /* spinner, top bar */
-  {
-    GtkWidget *hbox = gtk_hbox_new(0,0);
-    gtk_box_pack_start(GTK_BOX(p->private->topbox), hbox, 0,0,0);
-    gtk_box_pack_end(GTK_BOX(hbox),GTK_WIDGET(p->private->spinner),0,0,0);
-  }
-
-  /* plotbox, graph */
-  {
-    p->private->graph = GTK_WIDGET(_sv_plot_new(_sv_panel2d_recompute_callback,p,
-						(void *)(void *)_sv_panel2d_crosshairs_callback,p,
-						_sv_panel2d_box_callback,p,0)); 
-    p->private->plotbox = p->private->graph;
-    gtk_box_pack_start(GTK_BOX(p->private->topbox), p->private->plotbox, 1,1,2);
-  }
-
   /* obj box */
   {
     p2->obj_table = gtk_table_new(p->objectives, 5, 0);
@@ -1256,8 +1229,7 @@
       int hi = o->scale->val_list[o->scale->vals-1];
       
       /* label */
-      GtkWidget *label = gtk_label_new(o->name);
-      gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
+
       gtk_table_attach(GTK_TABLE(p2->obj_table),label,0,1,i,i+1,
 		       GTK_FILL,0,8,0);
       

Modified: trunk/sushivision/plane-bg.c
===================================================================
--- trunk/sushivision/plane-bg.c	2007-10-23 22:25:31 UTC (rev 14039)
+++ trunk/sushivision/plane-bg.c	2007-10-24 10:57:28 UTC (rev 14040)
@@ -33,10 +33,9 @@
 #include "internal.h"
 
 // the background 'plane' is handled a little differently from the
-// other planes, as alot of non-generalizable panel rendering also
-// happens in this module.  For this reason, the bg plane doesn't
-// bother with functions embedded in the plane struct.  They're simply
-// called directly by the panel code.
+// other planes. The bg plane doesn't bother with functions embedded
+// in the plane struct.  They're simply called directly by the panel
+// code.
 
 void bg_recompute_setup(sv_panel_t *p){
   sv_planebg_t *pl = p->bg;
@@ -44,7 +43,8 @@
   pl->image_x = _sv_dim_panelscale(payload + x_dim, p->w, 0);
   pl->image_y = _sv_dim_panelscale(payload + y_dim, p->h, 1);
   pl->image_task = 0;
-
+  pl->expose_top = -1;
+  pl->expose_bottom = -1;
 }
 
 void bg_resize(sv_panel_t *p){
@@ -145,29 +145,12 @@
 }
 
 int bg_scale(sv_panel_t *p){
-
-      _sv_plot_draw_scales(plot); // this should happen outside lock
-
-
-
+  pthread_mutex_unlock(p->status_m);
+  _sv_plot_draw_scales(p->graph);
+  pthread_mutex_lock(p->status_m);
 }
 
-int bg_render(sv_panel_t *p){
-
-
-}
-
-int bg_expose(sv_panel_t *p){
-
-
-}
-
-sv_planebg_t *sv_planebg_new(sv_panel_t *p){
-
-
-}
-
-static void render_checks(_sv_ucolor_t *c, int w, int y){
+static void render_checks(sv_ucolor_t *c, int w, int y){
   /* default checked background */
   /* 16x16 'mid-checks' */ 
   int x,j;
@@ -182,174 +165,108 @@
   }
 }
 
-// enter with lock
-static int _sv_panel2d_render_bg_line(sv_panel_t *p, int plot_serialno, int map_serialno){
-  _sv_panel2d_t *p2 = p->subtype->p2;
-  _sv_plot_t *plot = PLOT(p->private->graph);
-  if(plot_serialno != p->private->plot_serialno ||
-     map_serialno != p->private->map_serialno) return -1;
-  
-  int ph = p2->y.pixels;
-  int pw = p2->x.pixels;
-  unsigned char *todo = p2->bg_todo;
-  int i = p2->bg_next_line,j;
-  _sv_ucolor_t work_bg[pw];
-  _sv_ucolor_t work_pl[pw];
-  int bgmode = p->private->bg_type;
+int bg_render(sv_panel_t *p){
+  sv_planebg_t *bg = &p->bg;
+  sv_plot_t *plot = p->plot;
+  int serialno = p->compute_serialno;
+  int w = p->w,y;
+  int h = p->h;
+  sv_ucolor_t line[w];
 
-  /* find a row that needs to be updated */
-  while(i<ph && !todo[i]){
-    p->private->map_complete_count--;
-    p2->bg_next_line++;
-    i++;
-  }
+  int bgtype=0;
+  double r;
+  double g;
+  double b;
 
-  if(i == ph)
-    goto done;
-
-  if(i < p2->bg_first_line) p2->bg_first_line = i;
-  if(i+1 > p2->bg_last_line) p2->bg_last_line = i+1;
-  p2->bg_next_line++;
-
-  /* gray background checks */
-  gdk_unlock();
-
-  switch(bgmode){
-  case SV_BG_WHITE:
-    for(j=0;j<pw;j++)
-      work_bg[j].u = 0xffffffffU;
-    break;
-  case SV_BG_BLACK:
-    for(j=0;j<pw;j++)
-      work_bg[j].u = 0xff000000U;
-    break;
-  default:
-    render_checks(work_bg,pw,i);
-    break;
+  if(bg->bg[0]=='#' && strlen(bg->bg)==7){
+    bgtype=1;
+    r = (toupper(bg->bg[1])-65)*.0625 + (toupper(bg->bg[2])-65)*.00390625;
+    g = (toupper(bg->bg[3])-65)*.0625 + (toupper(bg->bg[4])-65)*.00390625;
+    b = (toupper(bg->bg[5])-65)*.0625 + (toupper(bg->bg[6])-65)*.00390625;
   }
 
-  /* by objective */
-  for(j=0;j<p->objectives;j++){
-    int o_ynum = p2->y_obj_from_panel[j];
+  // look for a line that needs love
+  do{
+    y = bg->image_nextline;
+    bg->image_nextline++;
+    if(bg->image_nextline>=h)bg->image_nextline=0;
     
-    gdk_lock();
-    if(plot_serialno != p->private->plot_serialno ||
-       map_serialno != p->private->map_serialno) return -1;
-
-    /**** mix Y plane */
-    
-    if(p2->y_planes[o_ynum]){
-      int x;
-      _sv_ucolor_t (*mixfunc)(_sv_ucolor_t,_sv_ucolor_t) = p2->mappings[j].mixfunc;
-      _sv_ucolor_t *rect = p2->y_planes[o_ynum] + i*pw;
-      memcpy(work_pl,rect,sizeof(work_pl));
+    if(bg->image_flags[y]){
+      sv_scalespace_t ix = bg->image_x;
+      sv_scalespace_t iy = bg->image_y;
       
-      gdk_unlock();
-      for(x=0;x<pw;x++)
-	work_bg[x] = mixfunc(work_pl[x],work_bg[x]);
-    }else
-      gdk_unlock();
+      // render this line 
+      bg->image_flags[i]=0;
+      bg->image_outstanding++;
 
-    /**** mix Z plane */
-    
-    /**** mix vector plane */
+      pthread_mutex_unlock(p->status_m);
 
-  }
+      // bg renders a line at a time primarily as a concession to the 2d panels.  
+      if(bgtype==0){
+	render_checks(line,w,y);
+      }else{
+	u_int32_t val = 0xff000000 | (r<<16) | (g<<8) | (b);
+	for(i=0;i<w;i++)line[i]=val;
+      }
+      
+      // grab line from panels in order.  Mix using plane native mix function
+      for(i=0;i<p->planes;i++){
+	sv_ucolor_t *mix(sv_ucolor_t, sv_ucolor_t) = p->plane_list[i]->c.mix;
+	sv_ucolor_t *pline = p->plane_list[i]->c.image[y*w]l
+	for(j=0;j<w;j++)
+	  line[j] = mix(pline[j],line[j]);
+      }
 
-  gdk_lock();
-  if(plot_serialno != p->private->plot_serialno ||
-     map_serialno != p->private->map_serialno) return -1;
+      pthread_mutex_lock(pl->status_m);
+      
+      if(p->compute_serialno == serialno){
+	bg->image_outstanding--;
 
-    // rendered a line, get it on the screen */
-  
-  memcpy(plot->datarect+pw*i, work_bg, sizeof(work_bg));
+	plot_write_line(p->plot,line);
 
-  p->private->map_complete_count--;
+	//invalidate rectangle for expose
+	if(bg->expose_top == -1 || bg->expose_top > y)
+	  bg->expose_top=y;
+	if(bg->expose_bottom == -1 || bg->expose_bottom < y)
+	  bg->expose_bottom=y;
+      }
+      return STATUS_WORKING;
+    }
+  }while(i!=last);
 
- done:
-  if(p->private->map_complete_count)
-    return 1; // not done yet
-
-  return 0;
+  if(bg->image_outstanding) return STATUS_BUSY;
+  return STATUS_IDLE;
 }
 
+int bg_expose(sv_panel_t *p){
+  sv_planebg_t *bg = &p->bg;
+  if(pl->expose_top != -1){
+    GdkRectangle r;
+    r.y = bg->expose_top;
+    r.h = bg->expose_bottom - bg->expose_top+1;
+    rx = 0;
+    r.w = p->w;
 
-// enter with lock
-static void _sv_panel2d_update_legend(sv_panel_t *p){  
-  _sv_panel2d_t *p2 = p->subtype->p2;
-  _sv_plot_t *plot = PLOT(p->private->graph);
+    pl->expose_top = -1;
+    pl->expose_bottom = -1;
+    pthread_mutex_unlock(p->status_m);
 
-  if(plot){
-    int i;
-    char buffer[320];
-    int depth = 0;
-    _sv_plot_legend_clear(plot);
-
-    // potentially add each dimension to the legend; add axis
-    // dimensions only if crosshairs are active
-
-    // display decimal precision relative to display scales
-    if(3-_sv_scalespace_decimal_exponent(&p2->x) > depth) 
-      depth = 3-_sv_scalespace_decimal_exponent(&p2->x);
-    if(3-_sv_scalespace_decimal_exponent(&p2->y) > depth) 
-      depth = 3-_sv_scalespace_decimal_exponent(&p2->y);
-    for(i=0;i<p->dimensions;i++){
-      sv_dim_t *d = p->dimension_list[i].d;
-      if( (d!=p->private->x_d && d!=p->private->y_d) ||
-	  plot->cross_active){
-	snprintf(buffer,320,"%s = %+.*f",
-		 p->dimension_list[i].d->legend,
-		 depth,
-		 p->dimension_list[i].d->val);
-	_sv_plot_legend_add(plot,buffer);
-      }
-    }
+    // the only place worker thread should ever touch the GDK lock
+    gdk_threads_enter();
+    gdk_invalidate_rectangle(GTK_WIDGET(p->plot),&r,FALSE);
+    gdk_threads_leave();
     
-    // add each active objective plane to the legend
-    // choose the value under the crosshairs 
-    if(plot->cross_active){
-      // one space 
-      _sv_plot_legend_add(plot,NULL);
-
-      for(i=0;i<p->objectives;i++){
-	
-	if(!_sv_mapping_inactive_p(p2->mappings+i)){
-	  compute_result vals;
-	  _sv_panel2d_compute_point(p,p->objective_list[i].o, plot->selx, plot->sely, &vals);
-	  
-	  if(!isnan(vals.y)){
-	    
-	    snprintf(buffer,320,"%s = %f",
-		     p->objective_list[i].o->name,
-		     vals.y);
-	    _sv_plot_legend_add(plot,buffer);
-	  }
-	}
-      }
-    }
   }
 
-  XXXXXX outside lock
-  _sv_plot_draw_legend(plot);
-
-
-
+  return STATUS_IDLE;
 }
 
-// subtype entry point for legend redraws; lock held
-static int _sv_panel2d_legend_redraw(sv_panel_t *p){
-  _sv_plot_t *plot = PLOT(p->private->graph);
-
-  if(p->private->legend_progress_count)return 0;
-  p->private->legend_progress_count++;
-  _sv_panel2d_update_legend(p);
-  _sv_panel_clean_legend(p);
-
-  gdk_unlock();
-  _sv_plot_draw_scales(plot);
-  gdk_lock();
-
-  _sv_plot_expose_request(plot);
-  return 1;
+sv_planebg_t *sv_planebg_new(sv_panel_t *p){
+  sv_planebg_t *ret = calloc(1, sizeof(*ret));
+  
+  ret->panel=p;
+  ret->bg = strdup("checks");
+  return(ret);
 }
 
+

Modified: trunk/sushivision/plane.h
===================================================================
--- trunk/sushivision/plane.h	2007-10-23 22:25:31 UTC (rev 14039)
+++ trunk/sushivision/plane.h	2007-10-24 10:57:28 UTC (rev 14040)
@@ -36,7 +36,7 @@
   sv_scalespace_t *data_scales;
 
   sv_ucolor_t     *image;
-  sv_ucolor_t    (*mix[])(sv_ucolor_t, sv_ucolor_t);
+  sv_ucolor_t    (*mix)(sv_ucolor_t, sv_ucolor_t);
   sv_scalespace_t  image_x;
   sv_scalespace_t  image_y;
   int              axes;
@@ -52,18 +52,23 @@
 
   void (*demultiplex)(sv_plane_t *, double *out, int dw, int x, int y, int n);
 
+  GtkWidget *(plane_label)(sv_plane_t *);
+  GtkWidget *(plane_obj)(sv_plane_t *);
+
 } sv_plane_common_t;
 
 struct sv_plane_bg {
   sv_plane_common_t c;
 
-  // image data and concurrency tracking
-
   // status
   int              image_outstanding;
   int              image_nextline;
   unsigned char   *image_flags;
 
+  int              expose_top;
+  int              expose_bottom;
+
+  char *bg;
 };
 
 struct sv_plane_2d {



More information about the commits mailing list