pdfload / pdfiumload use minimise to close early
see https://github.com/libvips/libvips/issues/1370#issuecomment-514949292
This commit is contained in:
parent
9373d63d6e
commit
53e0bc6698
@ -380,6 +380,15 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_foreign_load_pdf_minimise( VipsObject *object, VipsForeignLoadPdf *pdf )
|
||||
{
|
||||
/* In seq mode, we can shut down the input at the end of computation.
|
||||
*/
|
||||
if( VIPS_FOREIGN_LOAD( pdf )->access == VIPS_ACCESS_SEQUENTIAL )
|
||||
vips_foreign_load_pdf_close( pdf );
|
||||
}
|
||||
|
||||
static int
|
||||
vips_foreign_load_pdf_generate( VipsRegion *or,
|
||||
void *seq, void *a, void *b, gboolean *stop )
|
||||
@ -436,13 +445,6 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
|
||||
i += 1;
|
||||
}
|
||||
|
||||
/* In seq mode, we can shut down the input when we render the last
|
||||
* row.
|
||||
*/
|
||||
if( top >= or->im->Ysize &&
|
||||
load->access == VIPS_ACCESS_SEQUENTIAL )
|
||||
vips_foreign_load_pdf_close( pdf );
|
||||
|
||||
/* PDFium writes BRGA, we must swap.
|
||||
*
|
||||
* FIXME ... this is a bit slow.
|
||||
@ -476,6 +478,11 @@ vips_foreign_load_pdf_load( VipsForeignLoad *load )
|
||||
*/
|
||||
t[0] = vips_image_new();
|
||||
|
||||
/* Close input immediately at end of read.
|
||||
*/
|
||||
g_signal_connect( t[0], "minimise",
|
||||
G_CALLBACK( vips_foreign_load_pdf_minimise ), pdf );
|
||||
|
||||
vips_foreign_load_pdf_set_image( pdf, t[0] );
|
||||
if( vips_image_generate( t[0],
|
||||
NULL, vips_foreign_load_pdf_generate, NULL, pdf, NULL ) )
|
||||
|
@ -334,12 +334,20 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_foreign_load_pdf_minimise( VipsObject *object, VipsForeignLoadPdf *pdf )
|
||||
{
|
||||
/* In seq mode, we can shut down the input at the end of computation.
|
||||
*/
|
||||
if( VIPS_FOREIGN_LOAD( pdf )->access == VIPS_ACCESS_SEQUENTIAL )
|
||||
vips_foreign_load_pdf_close( pdf );
|
||||
}
|
||||
|
||||
static int
|
||||
vips_foreign_load_pdf_generate( VipsRegion *or,
|
||||
void *seq, void *a, void *b, gboolean *stop )
|
||||
{
|
||||
VipsForeignLoadPdf *pdf = (VipsForeignLoadPdf *) a;
|
||||
VipsForeignLoad *load = (VipsForeignLoad *) pdf;
|
||||
VipsRect *r = &or->valid;
|
||||
|
||||
int top;
|
||||
@ -398,13 +406,6 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
|
||||
i += 1;
|
||||
}
|
||||
|
||||
/* In seq mode, we can shut down the input when we render the last
|
||||
* row.
|
||||
*/
|
||||
if( top >= or->im->Ysize &&
|
||||
load->access == VIPS_ACCESS_SEQUENTIAL )
|
||||
vips_foreign_load_pdf_close( pdf );
|
||||
|
||||
/* Cairo makes pre-multipled BRGA, we must byteswap and unpremultiply.
|
||||
*/
|
||||
for( y = 0; y < r->height; y++ )
|
||||
@ -430,6 +431,11 @@ vips_foreign_load_pdf_load( VipsForeignLoad *load )
|
||||
*/
|
||||
t[0] = vips_image_new();
|
||||
|
||||
/* Close input immediately at end of read.
|
||||
*/
|
||||
g_signal_connect( t[0], "minimise",
|
||||
G_CALLBACK( vips_foreign_load_pdf_minimise ), pdf );
|
||||
|
||||
vips_foreign_load_pdf_set_image( pdf, t[0] );
|
||||
if( vips_image_generate( t[0],
|
||||
NULL, vips_foreign_load_pdf_generate, NULL, pdf, NULL ) )
|
||||
|
Loading…
Reference in New Issue
Block a user