blob: 9b89131394dd0eb3a6954b2207fe15228de0f38c [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
119 void
120 *metacontent;
121
122 size_t
123 signature;
124} NexusInfo;
cristy3ed852e2009-09-05 21:47:34 +0000125
126typedef struct _CacheInfo
127{
128 ClassType
129 storage_class;
130
131 ColorspaceType
132 colorspace;
133
cristy8a46d822012-08-28 23:32:39 +0000134 PixelTrait
135 alpha_trait;
136
cristy222b19c2011-08-04 01:35:11 +0000137 MagickBooleanType
cristy883fde12013-04-08 00:50:13 +0000138 read_mask,
139 write_mask;
cristy222b19c2011-08-04 01:35:11 +0000140
141 size_t
142 columns,
143 rows;
144
cristybcc1fdc2011-04-29 13:06:35 +0000145 size_t
cristy4c08aed2011-07-01 19:47:50 +0000146 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000147 number_channels;
cristy0d267172011-04-25 20:13:48 +0000148
cristy3dfccb22011-12-28 21:47:20 +0000149 PixelChannelMap
150 channel_map[MaxPixelChannels];
151
cristy3ed852e2009-09-05 21:47:34 +0000152 CacheType
153 type;
154
cristy87528ea2009-09-10 14:53:56 +0000155 MapMode
156 mode;
157
cristy3ed852e2009-09-05 21:47:34 +0000158 MagickBooleanType
159 mapped;
160
cristy3ed852e2009-09-05 21:47:34 +0000161 MagickOffsetType
162 offset;
163
164 MagickSizeType
165 length;
166
167 VirtualPixelMethod
168 virtual_pixel_method;
169
cristy4c08aed2011-07-01 19:47:50 +0000170 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000171 virtual_pixel_color;
172
cristybb503372010-05-27 20:51:26 +0000173 size_t
cristy3ed852e2009-09-05 21:47:34 +0000174 number_threads;
175
176 NexusInfo
177 **nexus_info;
178
cristy4c08aed2011-07-01 19:47:50 +0000179 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000180 *pixels;
181
cristy4c08aed2011-07-01 19:47:50 +0000182 void
183 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000184
185 int
186 file;
187
188 char
189 filename[MaxTextExtent],
190 cache_filename[MaxTextExtent];
191
192 CacheMethods
193 methods;
194
195 RandomInfo
196 *random_info;
197
cristybb31fcd2013-01-15 20:06:37 +0000198 void
cristy0c682412013-01-18 14:14:13 +0000199 *server_info;
cristy286dea02013-01-08 21:34:16 +0000200
cristy3ed852e2009-09-05 21:47:34 +0000201 MagickBooleanType
cristyfa0ea942012-12-21 02:42:29 +0000202 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000203 debug;
204
205 MagickThreadType
206 id;
207
cristybb503372010-05-27 20:51:26 +0000208 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000209 reference_count;
210
211 SemaphoreInfo
212 *semaphore,
cristy245d4c52012-11-15 21:13:56 +0000213 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000214
cristyff1889f2012-05-08 18:38:44 +0000215 time_t
216 timestamp;
217
cristybb503372010-05-27 20:51:26 +0000218 size_t
cristy3ed852e2009-09-05 21:47:34 +0000219 signature;
220} CacheInfo;
221
cristy9c7a8792011-09-02 19:54:50 +0000222extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000223 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000224 ClonePixelCache(const Cache),
225 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000226 ReferencePixelCache(Cache);
227
cristy9c7a8792011-09-02 19:54:50 +0000228extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000229 GetPixelCacheStorageClass(const Cache);
230
cristy9c7a8792011-09-02 19:54:50 +0000231extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000232 GetPixelCacheColorspace(const Cache);
233
cristy9c7a8792011-09-02 19:54:50 +0000234extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000235 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
236 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000237 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000238 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
239
cristy9c7a8792011-09-02 19:54:50 +0000240extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000241 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000242 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000243
cristy9c7a8792011-09-02 19:54:50 +0000244extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000245 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000246 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
247 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000248 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000249
cristy9c7a8792011-09-02 19:54:50 +0000250extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000251 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
252
cristy9c7a8792011-09-02 19:54:50 +0000253extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000254 **AcquirePixelCacheNexus(const size_t),
255 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000256
cristy9c7a8792011-09-02 19:54:50 +0000257extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000258 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000259 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristyc11dace2012-01-24 16:39:46 +0000260 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
261 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000262 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000263
cristy9c7a8792011-09-02 19:54:50 +0000264extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000265 GetPixelCacheChannels(const Cache);
266
cristyd1dd6e42011-09-04 01:46:08 +0000267extern MagickPrivate VirtualPixelMethod
268 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000269 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000270
cristy9c7a8792011-09-02 19:54:50 +0000271extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000272 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000273 ClonePixelCacheMethods(Cache,const Cache),
cristyd1dd6e42011-09-04 01:46:08 +0000274 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000275 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000276 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000277 SetPixelCacheMethods(Cache,CacheMethods *);
278
cristy3ed852e2009-09-05 21:47:34 +0000279#if defined(__cplusplus) || defined(c_plusplus)
280}
281#endif
282
283#endif