This commit is contained in:
John Cupitt 2010-01-21 17:04:00 +00:00
parent ea7662658f
commit c5e3ce4408
6 changed files with 71 additions and 13 deletions

View File

@ -19,6 +19,8 @@
- better TIFF YCbCr reading (thanks Ole)
- isanalyze generates fewer silly error messages
- added "written" callbacks, used to implement write to non-vips formats
- "invalidate" is careful to keep images alive, so invalidate callbacks can do
im_close()
26/11/09 started 7.20.3
- updated en_GB.po translation

7
TODO
View File

@ -1,4 +1,9 @@
- test new floodfill in paintbox
- close callbacks could use invalidate's trick and give close callbacks more
safety
could get rid of a couple of image flags too
- flood blob with ink == initial click loops
- we sill have the old flood-fill code there, move to deprecated

View File

@ -559,16 +559,50 @@ im_invalidate_region( REGION *reg )
}
static void *
im_invalidate_image( IMAGE *im )
im_invalidate_image( IMAGE *im, GSList **to_be_invalidated )
{
(void) im_slist_map2( im->regions,
(VSListMap2Fn) im_invalidate_region, NULL, NULL );
if( im__trigger_callbacks( im->invalidatefns ) )
return( im );
*to_be_invalidated = g_slist_prepend( *to_be_invalidated, im );
return( NULL );
}
/* Trigger a callbacks on a list of images, where the callbacks might create
* or destroy the images.
*
* We make a set of temp regions to hold the images open, but when we switch
* to VipsObject we should incr/decr ref count.
*/
static void
im_invalidate_trigger( GSList *images )
{
GSList *regions;
GSList *p;
regions = NULL;
for( p = images; p; p = p->next ) {
IMAGE *im = (IMAGE *) p->data;
regions = g_slist_prepend( regions, im_region_create( im ) );
}
for( p = images; p; p = p->next ) {
IMAGE *im = (IMAGE *) p->data;
(void) im__trigger_callbacks( im->invalidatefns );
}
for( p = regions; p; p = p->next ) {
REGION *r = (REGION *) p->data;
im_region_free( r );
}
g_slist_free( regions );
}
/**
* im_invalidate:
* @im: #IMAGE to invalidate
@ -581,8 +615,22 @@ im_invalidate_image( IMAGE *im )
void
im_invalidate( IMAGE *im )
{
GSList *to_be_invalidated;
/* Invalidate callbacks might do anything, including removing images
* or invalidating other images, so we can't trigger them from within
* the image loop. Instead we collect a list of image to invalidate
* and trigger them all in one go, checking that they are not
* invalidated.
*/
to_be_invalidated = NULL;
(void) im__link_map( im,
(VSListMap2Fn) im_invalidate_image, NULL, NULL );
(VSListMap2Fn) im_invalidate_image, &to_be_invalidated, NULL );
im_invalidate_trigger( to_be_invalidated );
g_slist_free( to_be_invalidated );
}
/* Init the buffer cache system.

View File

@ -276,9 +276,10 @@ im_close( IMAGE *im )
* be closed when the last region is freed
* (see im_region_free()).
*/
#ifdef DEBUG_IO
printf( "im_close: pending close for \"%s\"\n", im->filename );
#endif /*DEBUG_IO*/
#ifdef DEBUG_NEW
printf( "im_close: pending close for 0x%p, \"%s\"\n",
im, im->filename );
#endif /*DEBUG_NEW*/
im->close_pending = 1;
}

View File

@ -125,7 +125,7 @@ Modified:
*/
/*
#define DEBUG_IO
#define DEBUG
*/
#ifdef HAVE_CONFIG_H
@ -501,9 +501,9 @@ im_open( const char *filename, const char *mode )
(im_callback_fn) evalend_cb, progress, NULL );
}
#ifdef DEBUG_IO
#ifdef DEBUG
printf( "im_open: success for %s (%p)\n", im->filename, im );
#endif /*DEBUG_IO*/
#endif /*DEBUG*/
return( im );
}

View File

@ -1079,11 +1079,13 @@ im_render_priority( IMAGE *in, IMAGE *out, IMAGE *mask,
if( render_thread_create() )
return( -1 );
if( width <= 0 || height <= 0 || max < -1 ) {
if( width <= 0 ||
height <= 0 ||
max < -1 ) {
im_error( "im_render", "%s", _( "bad parameters" ) );
return( -1 );
}
if( im_pincheck( in ) || im_poutcheck( out ) )
if( im_piocheck( in, out ) )
return( -1 );
if( mask ) {
if( im_poutcheck( mask ) ||