blob: b106cc6c267557669f05dd6c409e38e55e1620dd [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
cristybb31fcd2013-01-15 20:06:37 +0000105 NexusInfo;
cristy3ed852e2009-09-05 21:47:34 +0000106
107typedef struct _CacheInfo
108{
109 ClassType
110 storage_class;
111
112 ColorspaceType
113 colorspace;
114
cristy8a46d822012-08-28 23:32:39 +0000115 PixelTrait
116 alpha_trait;
117
cristy222b19c2011-08-04 01:35:11 +0000118 MagickBooleanType
cristy883fde12013-04-08 00:50:13 +0000119 read_mask,
120 write_mask;
cristy222b19c2011-08-04 01:35:11 +0000121
122 size_t
123 columns,
124 rows;
125
cristybcc1fdc2011-04-29 13:06:35 +0000126 size_t
cristy4c08aed2011-07-01 19:47:50 +0000127 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000128 number_channels;
cristy0d267172011-04-25 20:13:48 +0000129
cristy3dfccb22011-12-28 21:47:20 +0000130 PixelChannelMap
131 channel_map[MaxPixelChannels];
132
cristy3ed852e2009-09-05 21:47:34 +0000133 CacheType
134 type;
135
cristy87528ea2009-09-10 14:53:56 +0000136 MapMode
137 mode;
138
cristy3ed852e2009-09-05 21:47:34 +0000139 MagickBooleanType
140 mapped;
141
cristy3ed852e2009-09-05 21:47:34 +0000142 MagickOffsetType
143 offset;
144
145 MagickSizeType
146 length;
147
148 VirtualPixelMethod
149 virtual_pixel_method;
150
cristy4c08aed2011-07-01 19:47:50 +0000151 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000152 virtual_pixel_color;
153
cristybb503372010-05-27 20:51:26 +0000154 size_t
cristy3ed852e2009-09-05 21:47:34 +0000155 number_threads;
156
157 NexusInfo
158 **nexus_info;
159
cristy4c08aed2011-07-01 19:47:50 +0000160 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000161 *pixels;
162
cristy4c08aed2011-07-01 19:47:50 +0000163 void
164 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000165
166 int
167 file;
168
169 char
170 filename[MaxTextExtent],
171 cache_filename[MaxTextExtent];
172
173 CacheMethods
174 methods;
175
176 RandomInfo
177 *random_info;
178
cristybb31fcd2013-01-15 20:06:37 +0000179 void
cristy0c682412013-01-18 14:14:13 +0000180 *server_info;
cristy286dea02013-01-08 21:34:16 +0000181
cristy3ed852e2009-09-05 21:47:34 +0000182 MagickBooleanType
cristyfa0ea942012-12-21 02:42:29 +0000183 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000184 debug;
185
186 MagickThreadType
187 id;
188
cristybb503372010-05-27 20:51:26 +0000189 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000190 reference_count;
191
192 SemaphoreInfo
193 *semaphore,
cristy245d4c52012-11-15 21:13:56 +0000194 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000195
cristyff1889f2012-05-08 18:38:44 +0000196 time_t
197 timestamp;
198
cristybb503372010-05-27 20:51:26 +0000199 size_t
cristy3ed852e2009-09-05 21:47:34 +0000200 signature;
201} CacheInfo;
202
cristy9c7a8792011-09-02 19:54:50 +0000203extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000204 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000205 ClonePixelCache(const Cache),
206 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000207 ReferencePixelCache(Cache);
208
cristy9c7a8792011-09-02 19:54:50 +0000209extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000210 GetPixelCacheStorageClass(const Cache);
211
cristy9c7a8792011-09-02 19:54:50 +0000212extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000213 GetPixelCacheColorspace(const Cache);
214
cristy9c7a8792011-09-02 19:54:50 +0000215extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000216 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
217 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000218 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000219 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
220
cristy9c7a8792011-09-02 19:54:50 +0000221extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000222 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000223 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000224
cristy9c7a8792011-09-02 19:54:50 +0000225extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000226 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000227 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
228 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000229 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000230
cristy9c7a8792011-09-02 19:54:50 +0000231extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000232 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
233
cristy9c7a8792011-09-02 19:54:50 +0000234extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000235 **AcquirePixelCacheNexus(const size_t),
236 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000237
cristy9c7a8792011-09-02 19:54:50 +0000238extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000239 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000240 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000241 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000242 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
243 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000244 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000245
cristy9c7a8792011-09-02 19:54:50 +0000246extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000247 GetPixelCacheChannels(const Cache);
248
cristyd1dd6e42011-09-04 01:46:08 +0000249extern MagickPrivate VirtualPixelMethod
250 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000251 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000252
cristy9c7a8792011-09-02 19:54:50 +0000253extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000254 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000255 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000256 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000257 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000258 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000259 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000260 SetPixelCacheMethods(Cache,CacheMethods *);
261
cristy3ed852e2009-09-05 21:47:34 +0000262#if defined(__cplusplus) || defined(c_plusplus)
263}
264#endif
265
266#endif