private.h 6.1 KB

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