blob: 118a5a5a2726b2f68429b0436b769b71c6353ccc [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy1454be72011-12-19 01:52:48 +00002 Copyright 1999-2012 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>
cristy4c08aed2011-07-01 19:47:50 +000026#include "MagickCore/random_.h"
27#include "MagickCore/thread-private.h"
28#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000029
30typedef enum
31{
32 UndefinedCache,
33 MemoryCache,
34 MapCache,
cristy73724512010-04-12 14:43:14 +000035 DiskCache,
36 PingCache
cristy3ed852e2009-09-05 21:47:34 +000037} CacheType;
38
cristycd01fae2011-08-06 23:52:42 +000039typedef void
40 *Cache;
41
cristy3ed852e2009-09-05 21:47:34 +000042typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000043 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000044 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000045 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000046 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000047 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
48
cristy4c08aed2011-07-01 19:47:50 +000049typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000050 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
51 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000052 *(*GetVirtualPixelsHandler)(const Image *);
53
cristy4c08aed2011-07-01 19:47:50 +000054typedef const void
55 *(*GetVirtualMetacontentFromHandler)(const Image *);
56
57typedef Quantum
cristybb503372010-05-27 20:51:26 +000058 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
59 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000060
cristy4c08aed2011-07-01 19:47:50 +000061typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000062 *(*GetAuthenticPixelsFromHandler)(const Image *);
63
cristy4c08aed2011-07-01 19:47:50 +000064typedef Quantum
cristybb503372010-05-27 20:51:26 +000065 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
66 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000067
68typedef void
69 (*DestroyPixelHandler)(Image *);
70
cristy4c08aed2011-07-01 19:47:50 +000071typedef void
72 *(*GetAuthenticMetacontentFromHandler)(const Image *);
73
cristy3ed852e2009-09-05 21:47:34 +000074typedef struct _CacheMethods
75{
76 GetVirtualPixelHandler
77 get_virtual_pixel_handler;
78
79 GetVirtualPixelsHandler
80 get_virtual_pixels_handler;
81
cristy4c08aed2011-07-01 19:47:50 +000082 GetVirtualMetacontentFromHandler
83 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000084
85 GetOneVirtualPixelFromHandler
86 get_one_virtual_pixel_from_handler;
87
88 GetAuthenticPixelsHandler
89 get_authentic_pixels_handler;
90
cristy4c08aed2011-07-01 19:47:50 +000091 GetAuthenticMetacontentFromHandler
92 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000093
94 GetOneAuthenticPixelFromHandler
95 get_one_authentic_pixel_from_handler;
96
97 GetAuthenticPixelsFromHandler
98 get_authentic_pixels_from_handler;
99
100 QueueAuthenticPixelsHandler
101 queue_authentic_pixels_handler;
102
103 SyncAuthenticPixelsHandler
104 sync_authentic_pixels_handler;
105
106 DestroyPixelHandler
107 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000108} CacheMethods;
109
110typedef struct _NexusInfo
111 NexusInfo;
112
113typedef struct _CacheInfo
114{
115 ClassType
116 storage_class;
117
118 ColorspaceType
119 colorspace;
120
cristy222b19c2011-08-04 01:35:11 +0000121 MagickBooleanType
122 matte;
123
124 size_t
125 columns,
126 rows;
127
cristybcc1fdc2011-04-29 13:06:35 +0000128 size_t
cristy4c08aed2011-07-01 19:47:50 +0000129 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000130 number_channels;
cristy0d267172011-04-25 20:13:48 +0000131
cristy3dfccb22011-12-28 21:47:20 +0000132 PixelChannelMap
133 channel_map[MaxPixelChannels];
134
cristy3ed852e2009-09-05 21:47:34 +0000135 CacheType
136 type;
137
cristy87528ea2009-09-10 14:53:56 +0000138 MapMode
139 mode;
140
cristy3ed852e2009-09-05 21:47:34 +0000141 MagickBooleanType
142 mapped;
143
cristy3ed852e2009-09-05 21:47:34 +0000144 MagickOffsetType
145 offset;
146
147 MagickSizeType
148 length;
149
150 VirtualPixelMethod
151 virtual_pixel_method;
152
cristy4c08aed2011-07-01 19:47:50 +0000153 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000154 virtual_pixel_color;
155
cristybb503372010-05-27 20:51:26 +0000156 size_t
cristy3ed852e2009-09-05 21:47:34 +0000157 number_threads;
158
159 NexusInfo
160 **nexus_info;
161
cristy4c08aed2011-07-01 19:47:50 +0000162 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000163 *pixels;
164
cristy4c08aed2011-07-01 19:47:50 +0000165 void
166 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000167
168 int
169 file;
170
171 char
172 filename[MaxTextExtent],
173 cache_filename[MaxTextExtent];
174
175 CacheMethods
176 methods;
177
178 RandomInfo
179 *random_info;
180
181 MagickBooleanType
182 debug;
183
184 MagickThreadType
185 id;
186
cristybb503372010-05-27 20:51:26 +0000187 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000188 reference_count;
189
190 SemaphoreInfo
191 *semaphore,
192 *disk_semaphore;
193
194 time_t
195 timestamp;
196
cristybb503372010-05-27 20:51:26 +0000197 size_t
cristy3ed852e2009-09-05 21:47:34 +0000198 signature;
199} CacheInfo;
200
cristy9c7a8792011-09-02 19:54:50 +0000201extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000202 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000203 ClonePixelCache(const Cache),
204 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000205 ReferencePixelCache(Cache);
206
cristy9c7a8792011-09-02 19:54:50 +0000207extern MagickPrivate CacheType
cristyb32b90a2009-09-07 21:45:48 +0000208 GetPixelCacheType(const Image *);
209
cristy9c7a8792011-09-02 19:54:50 +0000210extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000211 GetPixelCacheStorageClass(const Cache);
212
cristy9c7a8792011-09-02 19:54:50 +0000213extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000214 GetPixelCacheColorspace(const Cache);
215
cristy9c7a8792011-09-02 19:54:50 +0000216extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000217 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
218 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy3ed852e2009-09-05 21:47:34 +0000219 ExceptionInfo *),
220 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
221
cristy9c7a8792011-09-02 19:54:50 +0000222extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000223 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000224 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000225
cristy9c7a8792011-09-02 19:54:50 +0000226extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000227 CacheComponentGenesis(void),
cristyd1dd6e42011-09-04 01:46:08 +0000228 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *),
229 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,
240 const size_t,const size_t,NexusInfo *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000241 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristybb503372010-05-27 20:51:26 +0000242 *QueueAuthenticNexus(Image *,const ssize_t,const ssize_t,const size_t,
cristy65dbf172011-10-06 17:32:04 +0000243 const size_t,const MagickBooleanType,NexusInfo *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000244
cristy9c7a8792011-09-02 19:54:50 +0000245extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000246 GetPixelCacheChannels(const Cache);
247
cristyd1dd6e42011-09-04 01:46:08 +0000248extern MagickPrivate VirtualPixelMethod
249 GetPixelCacheVirtualMethod(const Image *),
250 SetPixelCacheVirtualMethod(const Image *,const VirtualPixelMethod);
251
cristy9c7a8792011-09-02 19:54:50 +0000252extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000253 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000254 ClonePixelCacheMethods(Cache,const Cache),
cristy5ff4eaf2011-09-03 01:38:02 +0000255 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *),
cristyd1dd6e42011-09-04 01:46:08 +0000256 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000257 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000258 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000259 SetPixelCacheMethods(Cache,CacheMethods *);
260
cristy3ed852e2009-09-05 21:47:34 +0000261#if defined(__cplusplus) || defined(c_plusplus)
262}
263#endif
264
265#endif