blob: 698f3be9cdb458303c617f448f1234733570743a [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"
28#include "MagickCore/distribute-cache-private.h"
cristy8a46d822012-08-28 23:32:39 +000029#include "MagickCore/pixel.h"
cristy4c08aed2011-07-01 19:47:50 +000030#include "MagickCore/random_.h"
31#include "MagickCore/thread-private.h"
32#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000033
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
105typedef struct _NexusInfo
106 NexusInfo;
107
108typedef struct _CacheInfo
109{
110 ClassType
111 storage_class;
112
113 ColorspaceType
114 colorspace;
115
cristy8a46d822012-08-28 23:32:39 +0000116 PixelTrait
117 alpha_trait;
118
cristy222b19c2011-08-04 01:35:11 +0000119 MagickBooleanType
cristy183a5c72012-01-30 01:40:35 +0000120 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
cristye80f9cb2013-01-09 01:09:31 +0000179 DistributeCacheInfo
cristy1cbaf972013-01-09 02:13:23 +0000180 *distribute_cache_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