1 /* Declarations which are public-facing, but private. See internal.h for 2 * declarations which are only used internally by vips and which are not 3 * externally visible. 4 * 5 * 6/7/09 6 * - from vips.h 7 */ 8 9 /* 10 11 This file is part of VIPS. 12 13 VIPS is free software; you can redistribute it and/or modify 14 it under the terms of the GNU Lesser General Public License as published by 15 the Free Software Foundation; either version 2 of the License, or 16 (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU Lesser General Public License for more details. 22 23 You should have received a copy of the GNU Lesser General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 26 02110-1301 USA 27 28 */ 29 30 /* 31 32 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk 33 34 */ 35 36 #ifndef VIPS_PRIVATE_H 37 #define VIPS_PRIVATE_H 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif /*__cplusplus*/ 42 43 #define VIPS_SPARE (8) 44 45 /* Private to iofuncs: the minimum number of scanlines we add above and below 46 * the window as a margin for slop. 47 */ 48 #define VIPS__WINDOW_MARGIN_PIXELS (128) 49 50 /* Private to iofuncs: add at least this many bytes above and below the window. 51 * There's no point mapping just a few KB of a small image. 52 */ 53 #define VIPS__WINDOW_MARGIN_BYTES (1024 * 1024 * 10) 54 55 /* sizeof() a VIPS header on disc. 56 */ 57 #define VIPS_SIZEOF_HEADER (64) 58 59 /* What we track for each mmap window. Have a list of these on an openin 60 * VipsImage. 61 */ 62 typedef struct { 63 int ref_count; /* # of regions referencing us */ 64 struct _VipsImage *im; /* VipsImage we are attached to */ 65 66 int top; /* Area of image we have mapped, in pixels */ 67 int height; 68 VipsPel *data; /* First pixel of line 'top' */ 69 70 void *baseaddr; /* Base of window */ 71 size_t length; /* Size of window */ 72 } VipsWindow; 73 74 int vips_window_unref( VipsWindow *window ); 75 void vips_window_print( VipsWindow *window ); 76 77 /* Per-thread buffer state. Held in a GPrivate. 78 */ 79 typedef struct { 80 GHashTable *hash; /* VipsImage -> VipsBufferCache* */ 81 GThread *thread; /* Just for sanity checking */ 82 } VipsBufferThread; 83 84 /* Per-image buffer cache. This keeps a list of "done" VipsBuffer that this 85 * worker has generated. We use this to reuse results within a thread. 86 * 87 * Hash to this from VipsBufferThread::hash. 88 * We can't store the GSList directly in the hash table as GHashTable lacks an 89 * update operation and we'd need to _remove() and _insert() on every list 90 * operation. 91 */ 92 typedef struct _VipsBufferCache { 93 GSList *buffers; /* GSList of "done" VipsBuffer* */ 94 GThread *thread; /* Just for sanity checking */ 95 struct _VipsImage *im; 96 VipsBufferThread *buffer_thread; 97 GSList *reserve; /* VipsBuffer kept in reserve */ 98 int n_reserve; /* Number in reserve */ 99 } VipsBufferCache; 100 101 /* What we track for each pixel buffer. These can move between caches and 102 * between threads, but not between images. 103 * 104 * Moving between threads is difficult, use region ownership stuff. 105 */ 106 typedef struct _VipsBuffer { 107 int ref_count; /* # of regions referencing us */ 108 struct _VipsImage *im; /* VipsImage we are attached to */ 109 110 VipsRect area; /* Area this pixel buffer covers */ 111 gboolean done; /* Calculated and in a cache */ 112 VipsBufferCache *cache; /* The cache this buffer is published on */ 113 VipsPel *buf; /* Private malloc() area */ 114 size_t bsize; /* Size of private malloc() */ 115 } VipsBuffer; 116 117 void vips_buffer_dump_all( void ); 118 void vips_buffer_done( VipsBuffer *buffer ); 119 void vips_buffer_undone( VipsBuffer *buffer ); 120 void vips_buffer_unref( VipsBuffer *buffer ); 121 VipsBuffer *vips_buffer_new( struct _VipsImage *im, VipsRect *area ); 122 VipsBuffer *vips_buffer_ref( struct _VipsImage *im, VipsRect *area ); 123 VipsBuffer *vips_buffer_unref_ref( VipsBuffer *buffer, 124 struct _VipsImage *im, VipsRect *area ); 125 void vips_buffer_print( VipsBuffer *buffer ); 126 127 void vips__render_shutdown( void ); 128 129 /* Sections of region.h that are private to VIPS. 130 */ 131 132 /* Region types. 133 */ 134 typedef enum _RegionType { 135 VIPS_REGION_NONE, 136 VIPS_REGION_BUFFER, /* A VipsBuffer */ 137 VIPS_REGION_OTHER_REGION, /* Memory on another region */ 138 VIPS_REGION_OTHER_IMAGE, /* Memory on another image */ 139 VIPS_REGION_WINDOW /* A VipsWindow on fd */ 140 } RegionType; 141 142 /* Private to iofuncs: the size of the `tiles' requested by 143 * vips_image_generate() when acting as a data sink. 144 */ 145 #define VIPS__TILE_WIDTH (128) 146 #define VIPS__TILE_HEIGHT (128) 147 148 /* The height of the strips for the other two request styles. 149 */ 150 #define VIPS__THINSTRIP_HEIGHT (1) 151 #define VIPS__FATSTRIP_HEIGHT (16) 152 153 /* Functions on regions. 154 */ 155 struct _VipsRegion; 156 void vips__region_take_ownership( struct _VipsRegion *reg ); 157 void vips__region_check_ownership( struct _VipsRegion *reg ); 158 void vips__region_no_ownership( struct _VipsRegion *reg ); 159 160 typedef int (*VipsRegionFillFn)( struct _VipsRegion *, void * ); 161 int vips_region_fill( struct _VipsRegion *reg, 162 const VipsRect *r, VipsRegionFillFn fn, void *a ); 163 164 int vips__image_wio_output( struct _VipsImage *image ); 165 int vips__image_pio_output( struct _VipsImage *image ); 166 167 VipsArgumentInstance *vips__argument_get_instance( 168 VipsArgumentClass *argument_class, 169 VipsObject *object); 170 VipsArgument *vips__argument_table_lookup( VipsArgumentTable *table, 171 GParamSpec *pspec); 172 173 void vips__demand_hint_array( struct _VipsImage *image, 174 int hint, struct _VipsImage **in ); 175 int vips__image_copy_fields_array( struct _VipsImage *out, 176 struct _VipsImage *in[] ); 177 178 void vips__region_count_pixels( struct _VipsRegion *region, const char *nickname ); 179 void vips_region_dump_all( void ); 180 181 /* Deprecated. 182 */ 183 int vips__init( const char *argv0 ); 184 size_t vips__get_sizeof_vipsobject( void ); 185 int vips_region_prepare_many( struct _VipsRegion **reg, const VipsRect *r ); 186 187 /* Handy for debugging. 188 */ 189 int vips__view_image( struct _VipsImage *image ); 190 191 /* Pre 8.7 libvipses used this for allocating argument ids. 192 */ 193 extern int _vips__argument_id; 194 195 void vips__meta_init( void ); 196 197 #ifdef __cplusplus 198 } 199 #endif /*__cplusplus*/ 200 201 #endif /*VIPS_PRIVATE_H*/ 202