blob: e5b6bf337a1d5635dad73f410a84e9de1a0fc57d [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"
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
cristyfa0ea942012-12-21 02:42:29 +0000178 synchronize,
cristy3ed852e2009-09-05 21:47:34 +0000179 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,
cristy245d4c52012-11-15 21:13:56 +0000189 *file_semaphore;
cristy3ed852e2009-09-05 21:47:34 +0000190
cristyff1889f2012-05-08 18:38:44 +0000191 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 ClassType
cristy3ed852e2009-09-05 21:47:34 +0000205 GetPixelCacheStorageClass(const Cache);
206
cristy9c7a8792011-09-02 19:54:50 +0000207extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000208 GetPixelCacheColorspace(const Cache);
209
cristy9c7a8792011-09-02 19:54:50 +0000210extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000211 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
212 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000213 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000214 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
215
cristy9c7a8792011-09-02 19:54:50 +0000216extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000217 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000218 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000219
cristy9c7a8792011-09-02 19:54:50 +0000220extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000221 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000222 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
223 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000224 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000225
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,
cristy19596d62012-02-19 00:24:59 +0000235 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000236 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000237 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
238 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000239 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000240
cristy9c7a8792011-09-02 19:54:50 +0000241extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000242 GetPixelCacheChannels(const Cache);
243
cristyd1dd6e42011-09-04 01:46:08 +0000244extern MagickPrivate VirtualPixelMethod
245 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000246 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000247
cristy9c7a8792011-09-02 19:54:50 +0000248extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000249 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000250 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000251 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000252 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000253 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000254 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000255 SetPixelCacheMethods(Cache,CacheMethods *);
256
cristy3ed852e2009-09-05 21:47:34 +0000257#if defined(__cplusplus) || defined(c_plusplus)
258}
259#endif
260
261#endif