blob: 5612e344dd2abcdd5fd88bef25c0c0f2e6bbe08d [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy7e41fe82010-12-04 23:12:08 +00002 Copyright 1999-2011 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,
cristy3ed852e2009-09-05 21:47:34 +000044 PixelPacket *,ExceptionInfo *),
45 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristybb503372010-05-27 20:51:26 +000046 const ssize_t,const ssize_t,PixelPacket *,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
cristy3ed852e2009-09-05 21:47:34 +0000132 CacheType
133 type;
134
cristy87528ea2009-09-10 14:53:56 +0000135 MapMode
136 mode;
137
cristy3ed852e2009-09-05 21:47:34 +0000138 MagickBooleanType
139 mapped;
140
cristy3ed852e2009-09-05 21:47:34 +0000141 MagickOffsetType
142 offset;
143
144 MagickSizeType
145 length;
146
147 VirtualPixelMethod
148 virtual_pixel_method;
149
cristy4c08aed2011-07-01 19:47:50 +0000150 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000151 virtual_pixel_color;
152
cristybb503372010-05-27 20:51:26 +0000153 size_t
cristy3ed852e2009-09-05 21:47:34 +0000154 number_threads;
155
156 NexusInfo
157 **nexus_info;
158
cristy4c08aed2011-07-01 19:47:50 +0000159 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000160 *pixels;
161
cristy4c08aed2011-07-01 19:47:50 +0000162 void
163 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000164
165 int
166 file;
167
168 char
169 filename[MaxTextExtent],
170 cache_filename[MaxTextExtent];
171
172 CacheMethods
173 methods;
174
175 RandomInfo
176 *random_info;
177
178 MagickBooleanType
179 debug;
180
181 MagickThreadType
182 id;
183
cristybb503372010-05-27 20:51:26 +0000184 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000185 reference_count;
186
187 SemaphoreInfo
188 *semaphore,
189 *disk_semaphore;
190
191 time_t
192 timestamp;
193
cristybb503372010-05-27 20:51:26 +0000194 size_t
cristy3ed852e2009-09-05 21:47:34 +0000195 signature;
196} CacheInfo;
197
cristy9c7a8792011-09-02 19:54:50 +0000198extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000199 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000200 ClonePixelCache(const Cache),
201 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000202 ReferencePixelCache(Cache);
203
cristy9c7a8792011-09-02 19:54:50 +0000204extern MagickPrivate CacheType
cristyb32b90a2009-09-07 21:45:48 +0000205 GetPixelCacheType(const Image *);
206
cristy9c7a8792011-09-02 19:54:50 +0000207extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000208 GetPixelCacheStorageClass(const Cache);
209
cristy9c7a8792011-09-02 19:54:50 +0000210extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000211 GetPixelCacheColorspace(const Cache);
212
cristy9c7a8792011-09-02 19:54:50 +0000213extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000214 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
215 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy3ed852e2009-09-05 21:47:34 +0000216 ExceptionInfo *),
217 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
218
cristy9c7a8792011-09-02 19:54:50 +0000219extern MagickPrivate const void
cristy4c08aed2011-07-01 19:47:50 +0000220 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000221
cristy9c7a8792011-09-02 19:54:50 +0000222extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000223 CacheComponentGenesis(void),
cristy3ed852e2009-09-05 21:47:34 +0000224 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *);
225
cristy9c7a8792011-09-02 19:54:50 +0000226extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000227 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
228
cristy9c7a8792011-09-02 19:54:50 +0000229extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000230 **AcquirePixelCacheNexus(const size_t),
231 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000232
cristy9c7a8792011-09-02 19:54:50 +0000233extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000234 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
235 const size_t,const size_t,NexusInfo *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000236 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristybb503372010-05-27 20:51:26 +0000237 *QueueAuthenticNexus(Image *,const ssize_t,const ssize_t,const size_t,
238 const size_t,NexusInfo *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000239
cristy9c7a8792011-09-02 19:54:50 +0000240extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000241 GetPixelCacheChannels(const Cache);
242
cristy9c7a8792011-09-02 19:54:50 +0000243extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000244 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000245 ClonePixelCacheMethods(Cache,const Cache),
cristy5ff4eaf2011-09-03 01:38:02 +0000246 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *),
cristybb503372010-05-27 20:51:26 +0000247 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000248 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000249 SetPixelCacheMethods(Cache,CacheMethods *);
250
cristy3ed852e2009-09-05 21:47:34 +0000251#if defined(__cplusplus) || defined(c_plusplus)
252}
253#endif
254
255#endif