blob: f377dc68277ddec7b588a7790be57965fff0a8ad [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristyb56bb242014-11-25 17:12:48 +00002 Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization
cristy3ed852e2009-09-05 21:47:34 +00003 dedicated to making software imaging solutions freely available.
cristy222b19c2011-08-04 01:35:11 +00004
cristy3ed852e2009-09-05 21:47:34 +00005 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
cristy222b19c2011-08-04 01:35:11 +00007
cristy3ed852e2009-09-05 21:47:34 +00008 http://www.imagemagick.org/script/license.php
cristy222b19c2011-08-04 01:35:11 +00009
cristy3ed852e2009-09-05 21:47:34 +000010 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 MagickCore cache private methods.
17*/
18#ifndef _MAGICKCORE_CACHE_PRIVATE_H
19#define _MAGICKCORE_CACHE_PRIVATE_H
20
cristy4ee2b0c2012-05-15 00:30:35 +000021#include "MagickCore/cache.h"
cristye80f9cb2013-01-09 01:09:31 +000022#include "MagickCore/distribute-cache.h"
cristy8a46d822012-08-28 23:32:39 +000023#include "MagickCore/pixel.h"
cristy4c08aed2011-07-01 19:47:50 +000024#include "MagickCore/random_.h"
25#include "MagickCore/thread-private.h"
26#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000027
cristy6398ec72013-11-28 02:00:27 +000028#if defined(__cplusplus) || defined(c_plusplus)
29extern "C" {
30#endif
31
cristycd01fae2011-08-06 23:52:42 +000032typedef void
33 *Cache;
34
cristy3ed852e2009-09-05 21:47:34 +000035typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000036 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000037 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000038 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000039 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000040 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
41
cristy4c08aed2011-07-01 19:47:50 +000042typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000043 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
44 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000045 *(*GetVirtualPixelsHandler)(const Image *);
46
cristy4c08aed2011-07-01 19:47:50 +000047typedef const void
48 *(*GetVirtualMetacontentFromHandler)(const Image *);
49
50typedef Quantum
cristybb503372010-05-27 20:51:26 +000051 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
52 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000053
cristy4c08aed2011-07-01 19:47:50 +000054typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000055 *(*GetAuthenticPixelsFromHandler)(const Image *);
56
cristy4c08aed2011-07-01 19:47:50 +000057typedef Quantum
cristybb503372010-05-27 20:51:26 +000058 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
59 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000060
61typedef void
62 (*DestroyPixelHandler)(Image *);
63
cristy4c08aed2011-07-01 19:47:50 +000064typedef void
65 *(*GetAuthenticMetacontentFromHandler)(const Image *);
66
cristy3ed852e2009-09-05 21:47:34 +000067typedef struct _CacheMethods
68{
69 GetVirtualPixelHandler
70 get_virtual_pixel_handler;
71
72 GetVirtualPixelsHandler
73 get_virtual_pixels_handler;
74
cristy4c08aed2011-07-01 19:47:50 +000075 GetVirtualMetacontentFromHandler
76 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000077
78 GetOneVirtualPixelFromHandler
79 get_one_virtual_pixel_from_handler;
80
81 GetAuthenticPixelsHandler
82 get_authentic_pixels_handler;
83
cristy4c08aed2011-07-01 19:47:50 +000084 GetAuthenticMetacontentFromHandler
85 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000086
87 GetOneAuthenticPixelFromHandler
88 get_one_authentic_pixel_from_handler;
89
90 GetAuthenticPixelsFromHandler
91 get_authentic_pixels_from_handler;
92
93 QueueAuthenticPixelsHandler
94 queue_authentic_pixels_handler;
95
96 SyncAuthenticPixelsHandler
97 sync_authentic_pixels_handler;
98
99 DestroyPixelHandler
100 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000101} CacheMethods;
102
103typedef struct _NexusInfo
cristyffaf87e2013-04-30 17:09:30 +0000104{
105 MagickBooleanType
106 mapped;
107
108 RectangleInfo
109 region;
110
111 MagickSizeType
112 length;
113
114 Quantum
115 *cache,
116 *pixels;
117
cristyd7d71282013-04-30 17:24:26 +0000118 MagickBooleanType
cristy73f359e2013-04-30 22:22:32 +0000119 authentic_pixel_cache;
cristyd7d71282013-04-30 17:24:26 +0000120
cristyffaf87e2013-04-30 17:09:30 +0000121 void
122 *metacontent;
123
124 size_t
125 signature;
126} NexusInfo;
cristy3ed852e2009-09-05 21:47:34 +0000127
128typedef struct _CacheInfo
129{
130 ClassType
131 storage_class;
132
133 ColorspaceType
134 colorspace;
135
cristy8a46d822012-08-28 23:32:39 +0000136 PixelTrait
137 alpha_trait;
138
cristy222b19c2011-08-04 01:35:11 +0000139 MagickBooleanType
cristy883fde12013-04-08 00:50:13 +0000140 read_mask,
141 write_mask;
cristy222b19c2011-08-04 01:35:11 +0000142
143 size_t
144 columns,
145 rows;
146
cristybcc1fdc2011-04-29 13:06:35 +0000147 size_t
cristy4c08aed2011-07-01 19:47:50 +0000148 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000149 number_channels;
cristy0d267172011-04-25 20:13:48 +0000150
cristy3dfccb22011-12-28 21:47:20 +0000151 PixelChannelMap
152 channel_map[MaxPixelChannels];
153
cristy3ed852e2009-09-05 21:47:34 +0000154 CacheType
155 type;
156
cristy87528ea2009-09-10 14:53:56 +0000157 MapMode
158 mode;
159
cristy3ed852e2009-09-05 21:47:34 +0000160 MagickBooleanType
161 mapped;
162
cristy3ed852e2009-09-05 21:47:34 +0000163 MagickOffsetType
164 offset;
165
166 MagickSizeType
167 length;
168
169 VirtualPixelMethod
170 virtual_pixel_method;
171
cristy4c08aed2011-07-01 19:47:50 +0000172 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000173 virtual_pixel_color;
174
cristybb503372010-05-27 20:51:26 +0000175 size_t
cristy3ed852e2009-09-05 21:47:34 +0000176 number_threads;
177
178 NexusInfo
179 **nexus_info;
180
cristy4c08aed2011-07-01 19:47:50 +0000181 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000182 *pixels;
183
cristy4c08aed2011-07-01 19:47:50 +0000184 void
185 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000186
187 int
188 file;
189
190 char
cristy151b66d2015-04-15 10:50:31 +0000191 filename[MagickPathExtent],
192 cache_filename[MagickPathExtent];
cristy3ed852e2009-09-05 21:47:34 +0000193
194 CacheMethods
195 methods;
196
197 RandomInfo
198 *random_info;
199
cristybb31fcd2013-01-15 20:06:37 +0000200 void
cristy0c682412013-01-18 14:14:13 +0000201 *server_info;
cristy286dea02013-01-08 21:34:16 +0000202
cristy3ed852e2009-09-05 21:47:34 +0000203 MagickBooleanType
cristyfa0ea942012-12-21 02:42:29 +0000204 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000205 debug;
206
207 MagickThreadType
208 id;
209
cristybb503372010-05-27 20:51:26 +0000210 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000211 reference_count;
212
213 SemaphoreInfo
214 *semaphore,
cristy245d4c52012-11-15 21:13:56 +0000215 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000216
cristyff1889f2012-05-08 18:38:44 +0000217 time_t
218 timestamp;
219
cristybb503372010-05-27 20:51:26 +0000220 size_t
cristy3ed852e2009-09-05 21:47:34 +0000221 signature;
222} CacheInfo;
223
cristy9c7a8792011-09-02 19:54:50 +0000224extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000225 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000226 ClonePixelCache(const Cache),
227 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000228 ReferencePixelCache(Cache);
229
cristy9c7a8792011-09-02 19:54:50 +0000230extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000231 GetPixelCacheStorageClass(const Cache);
232
cristy9c7a8792011-09-02 19:54:50 +0000233extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000234 GetPixelCacheColorspace(const Cache);
235
cristy9c7a8792011-09-02 19:54:50 +0000236extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000237 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
238 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000239 ExceptionInfo *) magick_hot_spot,
dirk05d2ff72015-11-18 23:13:43 +0100240 *GetVirtualPixelsNexus(const Cache,NexusInfo *magick_restrict);
cristy3ed852e2009-09-05 21:47:34 +0000241
cristy9c7a8792011-09-02 19:54:50 +0000242extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000243 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
dirk05d2ff72015-11-18 23:13:43 +0100244 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *magick_restrict);
cristy3ed852e2009-09-05 21:47:34 +0000245
cristy9c7a8792011-09-02 19:54:50 +0000246extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000247 CacheComponentGenesis(void),
dirk05d2ff72015-11-18 23:13:43 +0100248 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *magick_restrict,
249 ExceptionInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000250 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000251
cristy9c7a8792011-09-02 19:54:50 +0000252extern MagickPrivate MagickSizeType
dirk05d2ff72015-11-18 23:13:43 +0100253 GetPixelCacheNexusExtent(const Cache,NexusInfo *magick_restrict);
cristy3ed852e2009-09-05 21:47:34 +0000254
cristy9c7a8792011-09-02 19:54:50 +0000255extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000256 **AcquirePixelCacheNexus(const size_t),
257 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000258
cristy9c7a8792011-09-02 19:54:50 +0000259extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000260 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000261 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristyc11dace2012-01-24 16:39:46 +0000262 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
263 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000264 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000265
cristy9c7a8792011-09-02 19:54:50 +0000266extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000267 GetPixelCacheChannels(const Cache);
268
cristyd1dd6e42011-09-04 01:46:08 +0000269extern MagickPrivate VirtualPixelMethod
270 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000271 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000272
cristy9c7a8792011-09-02 19:54:50 +0000273extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000274 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000275 ClonePixelCacheMethods(Cache,const Cache),
cristyd1dd6e42011-09-04 01:46:08 +0000276 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000277 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000278 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000279 SetPixelCacheMethods(Cache,CacheMethods *);
280
cristy3ed852e2009-09-05 21:47:34 +0000281#if defined(__cplusplus) || defined(c_plusplus)
282}
283#endif
284
285#endif