blob: 51afa32f701af004dc207102f6057800d077b7f4 [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"
cristy8a46d822012-08-28 23:32:39 +000028#include "MagickCore/pixel.h"
cristy4c08aed2011-07-01 19:47:50 +000029#include "MagickCore/random_.h"
30#include "MagickCore/thread-private.h"
31#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000032
cristycd01fae2011-08-06 23:52:42 +000033typedef void
34 *Cache;
35
cristy3ed852e2009-09-05 21:47:34 +000036typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000037 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000038 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000039 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000040 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000041 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
42
cristy4c08aed2011-07-01 19:47:50 +000043typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000044 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
45 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000046 *(*GetVirtualPixelsHandler)(const Image *);
47
cristy4c08aed2011-07-01 19:47:50 +000048typedef const void
49 *(*GetVirtualMetacontentFromHandler)(const Image *);
50
51typedef Quantum
cristybb503372010-05-27 20:51:26 +000052 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
53 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000054
cristy4c08aed2011-07-01 19:47:50 +000055typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000056 *(*GetAuthenticPixelsFromHandler)(const Image *);
57
cristy4c08aed2011-07-01 19:47:50 +000058typedef Quantum
cristybb503372010-05-27 20:51:26 +000059 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
60 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000061
62typedef void
63 (*DestroyPixelHandler)(Image *);
64
cristy4c08aed2011-07-01 19:47:50 +000065typedef void
66 *(*GetAuthenticMetacontentFromHandler)(const Image *);
67
cristy3ed852e2009-09-05 21:47:34 +000068typedef struct _CacheMethods
69{
70 GetVirtualPixelHandler
71 get_virtual_pixel_handler;
72
73 GetVirtualPixelsHandler
74 get_virtual_pixels_handler;
75
cristy4c08aed2011-07-01 19:47:50 +000076 GetVirtualMetacontentFromHandler
77 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000078
79 GetOneVirtualPixelFromHandler
80 get_one_virtual_pixel_from_handler;
81
82 GetAuthenticPixelsHandler
83 get_authentic_pixels_handler;
84
cristy4c08aed2011-07-01 19:47:50 +000085 GetAuthenticMetacontentFromHandler
86 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000087
88 GetOneAuthenticPixelFromHandler
89 get_one_authentic_pixel_from_handler;
90
91 GetAuthenticPixelsFromHandler
92 get_authentic_pixels_from_handler;
93
94 QueueAuthenticPixelsHandler
95 queue_authentic_pixels_handler;
96
97 SyncAuthenticPixelsHandler
98 sync_authentic_pixels_handler;
99
100 DestroyPixelHandler
101 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000102} CacheMethods;
103
104typedef struct _NexusInfo
cristybb31fcd2013-01-15 20:06:37 +0000105 NexusInfo;
cristy3ed852e2009-09-05 21:47:34 +0000106
107typedef struct _CacheInfo
108{
109 ClassType
110 storage_class;
111
112 ColorspaceType
113 colorspace;
114
cristy8a46d822012-08-28 23:32:39 +0000115 PixelTrait
116 alpha_trait;
117
cristy222b19c2011-08-04 01:35:11 +0000118 MagickBooleanType
cristy183a5c72012-01-30 01:40:35 +0000119 mask;
cristy222b19c2011-08-04 01:35:11 +0000120
121 size_t
122 columns,
123 rows;
124
cristybcc1fdc2011-04-29 13:06:35 +0000125 size_t
cristy4c08aed2011-07-01 19:47:50 +0000126 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000127 number_channels;
cristy0d267172011-04-25 20:13:48 +0000128
cristy3dfccb22011-12-28 21:47:20 +0000129 PixelChannelMap
130 channel_map[MaxPixelChannels];
131
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
cristybb31fcd2013-01-15 20:06:37 +0000178 void
cristy0c682412013-01-18 14:14:13 +0000179 *server_info;
cristy286dea02013-01-08 21:34:16 +0000180
cristy3ed852e2009-09-05 21:47:34 +0000181 MagickBooleanType
cristyfa0ea942012-12-21 02:42:29 +0000182 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000183 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,
cristy245d4c52012-11-15 21:13:56 +0000193 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000194
cristyff1889f2012-05-08 18:38:44 +0000195 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 ClassType
cristy3ed852e2009-09-05 21:47:34 +0000209 GetPixelCacheStorageClass(const Cache);
210
cristy9c7a8792011-09-02 19:54:50 +0000211extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000212 GetPixelCacheColorspace(const Cache);
213
cristy9c7a8792011-09-02 19:54:50 +0000214extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000215 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
216 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000217 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000218 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
219
cristy9c7a8792011-09-02 19:54:50 +0000220extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000221 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000222 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000223
cristy9c7a8792011-09-02 19:54:50 +0000224extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000225 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000226 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
227 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000228 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000229
cristy9c7a8792011-09-02 19:54:50 +0000230extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000231 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
232
cristy9c7a8792011-09-02 19:54:50 +0000233extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000234 **AcquirePixelCacheNexus(const size_t),
235 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000236
cristy9c7a8792011-09-02 19:54:50 +0000237extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000238 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000239 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000240 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000241 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
242 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000243 ExceptionInfo *) magick_hot_spot;
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 *),
cristy387430f2012-02-07 13:09:46 +0000250 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000251
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),
cristy19596d62012-02-19 00:24:59 +0000255 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
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