blob: 2fc090edb0a870c147ad3a14be4ec1c13251a4ea [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"
cristy8a46d822012-08-28 23:32:39 +000027#include "MagickCore/pixel.h"
cristy4c08aed2011-07-01 19:47:50 +000028#include "MagickCore/random_.h"
29#include "MagickCore/thread-private.h"
30#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000031
cristycd01fae2011-08-06 23:52:42 +000032typedef void
33 *Cache;
34
cristy3ed852e2009-09-05 21:47:34 +000035typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000036 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000037 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000038 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000039 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000040 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
41
cristy4c08aed2011-07-01 19:47:50 +000042typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000043 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
44 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000045 *(*GetVirtualPixelsHandler)(const Image *);
46
cristy4c08aed2011-07-01 19:47:50 +000047typedef const void
48 *(*GetVirtualMetacontentFromHandler)(const Image *);
49
50typedef Quantum
cristybb503372010-05-27 20:51:26 +000051 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
52 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000053
cristy4c08aed2011-07-01 19:47:50 +000054typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000055 *(*GetAuthenticPixelsFromHandler)(const Image *);
56
cristy4c08aed2011-07-01 19:47:50 +000057typedef Quantum
cristybb503372010-05-27 20:51:26 +000058 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
59 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000060
61typedef void
62 (*DestroyPixelHandler)(Image *);
63
cristy4c08aed2011-07-01 19:47:50 +000064typedef void
65 *(*GetAuthenticMetacontentFromHandler)(const Image *);
66
cristy3ed852e2009-09-05 21:47:34 +000067typedef struct _CacheMethods
68{
69 GetVirtualPixelHandler
70 get_virtual_pixel_handler;
71
72 GetVirtualPixelsHandler
73 get_virtual_pixels_handler;
74
cristy4c08aed2011-07-01 19:47:50 +000075 GetVirtualMetacontentFromHandler
76 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000077
78 GetOneVirtualPixelFromHandler
79 get_one_virtual_pixel_from_handler;
80
81 GetAuthenticPixelsHandler
82 get_authentic_pixels_handler;
83
cristy4c08aed2011-07-01 19:47:50 +000084 GetAuthenticMetacontentFromHandler
85 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000086
87 GetOneAuthenticPixelFromHandler
88 get_one_authentic_pixel_from_handler;
89
90 GetAuthenticPixelsFromHandler
91 get_authentic_pixels_from_handler;
92
93 QueueAuthenticPixelsHandler
94 queue_authentic_pixels_handler;
95
96 SyncAuthenticPixelsHandler
97 sync_authentic_pixels_handler;
98
99 DestroyPixelHandler
100 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000101} CacheMethods;
102
103typedef struct _NexusInfo
104 NexusInfo;
105
106typedef struct _CacheInfo
107{
108 ClassType
109 storage_class;
110
111 ColorspaceType
112 colorspace;
113
cristy8a46d822012-08-28 23:32:39 +0000114 PixelTrait
115 alpha_trait;
116
cristy222b19c2011-08-04 01:35:11 +0000117 MagickBooleanType
cristy183a5c72012-01-30 01:40:35 +0000118 mask;
cristy222b19c2011-08-04 01:35:11 +0000119
120 size_t
121 columns,
122 rows;
123
cristybcc1fdc2011-04-29 13:06:35 +0000124 size_t
cristy4c08aed2011-07-01 19:47:50 +0000125 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000126 number_channels;
cristy0d267172011-04-25 20:13:48 +0000127
cristy3dfccb22011-12-28 21:47:20 +0000128 PixelChannelMap
129 channel_map[MaxPixelChannels];
130
cristy3ed852e2009-09-05 21:47:34 +0000131 CacheType
132 type;
133
cristy87528ea2009-09-10 14:53:56 +0000134 MapMode
135 mode;
136
cristy3ed852e2009-09-05 21:47:34 +0000137 MagickBooleanType
138 mapped;
139
cristy3ed852e2009-09-05 21:47:34 +0000140 MagickOffsetType
141 offset;
142
143 MagickSizeType
144 length;
145
146 VirtualPixelMethod
147 virtual_pixel_method;
148
cristy4c08aed2011-07-01 19:47:50 +0000149 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000150 virtual_pixel_color;
151
cristybb503372010-05-27 20:51:26 +0000152 size_t
cristy3ed852e2009-09-05 21:47:34 +0000153 number_threads;
154
155 NexusInfo
156 **nexus_info;
157
cristy4c08aed2011-07-01 19:47:50 +0000158 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000159 *pixels;
160
cristy4c08aed2011-07-01 19:47:50 +0000161 void
162 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000163
164 int
165 file;
166
167 char
168 filename[MaxTextExtent],
169 cache_filename[MaxTextExtent];
170
171 CacheMethods
172 methods;
173
174 RandomInfo
175 *random_info;
176
177 MagickBooleanType
178 debug;
179
180 MagickThreadType
181 id;
182
cristybb503372010-05-27 20:51:26 +0000183 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000184 reference_count;
185
186 SemaphoreInfo
187 *semaphore,
188 *disk_semaphore;
189
cristyff1889f2012-05-08 18:38:44 +0000190 time_t
191 timestamp;
192
cristybb503372010-05-27 20:51:26 +0000193 size_t
cristy3ed852e2009-09-05 21:47:34 +0000194 signature;
195} CacheInfo;
196
cristy9c7a8792011-09-02 19:54:50 +0000197extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000198 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000199 ClonePixelCache(const Cache),
200 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000201 ReferencePixelCache(Cache);
202
cristy9c7a8792011-09-02 19:54:50 +0000203extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000204 GetPixelCacheStorageClass(const Cache);
205
cristy9c7a8792011-09-02 19:54:50 +0000206extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000207 GetPixelCacheColorspace(const Cache);
208
cristy9c7a8792011-09-02 19:54:50 +0000209extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000210 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
211 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000212 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000213 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
214
cristy9c7a8792011-09-02 19:54:50 +0000215extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000216 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000217 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000218
cristy9c7a8792011-09-02 19:54:50 +0000219extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000220 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000221 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
222 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000223 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000224
cristy9c7a8792011-09-02 19:54:50 +0000225extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000226 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
227
cristy9c7a8792011-09-02 19:54:50 +0000228extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000229 **AcquirePixelCacheNexus(const size_t),
230 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000231
cristy9c7a8792011-09-02 19:54:50 +0000232extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000233 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000234 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000235 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000236 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
237 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000238 ExceptionInfo *) magick_hot_spot;
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
cristyd1dd6e42011-09-04 01:46:08 +0000243extern MagickPrivate VirtualPixelMethod
244 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000245 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000246
cristy9c7a8792011-09-02 19:54:50 +0000247extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000248 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000249 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000250 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000251 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000252 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000253 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000254 SetPixelCacheMethods(Cache,CacheMethods *);
255
cristy3ed852e2009-09-05 21:47:34 +0000256#if defined(__cplusplus) || defined(c_plusplus)
257}
258#endif
259
260#endif