blob: cb2b3ec0e60fabed27aa6549299ef4073182be77 [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"
cristy8a46d822012-08-28 23:32:39 +000027#include "MagickCore/pixel.h"
cristy4c08aed2011-07-01 19:47:50 +000028#include "MagickCore/random_.h"
29#include "MagickCore/thread-private.h"
30#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000031
cristy286dea02013-01-08 21:34:16 +000032#define MaxNumberDistributedCacheClients 32
33
cristycd01fae2011-08-06 23:52:42 +000034typedef void
35 *Cache;
36
cristy3ed852e2009-09-05 21:47:34 +000037typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000038 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000039 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000040 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000041 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000042 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
43
cristy4c08aed2011-07-01 19:47:50 +000044typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000045 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
46 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000047 *(*GetVirtualPixelsHandler)(const Image *);
48
cristy4c08aed2011-07-01 19:47:50 +000049typedef const void
50 *(*GetVirtualMetacontentFromHandler)(const Image *);
51
52typedef Quantum
cristybb503372010-05-27 20:51:26 +000053 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
54 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000055
cristy4c08aed2011-07-01 19:47:50 +000056typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000057 *(*GetAuthenticPixelsFromHandler)(const Image *);
58
cristy4c08aed2011-07-01 19:47:50 +000059typedef Quantum
cristybb503372010-05-27 20:51:26 +000060 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
61 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000062
63typedef void
64 (*DestroyPixelHandler)(Image *);
65
cristy4c08aed2011-07-01 19:47:50 +000066typedef void
67 *(*GetAuthenticMetacontentFromHandler)(const Image *);
68
cristy3ed852e2009-09-05 21:47:34 +000069typedef struct _CacheMethods
70{
71 GetVirtualPixelHandler
72 get_virtual_pixel_handler;
73
74 GetVirtualPixelsHandler
75 get_virtual_pixels_handler;
76
cristy4c08aed2011-07-01 19:47:50 +000077 GetVirtualMetacontentFromHandler
78 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000079
80 GetOneVirtualPixelFromHandler
81 get_one_virtual_pixel_from_handler;
82
83 GetAuthenticPixelsHandler
84 get_authentic_pixels_handler;
85
cristy4c08aed2011-07-01 19:47:50 +000086 GetAuthenticMetacontentFromHandler
87 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000088
89 GetOneAuthenticPixelFromHandler
90 get_one_authentic_pixel_from_handler;
91
92 GetAuthenticPixelsFromHandler
93 get_authentic_pixels_from_handler;
94
95 QueueAuthenticPixelsHandler
96 queue_authentic_pixels_handler;
97
98 SyncAuthenticPixelsHandler
99 sync_authentic_pixels_handler;
100
101 DestroyPixelHandler
102 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000103} CacheMethods;
104
cristy286dea02013-01-08 21:34:16 +0000105typedef struct _DistributedCacheInfo
106{
107#if defined(MAGICKCORE_HAVE_SOCKET)
108 int
109 server;
110#endif
111
112 size_t
113 session;
114} DistributedCacheInfo;
115
cristy3ed852e2009-09-05 21:47:34 +0000116typedef struct _NexusInfo
117 NexusInfo;
118
119typedef struct _CacheInfo
120{
121 ClassType
122 storage_class;
123
124 ColorspaceType
125 colorspace;
126
cristy8a46d822012-08-28 23:32:39 +0000127 PixelTrait
128 alpha_trait;
129
cristy222b19c2011-08-04 01:35:11 +0000130 MagickBooleanType
cristy183a5c72012-01-30 01:40:35 +0000131 mask;
cristy222b19c2011-08-04 01:35:11 +0000132
133 size_t
134 columns,
135 rows;
136
cristybcc1fdc2011-04-29 13:06:35 +0000137 size_t
cristy4c08aed2011-07-01 19:47:50 +0000138 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000139 number_channels;
cristy0d267172011-04-25 20:13:48 +0000140
cristy3dfccb22011-12-28 21:47:20 +0000141 PixelChannelMap
142 channel_map[MaxPixelChannels];
143
cristy3ed852e2009-09-05 21:47:34 +0000144 CacheType
145 type;
146
cristy87528ea2009-09-10 14:53:56 +0000147 MapMode
148 mode;
149
cristy3ed852e2009-09-05 21:47:34 +0000150 MagickBooleanType
151 mapped;
152
cristy3ed852e2009-09-05 21:47:34 +0000153 MagickOffsetType
154 offset;
155
156 MagickSizeType
157 length;
158
159 VirtualPixelMethod
160 virtual_pixel_method;
161
cristy4c08aed2011-07-01 19:47:50 +0000162 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000163 virtual_pixel_color;
164
cristybb503372010-05-27 20:51:26 +0000165 size_t
cristy3ed852e2009-09-05 21:47:34 +0000166 number_threads;
167
168 NexusInfo
169 **nexus_info;
170
cristy4c08aed2011-07-01 19:47:50 +0000171 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000172 *pixels;
173
cristy4c08aed2011-07-01 19:47:50 +0000174 void
175 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000176
177 int
178 file;
179
180 char
181 filename[MaxTextExtent],
182 cache_filename[MaxTextExtent];
183
184 CacheMethods
185 methods;
186
187 RandomInfo
188 *random_info;
189
cristy286dea02013-01-08 21:34:16 +0000190 ssize_t
191 number_connections;
192
193 DistributedCacheInfo
194 connection[MaxNumberDistributedCacheClients];
195
cristy3ed852e2009-09-05 21:47:34 +0000196 MagickBooleanType
cristyfa0ea942012-12-21 02:42:29 +0000197 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000198 debug;
199
200 MagickThreadType
201 id;
202
cristybb503372010-05-27 20:51:26 +0000203 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000204 reference_count;
205
206 SemaphoreInfo
207 *semaphore,
cristy245d4c52012-11-15 21:13:56 +0000208 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000209
cristyff1889f2012-05-08 18:38:44 +0000210 time_t
211 timestamp;
212
cristybb503372010-05-27 20:51:26 +0000213 size_t
cristy3ed852e2009-09-05 21:47:34 +0000214 signature;
215} CacheInfo;
216
cristy9c7a8792011-09-02 19:54:50 +0000217extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000218 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000219 ClonePixelCache(const Cache),
220 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000221 ReferencePixelCache(Cache);
222
cristy9c7a8792011-09-02 19:54:50 +0000223extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000224 GetPixelCacheStorageClass(const Cache);
225
cristy9c7a8792011-09-02 19:54:50 +0000226extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000227 GetPixelCacheColorspace(const Cache);
228
cristy9c7a8792011-09-02 19:54:50 +0000229extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000230 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
231 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000232 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000233 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
234
cristy9c7a8792011-09-02 19:54:50 +0000235extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000236 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000237 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000238
cristy9c7a8792011-09-02 19:54:50 +0000239extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000240 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000241 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
242 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000243 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000244
cristy9c7a8792011-09-02 19:54:50 +0000245extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000246 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
247
cristy9c7a8792011-09-02 19:54:50 +0000248extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000249 **AcquirePixelCacheNexus(const size_t),
250 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000251
cristy9c7a8792011-09-02 19:54:50 +0000252extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000253 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000254 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000255 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000256 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
257 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000258 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000259
cristy9c7a8792011-09-02 19:54:50 +0000260extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000261 GetPixelCacheChannels(const Cache);
262
cristyd1dd6e42011-09-04 01:46:08 +0000263extern MagickPrivate VirtualPixelMethod
264 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000265 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000266
cristy9c7a8792011-09-02 19:54:50 +0000267extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000268 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000269 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000270 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000271 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000272 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000273 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000274 SetPixelCacheMethods(Cache,CacheMethods *);
275
cristy3ed852e2009-09-05 21:47:34 +0000276#if defined(__cplusplus) || defined(c_plusplus)
277}
278#endif
279
280#endif