[xiph-commits] r13784 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Sep 11 22:54:01 PDT 2007


Author: xiphmont
Date: 2007-09-11 22:54:00 -0700 (Tue, 11 Sep 2007)
New Revision: 13784

Modified:
   trunk/sushivision/Makefile
   trunk/sushivision/example_fractal.c
   trunk/sushivision/mapping.c
   trunk/sushivision/mapping.h
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel-2d.h
   trunk/sushivision/slider.c
Log:
More inprogress work.  The whole engine is currently torn apart.



Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/Makefile	2007-09-12 05:54:00 UTC (rev 13784)
@@ -24,15 +24,15 @@
 SOCFLAGS  = -fPIC
 SOLDFLAGS = -shared -nostdlib -Wl,-soname="lib$(NAME).so.$(MAJOR)"
 
-SRC       = main.c scale.c plot.c slider.c slice.c spinner.c objective.c panel.c panel-2d.c \
-	mapping.c dimension.c function.c undo.c gtksucks.c xml.c \
+SRC       = main.c mapping.c scale.c plot.c slider.c slice.c spinner.c objective.c panel.c panel-2d.c \
+	dimension.c function.c undo.c gtksucks.c xml.c \
 	tokens.c example_fractal.c example_discrete.c example_chirp.c example_spirograph.c
 INC       = sushivision.h sushimacro.h
 MAN	  =
 EXAMPLES  = sushivision_fractal #sushivision_discrete sushivision_chirp
 EX_OBJ    = example_fractal.o #example_discrete.o example_chirp.o example_spirograph.o
-OBJ       = main.o scale.o plot.o slider.o slice.o spinner.c objective.o panel.o panel-2d.o \
-	mapping.o dimension.o function.o undo.o gtksucks.o xml.o tokens.c
+OBJ       = main.o mapping.o scale.o plot.o slider.o slice.o spinner.c objective.o panel.o panel-2d.o \
+	dimension.o function.o undo.o gtksucks.o xml.o tokens.c
 LIBS      = -lpthread -ldl
 CAIROVER  =  >= 1.4.1
 GTKVER    =  >= 2.10.0

Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/example_fractal.c	2007-09-12 05:54:00 UTC (rev 13784)
@@ -76,7 +76,7 @@
 		    "1000:one thousand,"
 		    "10000:ten thousand,"
 		    "100000:one hundred thousand");
-  sv_dim_set_value(100);
+  sv_dim_set_value(10000);
 
   sv_obj_new("outer",fractal_objective,"rc,ic,rz,iz,it", "Z,*");
   sv_obj_make_scale("0, .001, .01, .1, 1.0");

Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/mapping.c	2007-09-12 05:54:00 UTC (rev 13784)
@@ -34,31 +34,35 @@
   r->a += mul; 
 
   switch(category){
-  case 0:
-    r->g += val; break;
-  case 1:
+  case 0: // indigo
+    r->r += val>>2; r->b += (val*3)>>2; break;
+  case 1: // deep blue
+    r->b += val; break;
+  case 2: // light blue 
+    r->g = (val*3) >> 2; r->b += val; break;
+
+  case 3: // cyan
+    r->g += val; r->b += (val*3)>>2; break;
+  case 4: // spring green
+    r->g += val; r->b+=val>>2; break;
+
+  case 5: //yellow green 
+    r->r += val>>1; r->g += val; break;
+  case 6: //yellow
     r->r += val; r->g += val; break;
-  case 2:
+  case 7: // orange
     r->r += val; r->g += val>>1; break;
-  case 3:
+  case 8: // red
     r->r += val; break;
-  case 4:
+  case 9: // magenta
     r->r += val; r->b += (val*3+2)>>2; break;
-  case 5:
-    r->r += (val*3+2)>>2; r->b += val; break;
-  case 6:
-    r->r += val>>1; r->b += val; break;
-  case 7:
-    r->b += val; break;
-  case 8:
-    r->g += (val*3+2)>>2; r->b += val; break;
-  case 9:
-    r->g += val; r->b+=val; break;
-  case 10:
-    r->r += val>>1; r->g += val; r->b += val; break;
-  case 11:
+
+
+  case 10: // pink
+    r->b += val; r->g += (val*3)>>2; r->r += val; break;
+  case 11: // gray 
     r->r += val; r->g += val; r->b += val; break;
-  default:
+  default: // white
     r->r += mul; r->g += mul; r->b += mul; break;
   }
 }
@@ -66,53 +70,57 @@
 static void _sv_mapping_smooth_colorwheel(int val, int mul, _sv_lcolor_t *r){
   if(val<0)return;
   r->a += mul;
+
+  // green -> yellow -> red   -> magenta -> blue -> cyan    -> white
+  // blue  -> cyan   -> green -> yellow  -> red  -> magenta -> white
+
   if(val < 37450){ // 4/7
     if(val < 18725){ // 2/7
       if(val < 9363){ // 1/7
 
-	// 0->1, 0->g
-	r->g+=(7L*val*mul)>>16;
+	// 0->1, 0->b
+	r->b+=(7L*val*mul)>>16;
 	
       }else{
 
-	// 1->2, g->rg
-	r->r+=((7L*val - 65536)*mul)>>16;
-	r->g+=mul;
+	// 1->2, b->bg
+	r->g+=((7L*val - 65536)*mul)>>16;
+	r->b+=mul;
 	
       }
     }else{
       if(val < 28087){ // 3/7
 
-	// 2->3, rg->r
-	r->r+=mul;
-	r->g+=((196608 - 7L*val)*mul)>>16;
+	// 2->3, bg->g
+	r->g+=mul;
+	r->b+=((196608 - 7L*val)*mul)>>16;
 	
       }else{
 
-	// 3->4, r->rb
-	r->r+=mul;
-	r->b+=((7L*val - 196608)*mul)>>16;
+	// 3->4, g->gr
+	r->g+=mul;
+	r->r+=((7L*val - 196608)*mul)>>16;
 
       }
     }
   }else{
     if(val < 46812){ // 5/7
 
-      // 4->5, rb->b
-      r->r+=((327680 - 7L*val)*mul)>>16;
-      r->b+=mul;
+      // 4->5, gr->r
+      r->g+=((327680 - 7L*val)*mul)>>16;
+      r->r+=mul;
       
     }else{
       if(val < 56174){ // 6/7
 
-	// 5->6, b->bg
-	r->g+=((7L*val - 327680)*mul)>>16;
-	r->b+=mul;
+	// 5->6, r->br
+	r->b+=((7L*val - 327680)*mul)>>16;
+	r->r+=mul;
 	
       }else{
-	// 6->7, bg->rgb
-	r->r+=((7L*val - 393216)*mul)>>16;
-	r->g+=mul;
+	// 6->7, rb->rgb
+	r->g+=((7L*val - 393216)*mul)>>16;
+	r->r+=mul;
 	r->b+=mul;
 	
       }
@@ -120,7 +128,7 @@
   }
 }
 
-static void _sv_mapping_white(int val, int mul, _sv_lcolor_t *r){
+static void _sv_mapping_grayscale(int val, int mul, _sv_lcolor_t *r){
   if(val<0)return;
   val = (val*mul)>>16;
   r->a += mul;
@@ -283,10 +291,10 @@
   return bg;
 }
 
-static void (*mapfunc[])(int, int, _sv_lcolor_t *)={
+void (*mapfunc[])(int, int, _sv_lcolor_t *)={
   _sv_mapping_smooth_colorwheel,
   _sv_mapping_scalloped_colorwheel,
-  _sv_mapping_white,
+  _sv_mapping_grayscale,
   _sv_mapping_red,
   _sv_mapping_green,
   _sv_mapping_blue,
@@ -296,7 +304,7 @@
   _sv_mapping_inactive
 };
 
-static _sv_ucolor_t (*mixfunc[])(_sv_ucolor_t, _sv_ucolor_t)={
+_sv_ucolor_t (*mixfunc[])(_sv_ucolor_t, _sv_ucolor_t)={
   _sv_mapping_normal_mix,
   _sv_mapping_normal_mix,
   _sv_mapping_normal_mix,
@@ -309,7 +317,7 @@
   _sv_mapping_inactive_mix
 };
 
-static _sv_propmap_t *mapnames[]={
+_sv_propmap_t *mapnames[]={
   &(_sv_propmap_t){"smooth colorwheel",0,    NULL, NULL, NULL},
   &(_sv_propmap_t){"scalloped colorwheel",1, NULL, NULL, NULL},
   &(_sv_propmap_t){"grayscale",2,            NULL, NULL, NULL},
@@ -333,73 +341,7 @@
   return mapnames[i]->left;
 }
 
-_sv_propmap_t **_sv_mapping_map(){
-  return mapnames;
-}
-
-void _sv_mapping_setup(_sv_mapping_t *m, float lo, float hi, int funcnum){
-  m->low = lo;
-  m->high = hi;
-  m->i_range = 1./(hi-lo);
-  m->mapfunc = mapfunc[funcnum];
-  m->mixfunc = mixfunc[funcnum];
-}
-
-void _sv_mapping_set_lo(_sv_mapping_t *m, float lo){
-  m->low = lo;
-  if(m->high-m->low>0.)
-    m->i_range = 1./(m->high-m->low);
-  else
-    m->i_range=0;
-}
-
-void _sv_mapping_set_hi(_sv_mapping_t *m, float hi){
-  m->high=hi;
-  if(m->high-m->low>0.)
-    m->i_range = 1./(m->high-m->low);
-  else
-    m->i_range=0;
-}
-
-void _sv_mapping_set_func(_sv_mapping_t *m, int funcnum){
-  m->mapnum = funcnum;
-  m->mapfunc = mapfunc[funcnum];
-  m->mixfunc = mixfunc[funcnum];
-}
-
-float _sv_mapping_val(_sv_mapping_t *m, float in){
-  if(m->i_range==0){
-    return NAN;
-  }else{
-    return (in - m->low) * m->i_range;
-  }
-}
-
-u_int32_t _sv_mapping_calc(_sv_mapping_t *m, float in, u_int32_t mix){
-  _sv_lcolor_t outc = {0,0,0,0};
-  
-  if(m->i_range==0){
-    if(in<=m->low)
-      m->mapfunc(0,255,&outc);
-    else
-      m->mapfunc(256*256,255,&outc);
-  }else{
-    float val = (in - m->low) * m->i_range;
-    if(val<0.f)val=0.f;
-    if(val>1.f)val=1.f;
-    m->mapfunc(rint(val*65536.f),255,&outc);
-  }
-
-  return m->mixfunc( (_sv_ucolor_t)(u_int32_t)((outc.a<<24) + (outc.r<<16) + (outc.g<<8) + outc.b),
-		     (_sv_ucolor_t)mix).u | 0xff000000;
-}
-
-int _sv_mapping_inactive_p(_sv_mapping_t *m){
-  if(m->mapfunc == _sv_mapping_inactive)return 1;
-  return 0;
-}
-
-static void (*mapsolid[])(int, int, _sv_lcolor_t *)={
+void (*mapsolid[])(int, int, _sv_lcolor_t *)={
   _sv_mapping_black_a,
   _sv_mapping_red_a,
   _sv_mapping_green_a,
@@ -412,7 +354,7 @@
   _sv_mapping_inactive
 };
 
-static _sv_ucolor_t (*mixsolid[])(_sv_ucolor_t, _sv_ucolor_t)={
+_sv_ucolor_t (*mixsolid[])(_sv_ucolor_t, _sv_ucolor_t)={
   _sv_mapping_normal_mix,
   _sv_mapping_normal_mix,
   _sv_mapping_normal_mix,
@@ -425,7 +367,7 @@
   _sv_mapping_inactive_mix
 };
 
-static _sv_propmap_t *solidnames[]={
+_sv_propmap_t *solidnames[]={
   &(_sv_propmap_t){"black",0,     NULL,NULL,NULL},
   &(_sv_propmap_t){"red",1,       NULL,NULL,NULL},
   &(_sv_propmap_t){"green",2,     NULL,NULL,NULL},
@@ -449,20 +391,11 @@
   return solidnames[i]->left;
 }
 
-_sv_propmap_t **_sv_solid_map(){
-  return solidnames;
-}
+u_int32_t _sv_mapping_calc(_sv_mapping_t *m, float val, u_int32_t mix){
+  _sv_lcolor_t outc = {0,0,0,0};
+  
+  m->mapfunc(rint(val*65536.f),255,&outc);
 
-void _sv_solid_setup(_sv_mapping_t *m, float lo, float hi, int funcnum){
-  m->low = lo;
-  m->high = hi;
-  m->i_range = 1./(hi-lo);
-  m->mapfunc = mapsolid[funcnum];
-  m->mixfunc = mixsolid[funcnum];
+  return m->mixfunc( (_sv_ucolor_t)(u_int32_t)((outc.a<<24) + (outc.r<<16) + (outc.g<<8) + outc.b),
+		     (_sv_ucolor_t)mix).u | 0xff000000;
 }
-
-void _sv_solid_set_func(_sv_mapping_t *m, int funcnum){
-  m->mapnum = funcnum;
-  m->mapfunc = mapsolid[funcnum];
-  m->mixfunc = mixsolid[funcnum];
-}

Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/mapping.h	2007-09-12 05:54:00 UTC (rev 13784)
@@ -49,30 +49,25 @@
   long b;
 } _sv_lcolor_t;
 
+
 typedef struct {
   int mapnum;
   float low;
   float high;
   float i_range;
-  void (*mapfunc)(int val,int mul, _sv_lcolor_t *out);
-  _sv_ucolor_t (*mixfunc)(_sv_ucolor_t in, _sv_ucolor_t mix);
+  
 } _sv_mapping_t;
 
+
 extern int       _sv_mapping_names();
 extern char     *_sv_mapping_name(int i);
-extern void      _sv_mapping_setup(_sv_mapping_t *m, float lo, float hi, int funcnum);
-extern void      _sv_mapping_set_lo(_sv_mapping_t *m, float lo);
-extern void      _sv_mapping_set_hi(_sv_mapping_t *m, float hi);
-extern void      _sv_mapping_set_func(_sv_mapping_t *m, int funcnum);
-extern float     _sv_mapping_val(_sv_mapping_t *m, float in);
-extern u_int32_t _sv_mapping_calc(_sv_mapping_t *m, float in, u_int32_t mix);
-extern int       _sv_mapping_inactive_p(_sv_mapping_t *m);
 
 extern int       _sv_solid_names();
 extern char     *_sv_solid_name(int i);
-extern void      _sv_solid_setup(_sv_mapping_t *m, float lo, float hi, int funcnum);
-extern void      _sv_solid_set_func(_sv_mapping_t *m, int funcnum);
 
-extern _sv_propmap_t **_sv_mapping_map();
-extern _sv_propmap_t **_sv_solid_map();
-
+extern void (*mapfunc[])(int, int, _sv_lcolor_t *);
+extern _sv_ucolor_t (*mixfunc[])(_sv_ucolor_t, _sv_ucolor_t);
+extern _sv_propmap_t *mapnames[];
+extern void (*mapsolid[])(int, int, _sv_lcolor_t *);
+extern _sv_ucolor_t (*mixsolid[])(_sv_ucolor_t, _sv_ucolor_t);
+extern _sv_propmap_t *solidnames[];

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/panel-2d.c	2007-09-12 05:54:00 UTC (rev 13784)
@@ -35,15 +35,18 @@
 /* helper functions for performing progressive computation */
 
 // enter unlocked
-static void _sv_panel2d_compute_line(sv_panel_t *p, 
-				     int serialno,
-				     int dw,
-				     int y,
-				     int x_d, 
-				     _sv_scalespace_t sxi,
-				     double *dim_vals, 
-				     _sv_bythread_cache_2d_t *c){
+static void _sv_planez_compute_line(sv_panel_t *p, 
+				    _sv_planez_t *z,
 
+				    int serialno,
+
+				    int dw,
+				    int y,
+				    int x_d, 
+				    _sv_scalespace_t sxi,
+				    double *dim_vals, 
+				    _sv_bythread_cache_2d_t *c){
+
   _sv_panel2d_t *p2 = p->subtype->p2;
   int i,j;
   

Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/panel-2d.h	2007-09-12 05:54:00 UTC (rev 13784)
@@ -19,44 +19,116 @@
  * 
  */
 
+// plane mutex policy:  
+//
+//  gdk_m -> panel_m -> obj_m -> dim_m -> scale_m
+//  |
+//  -> z.status_m -> bg.status_m -> z.data_m -> z.image_m -> bg.image_m 
+
 #define PLANE_Z 1
  
-union {
-  _sv_planez_t z;
-} _sv_plane_t;
+typedef union  _sv_plane _sv_plane_t;
+typedef struct _sv_plane_proto _sv_plane_proto_t;
+typedef struct _sv_plane_bg _sv_plane_bg_t;
+typedef struct _sv_plane_z _sv_plane_z_t;
 
-typedef struct {
-  // common
+struct _sv_plane_proto {
+  // in common with all plane types
   int plane_type;
   int working;
   sv_obj_t *o;
   _sv_plane_t *share_next;
   _sv_plane_t *share_prev;
-  
+
+};
+
+// bg plane mutex policy: [mutexes from one other plane] -> image -> status -> [back to other plane]
+struct _sv_plane_bg {
+  // in common with all plane types
+  int plane_type;
+  int working;
+  sv_obj_t *o;
+  _sv_plane_t *share_next;
+  _sv_plane_t *share_prev;
+
+   _sv_ucolor_t  *image; // panel size
+  int             image_serialno;
+  pthread_mutex_t image_m; 
+
+  // concurrency tracking
+  unsigned char  *line_status; // rendering flags
+  int             progress; // round-robin indicator
+  pthread_mutex_t status_m;
+};
+
+struct sv_zmap {
+
+  double *label_vals;
+  int labels;
+  int neg;
+  double al;
+  double lo;
+  double hi;
+  double lodel;
+  double *labeldelB;
+  double *labelvalB;
+
+};
+
+// z-plane mutex policy: data -> image plane -> [bg mutextes] -> status
+struct _sv_plane_z {
+  // in common with all plane types
+  int plane_type;
+  int working;
+  sv_obj_t *o;
+  _sv_plane_t *share_next;
+  _sv_plane_t *share_prev;
+  pthread_mutex_t planem;
+
   // subtype 
-  float         *data;   // native data size
-  int32_t       *map;    // native data size
-  _sv_ucolor_t  *buffer; // resampled data size;
+  // objective data
+  float          *data;   // data size
+  int             data_serialno; 
+  pthread_mutex_t data_m;
 
-  unsigned char *line_status; 
-  int            progress;
-} _sv_planez_t;
+  // image plane
+  _sv_ucolor_t   *image; // panel size;
+  int             image_serialno;
+  struct sv_zmap  image_map;
+  pthread_mutex_t image_m;
 
+  // concurrency tracking
+  unsigned char  *line_status; // rendering flags
+  int             progress; // round-robin indicator
+  pthread_mutex_t status_m;
+
+  // ui elements; use gdk lock
+  _sv_mapping_t   *mapping;
+  _sv_slider_t    *scale;
+  GtkWidget       *range_pulldown;
+  double           alphadel;
+
+};
+
+union {
+  _sv_plane_proto_t proto;
+  _sv_plane_bg_t bg;
+
+  _sv_plane_z_t z;
+} _sv_plane;
+
 typedef struct {
 
   GtkWidget *obj_table;
   GtkWidget *dim_table;
 
-  unsigned char *bg_todo;
-  int bg_next_line;
-  int bg_first_line;
-  int bg_last_line;
+  _sv_plane_t *bg;
 
   int planes;
   _sv_plane_t **plane_list;
   int next_plane; 
   
-  /* cached resampling helpers */
+  /* cached z-plane resampling helpers */
   int resample_serialno;
   unsigned char *ydelA;
   unsigned char *ydelB;
@@ -75,16 +147,11 @@
   int scales_init;
   double oldbox[4];
 
-  _sv_mapping_t    *mappings;
-  _sv_slider_t    **range_scales;
-  GtkWidget **range_pulldowns;
-  double     *alphadel;
+  GtkWidget **dim_xb; // X axis selector buttons
+  GtkWidget **dim_yb; // Y axis selector buttons
 
-  GtkWidget **dim_xb;
-  GtkWidget **dim_yb;
-
-  _sv_dim_widget_t *x_scale;
-  _sv_dim_widget_t *y_scale;
+  _sv_dim_widget_t *x_scale; // pointer to current X axis dimwidget
+  _sv_dim_widget_t *y_scale; // pointer to current Y axis dimwidget
   int x_dnum; // panel, not global list context
   int y_dnum; // panel, not global list context
 

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2007-09-12 02:53:20 UTC (rev 13783)
+++ trunk/sushivision/slider.c	2007-09-12 05:54:00 UTC (rev 13784)
@@ -507,13 +507,6 @@
   }
 
   return v*s->labeldelB[j] + s->labelvalB[j];
-
-  //labeldelB[j] = labeldel[j] * idelrange;
-  //labelvalB[j] = (j-label_vals[j]*s->labeldel[j]-s->lodel)*s->idelrange;
-
-
-
-  //return (j + (v-s->label_vals[j])*s->labeldel[j] - s->lodel) * s->idelrange;
 }
 
 void _sv_slider_expose_slice(_sv_slider_t *s, int slicenum){



More information about the commits mailing list