[xiph-commits] r12462 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Feb 12 22:51:37 PST 2007
Author: xiphmont
Date: 2007-02-12 22:51:35 -0800 (Mon, 12 Feb 2007)
New Revision: 12462
Modified:
trunk/sushivision/internal.h
trunk/sushivision/main.c
trunk/sushivision/panel-1d.c
trunk/sushivision/panel-2d.c
trunk/sushivision/panel.c
trunk/sushivision/plot.c
trunk/sushivision/plot.h
Log:
Add progress spinner
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/internal.h 2007-02-13 06:51:35 UTC (rev 12462)
@@ -70,6 +70,7 @@
int legend_dirty;
int maps_rendering;
int legend_rendering;
+ int panel_dirty;
time_t last_map_throttle;
@@ -106,7 +107,7 @@
extern void _sushiv_panel_dirty_map(sushiv_panel_t *p);
extern void _sushiv_panel_dirty_map_throttled(sushiv_panel_t *p);
extern void _sushiv_panel_dirty_legend(sushiv_panel_t *p);
-extern void _sushiv_wake_workers(void);
+extern void _sushiv_panel_dirty_panel(sushiv_panel_t *p);
extern void _maintain_cache(sushiv_panel_t *p, _sushiv_compute_cache *c, int w);
extern int _sushiv_panel_cooperative_compute(sushiv_panel_t *p,
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/main.c 2007-02-13 06:51:35 UTC (rev 12462)
@@ -44,6 +44,15 @@
static int instances=0;
static sushiv_instance_t **instance_list;
+void _sushiv_wake_workers(){
+ if(instances){
+ pthread_mutex_lock(&m);
+ wake_pending = num_threads;
+ pthread_cond_broadcast(&mc);
+ pthread_mutex_unlock(&m);
+ }
+}
+
void _sushiv_clean_exit(int sig){
_sushiv_exiting = 1;
_sushiv_wake_workers();
@@ -76,15 +85,6 @@
return num;
}
-void _sushiv_wake_workers(){
- if(instances){
- pthread_mutex_lock(&m);
- wake_pending = num_threads;
- pthread_cond_broadcast(&mc);
- pthread_mutex_unlock(&m);
- }
-}
-
static void *worker_thread(void *dummy){
/* set up temporary working space for function rendering; this saves
continuously recreating it in the loop below */
@@ -118,7 +118,8 @@
p->private->maps_dirty = 0;
p->private->maps_rendering = 1;
flag = 1;
-
+ plot_set_busy(PLOT(p->private->graph));
+
gdk_threads_leave ();
p->private->map_redraw(p);
gdk_threads_enter ();
@@ -132,6 +133,7 @@
p->private->legend_dirty = 0;
p->private->legend_rendering = 1;
flag = 1;
+ plot_set_busy(PLOT(p->private->graph));
gdk_threads_leave ();
p->private->legend_redraw(p);
@@ -142,8 +144,19 @@
gdk_threads_leave ();
// pending computation work?
- flag |= _sushiv_panel_cooperative_compute(s->panel_list[i],
- &c[j][i]);
+ if(p->private->panel_dirty)
+ flag |= _sushiv_panel_cooperative_compute(p,
+ &c[j][i]);
+
+ gdk_threads_enter ();
+ if(!flag &&
+ !p->private->panel_dirty &&
+ !p->private->legend_rendering &&
+ !p->private->legend_dirty &&
+ !p->private->maps_rendering &&
+ !p->private->maps_dirty)
+ plot_set_idle(PLOT(p->private->graph));
+ gdk_threads_leave ();
}
}
if(flag==1)continue;
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/panel-1d.c 2007-02-13 06:51:35 UTC (rev 12462)
@@ -688,7 +688,7 @@
p1->serialno++;
p1->last_line = 0;
- _sushiv_wake_workers();
+ _sushiv_panel_dirty_panel(p);
}
}
@@ -942,7 +942,6 @@
int x_d=-1;
int render_scale_flag = 0;
scalespace sy;
- scalespace syv;
scalespace sx;
scalespace sxv;
@@ -1028,6 +1027,7 @@
gdk_threads_enter ();
_sushiv_panel_dirty_map(p);
_sushiv_panel_dirty_legend(p);
+ p->private->panel_dirty = 0;
gdk_threads_leave ();
}else
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/panel-2d.c 2007-02-13 06:51:35 UTC (rev 12462)
@@ -872,7 +872,7 @@
p2->scaling_in_progress = 0;
_sushiv_panel1d_mark_recompute_linked(p);
- _sushiv_wake_workers();
+ _sushiv_panel_dirty_panel(p);
}
}
@@ -1138,7 +1138,6 @@
p2->scaling_in_progress = 0;
_sushiv_panel2d_map_redraw(p);
gdk_threads_leave ();
- _sushiv_wake_workers();
plot_draw_scales(plot);
}else
@@ -1146,10 +1145,6 @@
return 1;
}else{
- if(p2->scaling_in_progress){
- gdk_threads_leave();
- return 0;
- }
sx = p2->x;
sx_v = p2->x_v;
sx_i = p2->x_i;
@@ -1210,6 +1205,7 @@
if(p2->completed_lines>=dh){
_sushiv_panel_dirty_map(p);
_sushiv_panel_dirty_legend(p);
+ p->private->panel_dirty = 0;
}else{
_sushiv_panel_dirty_map_throttled(p);
}
Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/panel.c 2007-02-13 06:51:35 UTC (rev 12462)
@@ -33,6 +33,8 @@
#include <cairo-ft.h>
#include "internal.h"
+extern void _sushiv_wake_workers(void);
+
void _sushiv_realize_panel(sushiv_panel_t *p){
if(!p->private->realized){
p->private->realize(p);
@@ -91,6 +93,14 @@
return FALSE;
}
+void _sushiv_panel_dirty_panel(sushiv_panel_t *p){
+ gdk_threads_enter ();
+ p->private->panel_dirty = 1;
+ gdk_threads_leave ();
+ _sushiv_wake_workers();
+ return FALSE;
+}
+
void _sushiv_panel_dirty_map(sushiv_panel_t *p){
gdk_threads_enter ();
g_idle_add(_idle_map_fire,p);
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/plot.c 2007-02-13 06:51:35 UTC (rev 12462)
@@ -34,6 +34,69 @@
static GtkWidgetClass *parent_class = NULL;
+static void plot_draw_busy(Plot *p, cairo_t *c){
+ cairo_surface_t *s = p->stage;
+ int w = cairo_image_surface_get_width(s);
+ int h = cairo_image_surface_get_height(s);
+ int xv[8] = {-20,-13,-10,-13,-20,-27,-30,-27};
+ int yv[8] = {-30,-27,-20,-13,-10,-13,-20,-27};
+ int i;
+ double alpha=1.;
+
+ i = p->busy_count;
+ do{
+ double x = w+xv[i]+.5;
+ double y = h+yv[i]+.5;
+
+ cairo_set_source_rgba (c, 0,0,.5,1.);
+ cairo_arc(c,x,y,3.5,0,M_PI*2.);
+ cairo_fill(c);
+
+ cairo_set_source_rgba (c, 1.,1.,1.,alpha);
+ cairo_arc(c,x,y,3.5,0,M_PI*2.);
+ cairo_fill(c);
+
+ i--;
+ alpha *=.8;
+ if(i<0)i=7;
+ }while(i!=p->busy_count);
+}
+
+void plot_expose_busy(Plot *p){
+ cairo_surface_t *s = p->stage;
+ int w = cairo_image_surface_get_width(s);
+ int h = cairo_image_surface_get_height(s);
+
+ plot_expose_request_partial(p,w - 40, h - 40, 40, 40);
+}
+
+void plot_set_busy(Plot *p){
+ struct timeval now;
+ long test;
+
+ if(!p->busy){
+ p->busy=1;
+ plot_expose_busy(p);
+ }else{
+ gettimeofday(&now,NULL);
+
+ test = now.tv_sec*1000 + now.tv_usec/1000;
+ if(p->last_busy_throttle + 100 < test) {
+ p->busy_count++;
+ if(p->busy_count>7)
+ p->busy_count=0;
+ p->last_busy_throttle = test;
+ plot_expose_busy(p);
+ return;
+ }
+ }
+}
+
+void plot_set_idle(Plot *p){
+ p->busy=0;
+ plot_expose_busy(p);
+}
+
static void draw_scales_work(cairo_surface_t *s, scalespace xs, scalespace ys){
int w = cairo_image_surface_get_width(s);
int h = cairo_image_surface_get_height(s);
@@ -407,6 +470,10 @@
cairo_restore(c);
}
+ // busy indicator
+ if(p->busy)
+ plot_draw_busy(p, c);
+
cairo_destroy(c);
// blit to window
Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h 2007-02-13 03:38:05 UTC (rev 12461)
+++ trunk/sushivision/plot.h 2007-02-13 06:51:35 UTC (rev 12462)
@@ -57,6 +57,9 @@
double selx;
double sely;
int cross_active;
+ int busy;
+ int busy_count;
+ time_t last_busy_throttle;
double box_x1;
double box_y1;
@@ -119,5 +122,8 @@
void plot_do_enter(Plot *p);
void plot_do_escape(Plot *p);
+void plot_set_busy(Plot *p);
+void plot_set_idle(Plot *p);
+
#define PLOT_NO_X_CROSS 1
#define PLOT_NO_Y_CROSS 2
More information about the commits
mailing list