2009-08-16 17:00:08 +02:00
|
|
|
/* Declarations which are public-facing, but private. See internal.h for
|
|
|
|
* declarations which are only used internally by vips and which are not
|
|
|
|
* externally visible.
|
|
|
|
*
|
|
|
|
* 6/7/09
|
|
|
|
* - from vips.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file is part of VIPS.
|
|
|
|
|
|
|
|
VIPS is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2013-03-07 06:40:19 +01:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
02110-1301 USA
|
2009-08-16 17:00:08 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-03-28 18:18:06 +02:00
|
|
|
#ifndef VIPS_PRIVATE_H
|
|
|
|
#define VIPS_PRIVATE_H
|
2009-08-16 17:00:08 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /*__cplusplus*/
|
|
|
|
|
2011-03-28 18:18:06 +02:00
|
|
|
#define VIPS_SPARE (8)
|
2009-08-16 17:00:08 +02:00
|
|
|
|
2009-12-10 13:34:50 +01:00
|
|
|
/* Private to iofuncs: the minimum number of scanlines we add above and below
|
|
|
|
* the window as a margin for slop.
|
2009-08-16 17:00:08 +02:00
|
|
|
*/
|
2011-03-28 18:18:06 +02:00
|
|
|
#define VIPS__WINDOW_MARGIN_PIXELS (128)
|
2009-12-10 13:34:50 +01:00
|
|
|
|
|
|
|
/* Private to iofuncs: add at least this many bytes above and below the window.
|
|
|
|
* There's no point mapping just a few KB of a small image.
|
|
|
|
*/
|
2011-03-28 18:18:06 +02:00
|
|
|
#define VIPS__WINDOW_MARGIN_BYTES (1024 * 1024 * 10)
|
2009-08-16 17:00:08 +02:00
|
|
|
|
|
|
|
/* sizeof() a VIPS header on disc.
|
|
|
|
*/
|
2011-03-28 18:18:06 +02:00
|
|
|
#define VIPS_SIZEOF_HEADER (64)
|
2009-08-16 17:00:08 +02:00
|
|
|
|
|
|
|
/* What we track for each mmap window. Have a list of these on an openin
|
2011-03-10 10:41:45 +01:00
|
|
|
* VipsImage.
|
2009-08-16 17:00:08 +02:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
int ref_count; /* # of regions referencing us */
|
2011-03-10 10:41:45 +01:00
|
|
|
struct _VipsImage *im; /* VipsImage we are attached to */
|
2009-08-16 17:00:08 +02:00
|
|
|
|
|
|
|
int top; /* Area of image we have mapped, in pixels */
|
|
|
|
int height;
|
2011-12-31 19:22:42 +01:00
|
|
|
VipsPel *data; /* First pixel of line 'top' */
|
2009-08-16 17:00:08 +02:00
|
|
|
|
2011-12-09 15:30:45 +01:00
|
|
|
void *baseaddr; /* Base of window */
|
2009-08-16 17:00:08 +02:00
|
|
|
size_t length; /* Size of window */
|
2011-03-25 15:01:12 +01:00
|
|
|
} VipsWindow;
|
2009-08-16 17:00:08 +02:00
|
|
|
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
int vips_window_unref( VipsWindow *window );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
void vips_window_print( VipsWindow *window );
|
2009-10-06 18:19:13 +02:00
|
|
|
|
2013-12-18 10:54:26 +01:00
|
|
|
/* Per-thread buffer state. Held in a GPrivate.
|
2009-10-06 18:19:13 +02:00
|
|
|
*/
|
2011-03-25 15:01:12 +01:00
|
|
|
typedef struct {
|
2013-12-18 10:54:26 +01:00
|
|
|
GHashTable *hash; /* VipsImage -> VipsBufferCache* */
|
2009-10-06 18:19:13 +02:00
|
|
|
GThread *thread; /* Just for sanity checking */
|
2013-12-18 10:54:26 +01:00
|
|
|
} VipsBufferThread;
|
2009-10-06 18:19:13 +02:00
|
|
|
|
2016-10-13 15:57:18 +02:00
|
|
|
/* Per-image buffer cache. This keeps a list of "done" VipsBuffer that this
|
|
|
|
* worker has generated. We use this to reuse results within a thread.
|
|
|
|
*
|
|
|
|
* Hash to this from VipsBufferThread::hash.
|
2014-01-29 10:07:58 +01:00
|
|
|
* We can't store the GSList directly in the hash table as GHashTable lacks an
|
2009-10-06 18:19:13 +02:00
|
|
|
* update operation and we'd need to _remove() and _insert() on every list
|
|
|
|
* operation.
|
|
|
|
*/
|
2013-12-18 10:54:26 +01:00
|
|
|
typedef struct _VipsBufferCache {
|
2016-10-13 15:57:18 +02:00
|
|
|
GSList *buffers; /* GSList of "done" VipsBuffer* */
|
2009-10-06 18:19:13 +02:00
|
|
|
GThread *thread; /* Just for sanity checking */
|
|
|
|
struct _VipsImage *im;
|
2013-12-18 10:54:26 +01:00
|
|
|
VipsBufferThread *buffer_thread;
|
|
|
|
GSList *reserve; /* VipsBuffer kept in reserve */
|
|
|
|
int n_reserve; /* Number in reserve */
|
|
|
|
} VipsBufferCache;
|
2009-10-06 18:19:13 +02:00
|
|
|
|
2013-12-18 10:54:26 +01:00
|
|
|
/* What we track for each pixel buffer. These can move between caches and
|
|
|
|
* between threads, but not between images.
|
2016-10-13 15:57:18 +02:00
|
|
|
*
|
|
|
|
* Moving between threads is difficult, use region ownership stuff.
|
2009-10-06 18:19:13 +02:00
|
|
|
*/
|
2011-06-22 13:17:43 +02:00
|
|
|
typedef struct _VipsBuffer {
|
2009-10-06 18:19:13 +02:00
|
|
|
int ref_count; /* # of regions referencing us */
|
2011-03-10 10:41:45 +01:00
|
|
|
struct _VipsImage *im; /* VipsImage we are attached to */
|
2009-10-06 18:19:13 +02:00
|
|
|
|
2011-03-17 14:05:46 +01:00
|
|
|
VipsRect area; /* Area this pixel buffer covers */
|
2016-10-13 15:57:18 +02:00
|
|
|
gboolean done; /* Calculated and in a cache */
|
2013-12-18 10:54:26 +01:00
|
|
|
VipsBufferCache *cache; /* The cache this buffer is published on */
|
2011-12-31 19:22:42 +01:00
|
|
|
VipsPel *buf; /* Private malloc() area */
|
2009-10-06 18:19:13 +02:00
|
|
|
size_t bsize; /* Size of private malloc() */
|
2011-03-25 15:01:12 +01:00
|
|
|
} VipsBuffer;
|
|
|
|
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2013-12-17 16:21:21 +01:00
|
|
|
void vips_buffer_dump_all( void );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
void vips_buffer_done( VipsBuffer *buffer );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
void vips_buffer_undone( VipsBuffer *buffer );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
void vips_buffer_unref( VipsBuffer *buffer );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
VipsBuffer *vips_buffer_new( struct _VipsImage *im, VipsRect *area );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
VipsBuffer *vips_buffer_ref( struct _VipsImage *im, VipsRect *area );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
VipsBuffer *vips_buffer_unref_ref( VipsBuffer *buffer,
|
2011-03-17 14:05:46 +01:00
|
|
|
struct _VipsImage *im, VipsRect *area );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-25 15:01:12 +01:00
|
|
|
void vips_buffer_print( VipsBuffer *buffer );
|
2009-10-06 18:19:13 +02:00
|
|
|
|
2014-01-29 10:07:58 +01:00
|
|
|
void vips__render_shutdown( void );
|
|
|
|
|
2009-10-07 15:03:46 +02:00
|
|
|
/* Sections of region.h that are private to VIPS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Region types.
|
|
|
|
*/
|
2011-06-22 13:17:43 +02:00
|
|
|
typedef enum _RegionType {
|
2011-03-02 22:53:32 +01:00
|
|
|
VIPS_REGION_NONE,
|
2011-11-05 15:20:36 +01:00
|
|
|
VIPS_REGION_BUFFER, /* A VipsBuffer */
|
|
|
|
VIPS_REGION_OTHER_REGION, /* Memory on another region */
|
|
|
|
VIPS_REGION_OTHER_IMAGE, /* Memory on another image */
|
|
|
|
VIPS_REGION_WINDOW /* A VipsWindow on fd */
|
2009-10-07 15:03:46 +02:00
|
|
|
} RegionType;
|
|
|
|
|
2011-03-28 18:18:06 +02:00
|
|
|
/* Private to iofuncs: the size of the `tiles' requested by
|
2011-11-05 15:20:36 +01:00
|
|
|
* vips_image_generate() when acting as a data sink.
|
2009-10-07 15:03:46 +02:00
|
|
|
*/
|
2011-11-05 15:20:36 +01:00
|
|
|
#define VIPS__TILE_WIDTH (128)
|
|
|
|
#define VIPS__TILE_HEIGHT (128)
|
2009-10-07 15:03:46 +02:00
|
|
|
|
|
|
|
/* The height of the strips for the other two request styles.
|
|
|
|
*/
|
2011-03-28 18:18:06 +02:00
|
|
|
#define VIPS__THINSTRIP_HEIGHT (1)
|
|
|
|
#define VIPS__FATSTRIP_HEIGHT (16)
|
2009-10-07 15:03:46 +02:00
|
|
|
|
|
|
|
/* Functions on regions.
|
|
|
|
*/
|
2011-03-02 22:53:32 +01:00
|
|
|
struct _VipsRegion;
|
2011-03-03 15:49:12 +01:00
|
|
|
void vips__region_take_ownership( struct _VipsRegion *reg );
|
|
|
|
void vips__region_check_ownership( struct _VipsRegion *reg );
|
2022-04-16 11:58:55 +02:00
|
|
|
/* TODO(kleisauke): VIPS_API is required by vipsdisp.
|
|
|
|
*/
|
|
|
|
VIPS_API
|
2011-03-03 15:49:12 +01:00
|
|
|
void vips__region_no_ownership( struct _VipsRegion *reg );
|
2009-10-07 15:03:46 +02:00
|
|
|
|
2011-03-03 15:49:12 +01:00
|
|
|
typedef int (*VipsRegionFillFn)( struct _VipsRegion *, void * );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2011-03-03 15:49:12 +01:00
|
|
|
int vips_region_fill( struct _VipsRegion *reg,
|
2017-11-17 17:30:25 +01:00
|
|
|
const VipsRect *r, VipsRegionFillFn fn, void *a );
|
2009-10-07 15:03:46 +02:00
|
|
|
|
2011-12-21 20:00:32 +01:00
|
|
|
int vips__image_wio_output( struct _VipsImage *image );
|
|
|
|
int vips__image_pio_output( struct _VipsImage *image );
|
2011-03-23 23:19:49 +01:00
|
|
|
|
2022-04-16 11:58:55 +02:00
|
|
|
/* VIPS_ARGUMENT_FOR_ALL() needs to have this visible.
|
|
|
|
*/
|
|
|
|
VIPS_API
|
2011-06-22 13:17:43 +02:00
|
|
|
VipsArgumentInstance *vips__argument_get_instance(
|
|
|
|
VipsArgumentClass *argument_class,
|
|
|
|
VipsObject *object);
|
|
|
|
VipsArgument *vips__argument_table_lookup( VipsArgumentTable *table,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2022-04-16 11:58:55 +02:00
|
|
|
/* im_demand_hint_array() needs to have this visible.
|
|
|
|
*/
|
|
|
|
#if VIPS_ENABLE_DEPRECATED
|
|
|
|
VIPS_API
|
|
|
|
#endif
|
2013-10-22 10:29:40 +02:00
|
|
|
void vips__demand_hint_array( struct _VipsImage *image,
|
|
|
|
int hint, struct _VipsImage **in );
|
2022-04-16 11:58:55 +02:00
|
|
|
/* im_cp_desc_array() needs to have this visible.
|
|
|
|
*/
|
|
|
|
#if VIPS_ENABLE_DEPRECATED
|
|
|
|
VIPS_API
|
|
|
|
#endif
|
2013-10-22 10:29:40 +02:00
|
|
|
int vips__image_copy_fields_array( struct _VipsImage *out,
|
|
|
|
struct _VipsImage *in[] );
|
|
|
|
|
2017-04-06 11:19:35 +02:00
|
|
|
void vips__region_count_pixels( struct _VipsRegion *region, const char *nickname );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-04-06 11:19:35 +02:00
|
|
|
void vips_region_dump_all( void );
|
|
|
|
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-11-17 17:30:25 +01:00
|
|
|
int vips_region_prepare_many( struct _VipsRegion **reg, const VipsRect *r );
|
2016-12-31 18:58:33 +01:00
|
|
|
|
2017-06-08 19:35:55 +02:00
|
|
|
/* Handy for debugging.
|
|
|
|
*/
|
|
|
|
int vips__view_image( struct _VipsImage *image );
|
|
|
|
|
2018-05-29 17:49:20 +02:00
|
|
|
/* Pre 8.7 libvipses used this for allocating argument ids.
|
|
|
|
*/
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
|
|
|
int _vips__argument_id;
|
2018-05-29 17:49:20 +02:00
|
|
|
|
2020-01-31 16:25:05 +01:00
|
|
|
void vips__meta_init( void );
|
|
|
|
|
2009-08-16 17:00:08 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /*__cplusplus*/
|
|
|
|
|
2011-03-28 18:18:06 +02:00
|
|
|
#endif /*VIPS_PRIVATE_H*/
|