blob: 3b80ee6f484e778dbcb0a5c15172b1e97df6c84e [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy45ef08f2012-12-07 13:13:34 +00002 Copyright 1999-2013 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
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
25#include <time.h>
cristy4ee2b0c2012-05-15 00:30:35 +000026#include "MagickCore/cache.h"
cristye80f9cb2013-01-09 01:09:31 +000027#include "MagickCore/distribute-cache.h"
cristy8a46d822012-08-28 23:32:39 +000028#include "MagickCore/pixel.h"
cristy4c08aed2011-07-01 19:47:50 +000029#include "MagickCore/random_.h"
30#include "MagickCore/thread-private.h"
31#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000032
cristycd01fae2011-08-06 23:52:42 +000033typedef void
34 *Cache;
35
cristy3ed852e2009-09-05 21:47:34 +000036typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000037 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000038 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000039 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000040 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000041 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
42
cristy4c08aed2011-07-01 19:47:50 +000043typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000044 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
45 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000046 *(*GetVirtualPixelsHandler)(const Image *);
47
cristy4c08aed2011-07-01 19:47:50 +000048typedef const void
49 *(*GetVirtualMetacontentFromHandler)(const Image *);
50
51typedef Quantum
cristybb503372010-05-27 20:51:26 +000052 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
53 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000054
cristy4c08aed2011-07-01 19:47:50 +000055typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000056 *(*GetAuthenticPixelsFromHandler)(const Image *);
57
cristy4c08aed2011-07-01 19:47:50 +000058typedef Quantum
cristybb503372010-05-27 20:51:26 +000059 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
60 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000061
62typedef void
63 (*DestroyPixelHandler)(Image *);
64
cristy4c08aed2011-07-01 19:47:50 +000065typedef void
66 *(*GetAuthenticMetacontentFromHandler)(const Image *);
67
cristy3ed852e2009-09-05 21:47:34 +000068typedef struct _CacheMethods
69{
70 GetVirtualPixelHandler
71 get_virtual_pixel_handler;
72
73 GetVirtualPixelsHandler
74 get_virtual_pixels_handler;
75
cristy4c08aed2011-07-01 19:47:50 +000076 GetVirtualMetacontentFromHandler
77 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000078
79 GetOneVirtualPixelFromHandler
80 get_one_virtual_pixel_from_handler;
81
82 GetAuthenticPixelsHandler
83 get_authentic_pixels_handler;
84
cristy4c08aed2011-07-01 19:47:50 +000085 GetAuthenticMetacontentFromHandler
86 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000087
88 GetOneAuthenticPixelFromHandler
89 get_one_authentic_pixel_from_handler;
90
91 GetAuthenticPixelsFromHandler
92 get_authentic_pixels_from_handler;
93
94 QueueAuthenticPixelsHandler
95 queue_authentic_pixels_handler;
96
97 SyncAuthenticPixelsHandler
98 sync_authentic_pixels_handler;
99
100 DestroyPixelHandler
101 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000102} CacheMethods;
103
104typedef struct _NexusInfo
cristyffaf87e2013-04-30 17:09:30 +0000105{
106 MagickBooleanType
107 mapped;
108
109 RectangleInfo
110 region;
111
112 MagickSizeType
113 length;
114
115 Quantum
116 *cache,
117 *pixels;
118
cristyd7d71282013-04-30 17:24:26 +0000119 MagickBooleanType
120 is_authentic_pixels;
121
cristyffaf87e2013-04-30 17:09:30 +0000122 void
123 *metacontent;
124
125 size_t
126 signature;
127} NexusInfo;
cristy3ed852e2009-09-05 21:47:34 +0000128
129typedef struct _CacheInfo
130{
131 ClassType
132 storage_class;
133
134 ColorspaceType
135 colorspace;
136
cristy8a46d822012-08-28 23:32:39 +0000137 PixelTrait
138 alpha_trait;
139
cristy222b19c2011-08-04 01:35:11 +0000140 MagickBooleanType
cristy883fde12013-04-08 00:50:13 +0000141 read_mask,
142 write_mask;
cristy222b19c2011-08-04 01:35:11 +0000143
144 size_t
145 columns,
146 rows;
147
cristybcc1fdc2011-04-29 13:06:35 +0000148 size_t
cristy4c08aed2011-07-01 19:47:50 +0000149 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000150 number_channels;
cristy0d267172011-04-25 20:13:48 +0000151
cristy3dfccb22011-12-28 21:47:20 +0000152 PixelChannelMap
153 channel_map[MaxPixelChannels];
154
cristy3ed852e2009-09-05 21:47:34 +0000155 CacheType
156 type;
157
cristy87528ea2009-09-10 14:53:56 +0000158 MapMode
159 mode;
160
cristy3ed852e2009-09-05 21:47:34 +0000161 MagickBooleanType
162 mapped;
163
cristy3ed852e2009-09-05 21:47:34 +0000164 MagickOffsetType
165 offset;
166
167 MagickSizeType
168 length;
169
170 VirtualPixelMethod
171 virtual_pixel_method;
172
cristy4c08aed2011-07-01 19:47:50 +0000173 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000174 virtual_pixel_color;
175
cristybb503372010-05-27 20:51:26 +0000176 size_t
cristy3ed852e2009-09-05 21:47:34 +0000177 number_threads;
178
179 NexusInfo
180 **nexus_info;
181
cristy4c08aed2011-07-01 19:47:50 +0000182 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000183 *pixels;
184
cristy4c08aed2011-07-01 19:47:50 +0000185 void
186 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000187
188 int
189 file;
190
191 char
192 filename[MaxTextExtent],
193 cache_filename[MaxTextExtent];
194
195 CacheMethods
196 methods;
197
198 RandomInfo
199 *random_info;
200
cristybb31fcd2013-01-15 20:06:37 +0000201 void
cristy0c682412013-01-18 14:14:13 +0000202 *server_info;
cristy286dea02013-01-08 21:34:16 +0000203
cristy3ed852e2009-09-05 21:47:34 +0000204 MagickBooleanType
cristyfa0ea942012-12-21 02:42:29 +0000205 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000206 debug;
207
208 MagickThreadType
209 id;
210
cristybb503372010-05-27 20:51:26 +0000211 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000212 reference_count;
213
214 SemaphoreInfo
215 *semaphore,
cristy245d4c52012-11-15 21:13:56 +0000216 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000217
cristyff1889f2012-05-08 18:38:44 +0000218 time_t
219 timestamp;
220
cristybb503372010-05-27 20:51:26 +0000221 size_t
cristy3ed852e2009-09-05 21:47:34 +0000222 signature;
223} CacheInfo;
224
cristy9c7a8792011-09-02 19:54:50 +0000225extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000226 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000227 ClonePixelCache(const Cache),
228 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000229 ReferencePixelCache(Cache);
230
cristy9c7a8792011-09-02 19:54:50 +0000231extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000232 GetPixelCacheStorageClass(const Cache);
233
cristy9c7a8792011-09-02 19:54:50 +0000234extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000235 GetPixelCacheColorspace(const Cache);
236
cristy9c7a8792011-09-02 19:54:50 +0000237extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000238 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
239 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000240 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000241 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
242
cristy9c7a8792011-09-02 19:54:50 +0000243extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000244 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000245 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000246
cristy9c7a8792011-09-02 19:54:50 +0000247extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000248 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000249 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
250 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000251 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000252
cristy9c7a8792011-09-02 19:54:50 +0000253extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000254 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
255
cristy9c7a8792011-09-02 19:54:50 +0000256extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000257 **AcquirePixelCacheNexus(const size_t),
258 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000259
cristy9c7a8792011-09-02 19:54:50 +0000260extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000261 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000262 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristyc11dace2012-01-24 16:39:46 +0000263 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
264 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000265 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000266
cristy9c7a8792011-09-02 19:54:50 +0000267extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000268 GetPixelCacheChannels(const Cache);
269
cristyd1dd6e42011-09-04 01:46:08 +0000270extern MagickPrivate VirtualPixelMethod
271 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000272 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000273
cristy9c7a8792011-09-02 19:54:50 +0000274extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000275 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000276 ClonePixelCacheMethods(Cache,const Cache),
cristyd1dd6e42011-09-04 01:46:08 +0000277 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000278 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000279 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000280 SetPixelCacheMethods(Cache,CacheMethods *);
281
cristy3ed852e2009-09-05 21:47:34 +0000282#if defined(__cplusplus) || defined(c_plusplus)
283}
284#endif
285
286#endif