blob: a6be29f9225ca44fa1ecf578c1d755569ac07ec2 [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
cristy10a6c612012-01-29 21:41:05 +0000122 matte,
cristy183a5c72012-01-30 01:40:35 +0000123 mask;
cristy222b19c2011-08-04 01:35:11 +0000124
125 size_t
126 columns,
127 rows;
128
cristybcc1fdc2011-04-29 13:06:35 +0000129 size_t
cristy4c08aed2011-07-01 19:47:50 +0000130 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000131 number_channels;
cristy0d267172011-04-25 20:13:48 +0000132
cristy3dfccb22011-12-28 21:47:20 +0000133 PixelChannelMap
134 channel_map[MaxPixelChannels];
135
cristy3ed852e2009-09-05 21:47:34 +0000136 CacheType
137 type;
138
cristy87528ea2009-09-10 14:53:56 +0000139 MapMode
140 mode;
141
cristy3ed852e2009-09-05 21:47:34 +0000142 MagickBooleanType
143 mapped;
144
cristy3ed852e2009-09-05 21:47:34 +0000145 MagickOffsetType
146 offset;
147
148 MagickSizeType
149 length;
150
151 VirtualPixelMethod
152 virtual_pixel_method;
153
cristy4c08aed2011-07-01 19:47:50 +0000154 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000155 virtual_pixel_color;
156
cristybb503372010-05-27 20:51:26 +0000157 size_t
cristy3ed852e2009-09-05 21:47:34 +0000158 number_threads;
159
160 NexusInfo
161 **nexus_info;
162
cristy4c08aed2011-07-01 19:47:50 +0000163 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000164 *pixels;
165
cristy4c08aed2011-07-01 19:47:50 +0000166 void
167 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000168
169 int
170 file;
171
172 char
173 filename[MaxTextExtent],
174 cache_filename[MaxTextExtent];
175
176 CacheMethods
177 methods;
178
179 RandomInfo
180 *random_info;
181
182 MagickBooleanType
183 debug;
184
185 MagickThreadType
186 id;
187
cristybb503372010-05-27 20:51:26 +0000188 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000189 reference_count;
190
191 SemaphoreInfo
192 *semaphore,
193 *disk_semaphore;
194
195 time_t
196 timestamp;
197
cristybb503372010-05-27 20:51:26 +0000198 size_t
cristy3ed852e2009-09-05 21:47:34 +0000199 signature;
200} CacheInfo;
201
cristy9c7a8792011-09-02 19:54:50 +0000202extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000203 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000204 ClonePixelCache(const Cache),
205 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000206 ReferencePixelCache(Cache);
207
cristy9c7a8792011-09-02 19:54:50 +0000208extern MagickPrivate CacheType
cristyb32b90a2009-09-07 21:45:48 +0000209 GetPixelCacheType(const Image *);
210
cristy9c7a8792011-09-02 19:54:50 +0000211extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000212 GetPixelCacheStorageClass(const Cache);
213
cristy9c7a8792011-09-02 19:54:50 +0000214extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000215 GetPixelCacheColorspace(const Cache);
216
cristy9c7a8792011-09-02 19:54:50 +0000217extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000218 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
219 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000220 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000221 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
222
cristy9c7a8792011-09-02 19:54:50 +0000223extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000224 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000225 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000226
cristy9c7a8792011-09-02 19:54:50 +0000227extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000228 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000229 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
230 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000231 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000232
cristy9c7a8792011-09-02 19:54:50 +0000233extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000234 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
235
cristy9c7a8792011-09-02 19:54:50 +0000236extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000237 **AcquirePixelCacheNexus(const size_t),
238 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000239
cristy9c7a8792011-09-02 19:54:50 +0000240extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000241 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000242 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000243 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000244 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
245 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000246 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000247
cristy9c7a8792011-09-02 19:54:50 +0000248extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000249 GetPixelCacheChannels(const Cache);
250
cristyd1dd6e42011-09-04 01:46:08 +0000251extern MagickPrivate VirtualPixelMethod
252 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000253 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000254
cristy9c7a8792011-09-02 19:54:50 +0000255extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000256 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000257 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000258 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000259 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000260 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000261 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000262 SetPixelCacheMethods(Cache,CacheMethods *);
263
cristy3ed852e2009-09-05 21:47:34 +0000264#if defined(__cplusplus) || defined(c_plusplus)
265}
266#endif
267
268#endif