oops, put the flags test on a subclass

This commit is contained in:
John Cupitt 2016-02-18 19:12:00 +00:00
parent 6f94cb5ed4
commit 0a4991cbc0

View File

@ -4,6 +4,8 @@
* - wrap a class around the jpeg writer
* 29/11/11
* - split to make load, load from buffer and load from file
* 18/2/16
* - don't cache progressive jpgs, they take too much mem
*/
/*
@ -92,6 +94,25 @@ typedef VipsForeignLoadClass VipsForeignLoadJpegClass;
G_DEFINE_ABSTRACT_TYPE( VipsForeignLoadJpeg, vips_foreign_load_jpeg,
VIPS_TYPE_FOREIGN_LOAD );
static VipsOperationFlags
vips_foreign_load_jpeg_operation_get_flags( VipsOperation *operation )
{
VipsForeignLoad *load = VIPS_FOREIGN_LOAD( operation );
VipsOperationFlags flags;
int multiscan;
flags = VIPS_OPERATION_CLASS( vips_foreign_load_jpeg_parent_class )->
get_flags( operation );
if( load->out &&
!vips_image_get_int( load->out,
"jpeg-multiscan", &multiscan ) &&
multiscan )
flags |= VIPS_OPERATION_NOCACHE;
return( flags );
}
static VipsForeignFlags
vips_foreign_load_jpeg_get_flags( VipsForeignLoad *load )
{
@ -126,6 +147,7 @@ vips_foreign_load_jpeg_class_init( VipsForeignLoadJpegClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsOperationClass *operation_class = (VipsOperationClass *) class;
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
gobject_class->set_property = vips_object_set_property;
@ -135,6 +157,8 @@ vips_foreign_load_jpeg_class_init( VipsForeignLoadJpegClass *class )
object_class->description = _( "load jpeg" );
object_class->build = vips_foreign_load_jpeg_build;
operation_class->get_flags = vips_foreign_load_jpeg_operation_get_flags;
load_class->get_flags = vips_foreign_load_jpeg_get_flags;
VIPS_ARG_INT( class, "shrink", 10,
@ -179,25 +203,6 @@ typedef VipsForeignLoadJpegClass VipsForeignLoadJpegFileClass;
G_DEFINE_TYPE( VipsForeignLoadJpegFile, vips_foreign_load_jpeg_file,
vips_foreign_load_jpeg_get_type() );
static VipsOperationFlags
vips_foreign_load_jpeg_operation_get_flags( VipsOperation *operation )
{
VipsForeignLoad *load = VIPS_FOREIGN_LOAD( operation );
VipsOperationFlags flags;
int multiscan;
flags = VIPS_OPERATION_CLASS( vips_foreign_load_jpeg_parent_class )->
get_flags( operation );
if( load->out &&
!vips_image_get_int( load->out,
"jpeg-multiscan", &multiscan ) &&
multiscan )
flags |= VIPS_OPERATION_NOCACHE;
return( flags );
}
static VipsForeignFlags
vips_foreign_load_jpeg_file_get_flags_filename( const char *filename )
{
@ -248,7 +253,6 @@ vips_foreign_load_jpeg_file_class_init( VipsForeignLoadJpegFileClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsOperationClass *operation_class = (VipsOperationClass *) class;
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
@ -258,8 +262,6 @@ vips_foreign_load_jpeg_file_class_init( VipsForeignLoadJpegFileClass *class )
object_class->nickname = "jpegload";
object_class->description = _( "load jpeg from file" );
operation_class->get_flags = vips_foreign_load_jpeg_operation_get_flags;
foreign_class->suffs = jpeg_suffs;
/* We are fast at is_a(), so high priority.