blob: fac96c083415d6f8b3dac04d0b5b5ffcaffa5a88 [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>
cristy4ee2b0c2012-05-15 00:30:35 +000026#include "MagickCore/cache.h"
cristy4c08aed2011-07-01 19:47:50 +000027#include "MagickCore/random_.h"
28#include "MagickCore/thread-private.h"
29#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000030
31typedef enum
32{
33 UndefinedCache,
34 MemoryCache,
35 MapCache,
cristy73724512010-04-12 14:43:14 +000036 DiskCache,
37 PingCache
cristy3ed852e2009-09-05 21:47:34 +000038} CacheType;
39
cristycd01fae2011-08-06 23:52:42 +000040typedef void
41 *Cache;
42
cristy3ed852e2009-09-05 21:47:34 +000043typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000044 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000045 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000046 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000047 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000048 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
49
cristy4c08aed2011-07-01 19:47:50 +000050typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000051 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
52 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000053 *(*GetVirtualPixelsHandler)(const Image *);
54
cristy4c08aed2011-07-01 19:47:50 +000055typedef const void
56 *(*GetVirtualMetacontentFromHandler)(const Image *);
57
58typedef Quantum
cristybb503372010-05-27 20:51:26 +000059 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
60 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000061
cristy4c08aed2011-07-01 19:47:50 +000062typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000063 *(*GetAuthenticPixelsFromHandler)(const Image *);
64
cristy4c08aed2011-07-01 19:47:50 +000065typedef Quantum
cristybb503372010-05-27 20:51:26 +000066 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
67 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000068
69typedef void
70 (*DestroyPixelHandler)(Image *);
71
cristy4c08aed2011-07-01 19:47:50 +000072typedef void
73 *(*GetAuthenticMetacontentFromHandler)(const Image *);
74
cristy3ed852e2009-09-05 21:47:34 +000075typedef struct _CacheMethods
76{
77 GetVirtualPixelHandler
78 get_virtual_pixel_handler;
79
80 GetVirtualPixelsHandler
81 get_virtual_pixels_handler;
82
cristy4c08aed2011-07-01 19:47:50 +000083 GetVirtualMetacontentFromHandler
84 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000085
86 GetOneVirtualPixelFromHandler
87 get_one_virtual_pixel_from_handler;
88
89 GetAuthenticPixelsHandler
90 get_authentic_pixels_handler;
91
cristy4c08aed2011-07-01 19:47:50 +000092 GetAuthenticMetacontentFromHandler
93 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000094
95 GetOneAuthenticPixelFromHandler
96 get_one_authentic_pixel_from_handler;
97
98 GetAuthenticPixelsFromHandler
99 get_authentic_pixels_from_handler;
100
101 QueueAuthenticPixelsHandler
102 queue_authentic_pixels_handler;
103
104 SyncAuthenticPixelsHandler
105 sync_authentic_pixels_handler;
106
107 DestroyPixelHandler
108 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000109} CacheMethods;
110
111typedef struct _NexusInfo
112 NexusInfo;
113
114typedef struct _CacheInfo
115{
116 ClassType
117 storage_class;
118
119 ColorspaceType
120 colorspace;
121
cristy222b19c2011-08-04 01:35:11 +0000122 MagickBooleanType
cristy10a6c612012-01-29 21:41:05 +0000123 matte,
cristy183a5c72012-01-30 01:40:35 +0000124 mask;
cristy222b19c2011-08-04 01:35:11 +0000125
126 size_t
127 columns,
128 rows;
129
cristybcc1fdc2011-04-29 13:06:35 +0000130 size_t
cristy4c08aed2011-07-01 19:47:50 +0000131 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000132 number_channels;
cristy0d267172011-04-25 20:13:48 +0000133
cristy3dfccb22011-12-28 21:47:20 +0000134 PixelChannelMap
135 channel_map[MaxPixelChannels];
136
cristy3ed852e2009-09-05 21:47:34 +0000137 CacheType
138 type;
139
cristy87528ea2009-09-10 14:53:56 +0000140 MapMode
141 mode;
142
cristy3ed852e2009-09-05 21:47:34 +0000143 MagickBooleanType
144 mapped;
145
cristy3ed852e2009-09-05 21:47:34 +0000146 MagickOffsetType
147 offset;
148
149 MagickSizeType
150 length;
151
152 VirtualPixelMethod
153 virtual_pixel_method;
154
cristy4c08aed2011-07-01 19:47:50 +0000155 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000156 virtual_pixel_color;
157
cristybb503372010-05-27 20:51:26 +0000158 size_t
cristy3ed852e2009-09-05 21:47:34 +0000159 number_threads;
160
161 NexusInfo
162 **nexus_info;
163
cristy4c08aed2011-07-01 19:47:50 +0000164 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000165 *pixels;
166
cristy4c08aed2011-07-01 19:47:50 +0000167 void
168 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000169
170 int
171 file;
172
173 char
174 filename[MaxTextExtent],
175 cache_filename[MaxTextExtent];
176
177 CacheMethods
178 methods;
179
180 RandomInfo
181 *random_info;
182
183 MagickBooleanType
184 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,
194 *disk_semaphore;
195
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 CacheType
cristyb32b90a2009-09-07 21:45:48 +0000210 GetPixelCacheType(const Image *);
211
cristy9c7a8792011-09-02 19:54:50 +0000212extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000213 GetPixelCacheStorageClass(const Cache);
214
cristy9c7a8792011-09-02 19:54:50 +0000215extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000216 GetPixelCacheColorspace(const Cache);
217
cristy9c7a8792011-09-02 19:54:50 +0000218extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000219 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
220 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000221 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000222 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
223
cristy9c7a8792011-09-02 19:54:50 +0000224extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000225 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000226 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000227
cristy9c7a8792011-09-02 19:54:50 +0000228extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000229 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000230 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
231 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000232 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000233
cristy9c7a8792011-09-02 19:54:50 +0000234extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000235 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
236
cristy9c7a8792011-09-02 19:54:50 +0000237extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000238 **AcquirePixelCacheNexus(const size_t),
239 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000240
cristy9c7a8792011-09-02 19:54:50 +0000241extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000242 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000243 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000244 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000245 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
246 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000247 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000248
cristy9c7a8792011-09-02 19:54:50 +0000249extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000250 GetPixelCacheChannels(const Cache);
251
cristyd1dd6e42011-09-04 01:46:08 +0000252extern MagickPrivate VirtualPixelMethod
253 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000254 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000255
cristy9c7a8792011-09-02 19:54:50 +0000256extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000257 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000258 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000259 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000260 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000261 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000262 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000263 SetPixelCacheMethods(Cache,CacheMethods *);
264
cristy3ed852e2009-09-05 21:47:34 +0000265#if defined(__cplusplus) || defined(c_plusplus)
266}
267#endif
268
269#endif