From 16830d69375f41b14b7b2eb790ac4f025d9ad318 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 28 Jan 2014 13:08:02 +0000 Subject: [PATCH] vips_sink_screen() now invalidates for you clients no longer need to call vips_image_invalidate_all() --- TODO | 10 ---------- libvips/include/vips/region.h | 2 ++ libvips/iofuncs/image.c | 8 +++++--- libvips/iofuncs/region.c | 19 +++++++++++++++++++ libvips/iofuncs/sinkscreen.c | 5 +++++ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index b0d478f2..2b7fb047 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,3 @@ -- try: - - $ vips falsecolour k2.jpg x.jpg - vips warning: VipsJpeg: read gave 896 warnings - vips warning: VipsJpeg: Application transferred too many scanlines - - seems to read twice? - - problem in 7.38 too - - vips_colourspace() needs an option from_space param,? - check_uncoded() left to do: diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index a38bda33..ecc127d5 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -120,6 +120,8 @@ int vips_region_prepare_to( VipsRegion *reg, VipsRegion *dest, VipsRect *r, int x, int y ); int vips_region_prepare_many( VipsRegion **reg, VipsRect *r ); +void vips_region_invalidate( VipsRegion *reg ); + void vips_region_dump_all( void ); /* Macros on VipsRegion. diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 5f765904..e97bcdef 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -953,9 +953,9 @@ vips_image_build( VipsObject *object ) } static void * -vips_region_invalidate( VipsRegion *reg ) +vips_image_real_invalidate_cb( VipsRegion *reg ) { - reg->invalid = TRUE; + vips_region_invalidate( reg ); return( NULL ); } @@ -972,7 +972,7 @@ vips_image_real_invalidate( VipsImage *image ) VIPS_GATE_STOP( "vips_image_real_invalidate: wait" ); (void) vips_slist_map2( image->regions, - (VipsSListMap2Fn) vips_region_invalidate, NULL, NULL ); + (VipsSListMap2Fn) vips_image_real_invalidate_cb, NULL, NULL ); g_mutex_unlock( image->sslock ); } @@ -1274,6 +1274,8 @@ vips_image_invalidate_all_cb( VipsImage *image ) * is, images which depend on this image. * * The "invalidate" callback is triggered for all invalidated images. + * + * See also: vips_region_invalidate(). */ void vips_image_invalidate_all( VipsImage *image ) diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index 1cf20a24..42152971 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -1375,6 +1375,25 @@ vips_region_prepare_many( VipsRegion **reg, VipsRect *r ) return( 0 ); } +/** + * vips_region_invalidate: + * @reg: region to invalidate + * + * Mark a region as containing invalid pixels. Calling this function means + * that the next time vips_region_prepare() is called, the region will be + * recalculated. + * + * This is faster than calling vips_image_invalidate_all(), but obviously only + * affects a single region. + * + * See also: vips_image_invalidate_all(), vips_region_prepare(). + */ +void +vips_region_invalidate( VipsRegion *reg ) +{ + reg->invalid = TRUE; +} + #ifdef VIPS_DEBUG static void * vips_region_dump_all_cb( VipsRegion *region, size_t *alive ) diff --git a/libvips/iofuncs/sinkscreen.c b/libvips/iofuncs/sinkscreen.c index ca9523c6..7ecbdc65 100644 --- a/libvips/iofuncs/sinkscreen.c +++ b/libvips/iofuncs/sinkscreen.c @@ -424,6 +424,11 @@ render_work( VipsThreadState *state, void *a ) } tile->painted = TRUE; + /* All downstream images must drop caches, since we've (effectively) + * modified render->out. + */ + vips_image_invalidate_all( render->out ); + /* Now clients can update. */ if( render->notify )