better progress feedback
This commit is contained in:
parent
e107dd11c0
commit
6fc3ec028c
3
TODO
3
TODO
@ -1,3 +1,6 @@
|
||||
- vips_sink_screen() should create its output images
|
||||
|
||||
|
||||
- how about something like vips_grid() which turns a tall thin one-band
|
||||
image into a much smaller many-band image?
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
* - pack and unpack rad to scrgb
|
||||
* 18/8/14
|
||||
* - fix conversion to 16-bit RGB, thanks John
|
||||
* 18/6/15
|
||||
* - forward progress signals from load
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -758,6 +760,31 @@ vips_foreign_load_iscompat( VipsImage *a, VipsImage *b )
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
/* Forward pre-eval-post signals to our output image so our caller can see
|
||||
* progress for load via disc or memory.
|
||||
*/
|
||||
|
||||
static void
|
||||
vips_foreign_load_preeval( VipsImage *image,
|
||||
VipsProgress *progress, VipsForeignLoad *load )
|
||||
{
|
||||
vips_image_preeval( load->out );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_foreign_load_eval( VipsImage *image,
|
||||
VipsProgress *progress, VipsForeignLoad *load )
|
||||
{
|
||||
vips_image_eval( load->out, progress->npels );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_foreign_load_posteval( VipsImage *image,
|
||||
VipsProgress *progress, VipsForeignLoad *load )
|
||||
{
|
||||
vips_image_posteval( load->out );
|
||||
}
|
||||
|
||||
/* Our start function ... do the lazy open, if necessary, and return a region
|
||||
* on the new image.
|
||||
*/
|
||||
@ -775,8 +802,20 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b )
|
||||
printf( "vips_foreign_load_start: triggering ->load()\n" );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
/* Read the image in.
|
||||
/* Read the image in. This may involve a long computation and
|
||||
* will finish with load->real holding the decompressed image.
|
||||
*
|
||||
* We want our caller to be able to see this computation on
|
||||
* @out, so we need to forward the signals.
|
||||
*/
|
||||
g_signal_connect( load->real, "preeval",
|
||||
G_CALLBACK( vips_foreign_load_preeval ), load );
|
||||
g_signal_connect( load->real, "eval",
|
||||
G_CALLBACK( vips_foreign_load_eval ), load );
|
||||
g_signal_connect( load->real, "posteval",
|
||||
G_CALLBACK( vips_foreign_load_posteval ), load );
|
||||
vips_image_set_progress( load->real, TRUE );
|
||||
|
||||
if( class->load( load ) ||
|
||||
vips_image_pio_input( load->real ) )
|
||||
return( NULL );
|
||||
|
@ -745,7 +745,7 @@ vips_image_save_cb( VipsImage *image, int *result )
|
||||
/* Progress feedback.
|
||||
*/
|
||||
|
||||
static int
|
||||
static void
|
||||
vips_image_preeval_cb( VipsImage *image, VipsProgress *progress, int *last )
|
||||
{
|
||||
int tile_width;
|
||||
@ -753,7 +753,7 @@ vips_image_preeval_cb( VipsImage *image, VipsProgress *progress, int *last )
|
||||
int nlines;
|
||||
|
||||
if( vips_image_get_typeof( image, "hide-progress" ) )
|
||||
return( 0 );
|
||||
return;
|
||||
|
||||
*last = -1;
|
||||
|
||||
@ -766,15 +766,13 @@ vips_image_preeval_cb( VipsImage *image, VipsProgress *progress, int *last )
|
||||
vips_concurrency_get(),
|
||||
tile_width, tile_height, nlines );
|
||||
printf( "\n" );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
vips_image_eval_cb( VipsImage *image, VipsProgress *progress, int *last )
|
||||
{
|
||||
if( vips_image_get_typeof( image, "hide-progress" ) )
|
||||
return( 0 );
|
||||
return;
|
||||
|
||||
if( progress->percent != *last ) {
|
||||
printf( _( "%s %s: %d%% complete" ),
|
||||
@ -789,23 +787,19 @@ vips_image_eval_cb( VipsImage *image, VipsProgress *progress, int *last )
|
||||
vips_region_dump_all();
|
||||
*/
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
vips_image_posteval_cb( VipsImage *image, VipsProgress *progress )
|
||||
{
|
||||
if( vips_image_get_typeof( image, "hide-progress" ) )
|
||||
return( 0 );
|
||||
return;
|
||||
|
||||
/* Spaces at end help to erase the %complete message we overwrite.
|
||||
*/
|
||||
printf( _( "%s %s: done in %.3gs \n" ),
|
||||
g_get_prgname(), image->filename,
|
||||
g_timer_elapsed( progress->start, NULL ) );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Attach progress feedback, if required.
|
||||
|
Loading…
Reference in New Issue
Block a user