[xiph-commits] r12569 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Feb 26 03:01:00 PST 2007
Author: xiphmont
Date: 2007-02-26 03:00:58 -0800 (Mon, 26 Feb 2007)
New Revision: 12569
Modified:
trunk/sushivision/internal.h
trunk/sushivision/panel-1d.c
trunk/sushivision/panel-2d.c
trunk/sushivision/panel.c
trunk/sushivision/plot.c
Log:
Add printing to 1-d panels
Clear path before beginning to print... the print context seems to be
handing us a cairo_t with an active path in it.
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2007-02-26 10:22:47 UTC (rev 12568)
+++ trunk/sushivision/internal.h 2007-02-26 11:00:58 UTC (rev 12569)
@@ -149,6 +149,4 @@
extern void _sushiv_panel1d_update_linked_crosshairs(sushiv_panel_t *p, int xflag, int yflag);
extern void _sushiv_panel_update_menus(sushiv_panel_t *p);
-extern void render_checks(ucolor *c, int w, int y);
-
extern sig_atomic_t _sushiv_exiting;
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2007-02-26 10:22:47 UTC (rev 12568)
+++ trunk/sushivision/panel-1d.c 2007-02-26 11:00:58 UTC (rev 12569)
@@ -57,22 +57,35 @@
NULL
};
+static void render_checks(cairo_t *c, int w, int h){
+ /* default checked background */
+ /* 16x16 'mid-checks' */
+ int x,y;
+
+ cairo_set_source_rgb (c, .5,.5,.5);
+ cairo_paint(c);
+ cairo_set_source_rgb (c, .314,.314,.314);
+
+ for(y=0;y<h;y+=16){
+ int phase = (y>>4)&1;
+ for(x=0;x<w;x+=16){
+ if(phase){
+ cairo_rectangle(c,x,y,16.,16.);
+ cairo_fill(c);
+ }
+ phase=!phase;
+ }
+ }
+}
+
// called internally, assumes we hold lock
// redraws the data, does not compute the data
-static void _sushiv_panel1d_remap(sushiv_panel_t *p){
+static int _sushiv_panel1d_remap(sushiv_panel_t *p, cairo_t *c){
sushiv_panel1d_t *p1 = p->subtype->p1;
Plot *plot = PLOT(p->private->graph);
- cairo_surface_t *back = plot->back;
int plot_serialno = p->private->plot_serialno;
int map_serialno = p->private->map_serialno;
-
- // render to a temp surface so that we can release the lock occasionally
- cairo_surface_t *cs = cairo_surface_create_similar(back,CAIRO_CONTENT_COLOR,
- cairo_image_surface_get_width(back),
- cairo_image_surface_get_height(back));
- ucolor *lback = (ucolor *)cairo_image_surface_get_data(cs);
- cairo_t *c = cairo_create(cs);
int xi,i,j;
int pw = plot->x.pixels;
int ph = plot->y.pixels;
@@ -112,14 +125,13 @@
cairo_paint(c);
break;
case SUSHIV_BG_CHECKS:
- for(i=0;i<ph;i++)
- render_checks(lback+pw*i, pw, i);
+ render_checks(c,pw,ph);
break;
}
gdk_threads_enter();
if(plot_serialno != p->private->plot_serialno ||
- map_serialno != p->private->map_serialno) goto abort;
+ map_serialno != p->private->map_serialno) return -1;
if(p1->data_vec){
@@ -327,24 +339,21 @@
gdk_threads_enter();
if(plot_serialno != p->private->plot_serialno ||
- map_serialno != p->private->map_serialno) goto abort;
+ map_serialno != p->private->map_serialno) return -1;
}
}
}
- cairo_surface_destroy(plot->back);
- plot->back = cs;
- cairo_destroy(c);
+ return 1;
+}
- _sushiv_panel_clean_map(p);
- plot_expose_request(plot);
- return;
+void sushiv_panel1d_print_bg(cairo_t *c, sushiv_panel_t *p){
+ Plot *plot = PLOT(p->private->graph);
- abort:
- cairo_destroy(c);
- cairo_surface_destroy(cs);
+ if(!plot) return;
+ _sushiv_panel1d_remap(p,c);
}
static void update_legend(sushiv_panel_t *p){
@@ -962,7 +971,28 @@
int _sushiv_panel1d_map_redraw(sushiv_panel_t *p, _sushiv_bythread_cache *c){
if(p->private->map_progress_count)return 0;
p->private->map_progress_count++;
- _sushiv_panel1d_remap(p);
+
+ // render to a temp surface so that we can release the lock occasionally
+ Plot *plot = PLOT(p->private->graph);
+ cairo_surface_t *back = plot->back;
+ cairo_surface_t *cs = cairo_surface_create_similar(back,CAIRO_CONTENT_COLOR,
+ cairo_image_surface_get_width(back),
+ cairo_image_surface_get_height(back));
+ cairo_t *ct = cairo_create(cs);
+
+ if(_sushiv_panel1d_remap(p,ct) == -1){ // returns -1 on abort
+ cairo_destroy(ct);
+ cairo_surface_destroy(cs);
+ }else{
+ // else complete
+ cairo_surface_destroy(plot->back);
+ plot->back = cs;
+ cairo_destroy(ct);
+
+ _sushiv_panel_clean_map(p);
+ plot_expose_request(plot);
+ }
+
return 1;
}
@@ -991,7 +1021,6 @@
int dw,w,h,i,d;
int serialno;
- double x_min, x_max;
int x_d=-1;
scalespace sy;
@@ -1413,6 +1442,7 @@
p->private->compute_action = _sushiv_panel1d_compute;
p->private->request_compute = _mark_recompute_1d;
p->private->crosshair_action = crosshair_callback;
+ p->private->data_print = sushiv_panel1d_print_bg;
p->private->undo_log = panel1d_undo_log;
p->private->undo_restore = panel1d_undo_restore;
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-02-26 10:22:47 UTC (rev 12568)
+++ trunk/sushivision/panel-2d.c 2007-02-26 11:00:58 UTC (rev 12569)
@@ -520,6 +520,21 @@
return 0;
}
+static void render_checks(ucolor *c, int w, int y){
+ /* default checked background */
+ /* 16x16 'mid-checks' */
+ int x,j;
+
+ int phase = (y>>4)&1;
+ for(x=0;x<w;){
+ u_int32_t phaseval = 0xff505050UL;
+ if(phase) phaseval = 0xff808080UL;
+ for(j=0;j<16 && x<w;j++,x++)
+ c[x].u = phaseval;
+ phase=!phase;
+ }
+}
+
// enter with lock
static int render_bg_line(sushiv_panel_t *p, int plot_serialno, int map_serialno){
sushiv_panel2d_t *p2 = p->subtype->p2;
Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c 2007-02-26 10:22:47 UTC (rev 12568)
+++ trunk/sushivision/panel.c 2007-02-26 11:00:58 UTC (rev 12569)
@@ -618,21 +618,6 @@
return 0;
}
-void render_checks(ucolor *c, int w, int y){
- /* default checked background */
- /* 16x16 'mid-checks' */
- int x,j;
-
- int phase = (y>>4)&1;
- for(x=0;x<w;){
- u_int32_t phaseval = 0xff505050UL;
- if(phase) phaseval = 0xff808080UL;
- for(j=0;j<16 && x<w;j++,x++)
- c[x].u = phaseval;
- phase=!phase;
- }
-}
-
int sushiv_panel_background(sushiv_instance_t *s,
int number,
enum sushiv_background bg){
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2007-02-26 10:22:47 UTC (rev 12568)
+++ trunk/sushivision/plot.c 2007-02-26 11:00:58 UTC (rev 12569)
@@ -435,9 +435,13 @@
int inv = p->bg_inv;
int grid = p->grid_mode;
+ gdk_threads_enter(); // double lock
+
cairo_save(c);
+ cairo_new_path(c);
cairo_rectangle(c,0,0,pw,ph);
cairo_clip(c);
+ cairo_new_path(c);
// render the background
if(datarender)
@@ -496,6 +500,9 @@
cairo_stroke(c);
cairo_restore(c);
+
+ gdk_threads_leave();
+
return 0;
}
More information about the commits
mailing list