blob: 71d6768084105b23670093af896e9adfc4bd767e [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
cristycd01fae2011-08-06 23:52:42 +000031typedef void
32 *Cache;
33
cristy3ed852e2009-09-05 21:47:34 +000034typedef MagickBooleanType
cristybb503372010-05-27 20:51:26 +000035 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
cristy2ed42f62011-10-02 19:49:57 +000036 Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000037 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
cristy2ed42f62011-10-02 19:49:57 +000038 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000039 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
40
cristy4c08aed2011-07-01 19:47:50 +000041typedef const Quantum
cristy5ed838e2010-05-31 00:05:35 +000042 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,
43 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +000044 *(*GetVirtualPixelsHandler)(const Image *);
45
cristy4c08aed2011-07-01 19:47:50 +000046typedef const void
47 *(*GetVirtualMetacontentFromHandler)(const Image *);
48
49typedef Quantum
cristybb503372010-05-27 20:51:26 +000050 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
51 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000052
cristy4c08aed2011-07-01 19:47:50 +000053typedef Quantum
cristy3ed852e2009-09-05 21:47:34 +000054 *(*GetAuthenticPixelsFromHandler)(const Image *);
55
cristy4c08aed2011-07-01 19:47:50 +000056typedef Quantum
cristybb503372010-05-27 20:51:26 +000057 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
58 const size_t,const size_t,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000059
60typedef void
61 (*DestroyPixelHandler)(Image *);
62
cristy4c08aed2011-07-01 19:47:50 +000063typedef void
64 *(*GetAuthenticMetacontentFromHandler)(const Image *);
65
cristy3ed852e2009-09-05 21:47:34 +000066typedef struct _CacheMethods
67{
68 GetVirtualPixelHandler
69 get_virtual_pixel_handler;
70
71 GetVirtualPixelsHandler
72 get_virtual_pixels_handler;
73
cristy4c08aed2011-07-01 19:47:50 +000074 GetVirtualMetacontentFromHandler
75 get_virtual_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000076
77 GetOneVirtualPixelFromHandler
78 get_one_virtual_pixel_from_handler;
79
80 GetAuthenticPixelsHandler
81 get_authentic_pixels_handler;
82
cristy4c08aed2011-07-01 19:47:50 +000083 GetAuthenticMetacontentFromHandler
84 get_authentic_metacontent_from_handler;
cristy3ed852e2009-09-05 21:47:34 +000085
86 GetOneAuthenticPixelFromHandler
87 get_one_authentic_pixel_from_handler;
88
89 GetAuthenticPixelsFromHandler
90 get_authentic_pixels_from_handler;
91
92 QueueAuthenticPixelsHandler
93 queue_authentic_pixels_handler;
94
95 SyncAuthenticPixelsHandler
96 sync_authentic_pixels_handler;
97
98 DestroyPixelHandler
99 destroy_pixel_handler;
cristy3ed852e2009-09-05 21:47:34 +0000100} CacheMethods;
101
102typedef struct _NexusInfo
103 NexusInfo;
104
105typedef struct _CacheInfo
106{
107 ClassType
108 storage_class;
109
110 ColorspaceType
111 colorspace;
112
cristy222b19c2011-08-04 01:35:11 +0000113 MagickBooleanType
cristy10a6c612012-01-29 21:41:05 +0000114 matte,
cristy183a5c72012-01-30 01:40:35 +0000115 mask;
cristy222b19c2011-08-04 01:35:11 +0000116
117 size_t
118 columns,
119 rows;
120
cristybcc1fdc2011-04-29 13:06:35 +0000121 size_t
cristy4c08aed2011-07-01 19:47:50 +0000122 metacontent_extent,
cristyed231572011-07-14 02:18:59 +0000123 number_channels;
cristy0d267172011-04-25 20:13:48 +0000124
cristy3dfccb22011-12-28 21:47:20 +0000125 PixelChannelMap
126 channel_map[MaxPixelChannels];
127
cristy3ed852e2009-09-05 21:47:34 +0000128 CacheType
129 type;
130
cristy87528ea2009-09-10 14:53:56 +0000131 MapMode
132 mode;
133
cristy3ed852e2009-09-05 21:47:34 +0000134 MagickBooleanType
135 mapped;
136
cristy3ed852e2009-09-05 21:47:34 +0000137 MagickOffsetType
138 offset;
139
140 MagickSizeType
141 length;
142
143 VirtualPixelMethod
144 virtual_pixel_method;
145
cristy4c08aed2011-07-01 19:47:50 +0000146 PixelInfo
cristyc3ec0d42010-04-07 01:18:08 +0000147 virtual_pixel_color;
148
cristybb503372010-05-27 20:51:26 +0000149 size_t
cristy3ed852e2009-09-05 21:47:34 +0000150 number_threads;
151
152 NexusInfo
153 **nexus_info;
154
cristy4c08aed2011-07-01 19:47:50 +0000155 Quantum
cristy3ed852e2009-09-05 21:47:34 +0000156 *pixels;
157
cristy4c08aed2011-07-01 19:47:50 +0000158 void
159 *metacontent;
cristy3ed852e2009-09-05 21:47:34 +0000160
161 int
162 file;
163
164 char
165 filename[MaxTextExtent],
166 cache_filename[MaxTextExtent];
167
168 CacheMethods
169 methods;
170
171 RandomInfo
172 *random_info;
173
174 MagickBooleanType
175 debug;
176
177 MagickThreadType
178 id;
179
cristybb503372010-05-27 20:51:26 +0000180 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000181 reference_count;
182
183 SemaphoreInfo
184 *semaphore,
185 *disk_semaphore;
186
cristyff1889f2012-05-08 18:38:44 +0000187 time_t
188 timestamp;
189
cristybb503372010-05-27 20:51:26 +0000190 size_t
cristy3ed852e2009-09-05 21:47:34 +0000191 signature;
192} CacheInfo;
193
cristy9c7a8792011-09-02 19:54:50 +0000194extern MagickPrivate Cache
cristybb503372010-05-27 20:51:26 +0000195 AcquirePixelCache(const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000196 ClonePixelCache(const Cache),
197 DestroyPixelCache(Cache),
cristy3ed852e2009-09-05 21:47:34 +0000198 ReferencePixelCache(Cache);
199
cristy9c7a8792011-09-02 19:54:50 +0000200extern MagickPrivate ClassType
cristy3ed852e2009-09-05 21:47:34 +0000201 GetPixelCacheStorageClass(const Cache);
202
cristy9c7a8792011-09-02 19:54:50 +0000203extern MagickPrivate ColorspaceType
cristy3ed852e2009-09-05 21:47:34 +0000204 GetPixelCacheColorspace(const Cache);
205
cristy9c7a8792011-09-02 19:54:50 +0000206extern MagickPrivate const Quantum
cristy5ed838e2010-05-31 00:05:35 +0000207 *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,
208 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000209 ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000210 *GetVirtualPixelsNexus(const Cache,NexusInfo *);
211
cristy9c7a8792011-09-02 19:54:50 +0000212extern MagickPrivate const void
cristyd1dd6e42011-09-04 01:46:08 +0000213 *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000214 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000215
cristy9c7a8792011-09-02 19:54:50 +0000216extern MagickPrivate MagickBooleanType
cristy5ff4eaf2011-09-03 01:38:02 +0000217 CacheComponentGenesis(void),
cristye41d0792012-04-04 00:49:50 +0000218 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *)
219 magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000220 SyncImagePixelCache(Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000221
cristy9c7a8792011-09-02 19:54:50 +0000222extern MagickPrivate MagickSizeType
cristy3ed852e2009-09-05 21:47:34 +0000223 GetPixelCacheNexusExtent(const Cache,NexusInfo *);
224
cristy9c7a8792011-09-02 19:54:50 +0000225extern MagickPrivate NexusInfo
cristybb503372010-05-27 20:51:26 +0000226 **AcquirePixelCacheNexus(const size_t),
227 **DestroyPixelCacheNexus(NexusInfo **,const size_t);
cristy3ed852e2009-09-05 21:47:34 +0000228
cristy9c7a8792011-09-02 19:54:50 +0000229extern MagickPrivate Quantum
cristybb503372010-05-27 20:51:26 +0000230 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
cristy19596d62012-02-19 00:24:59 +0000231 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot,
cristy3ed852e2009-09-05 21:47:34 +0000232 *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
cristyc11dace2012-01-24 16:39:46 +0000233 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
234 const size_t,const size_t,const MagickBooleanType,NexusInfo *,
cristy19596d62012-02-19 00:24:59 +0000235 ExceptionInfo *) magick_hot_spot;
cristy3ed852e2009-09-05 21:47:34 +0000236
cristy9c7a8792011-09-02 19:54:50 +0000237extern MagickPrivate size_t
cristy0d267172011-04-25 20:13:48 +0000238 GetPixelCacheChannels(const Cache);
239
cristyd1dd6e42011-09-04 01:46:08 +0000240extern MagickPrivate VirtualPixelMethod
241 GetPixelCacheVirtualMethod(const Image *),
cristy387430f2012-02-07 13:09:46 +0000242 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
cristyd1dd6e42011-09-04 01:46:08 +0000243
cristy9c7a8792011-09-02 19:54:50 +0000244extern MagickPrivate void
cristy5ff4eaf2011-09-03 01:38:02 +0000245 CacheComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000246 ClonePixelCacheMethods(Cache,const Cache),
cristy19596d62012-02-19 00:24:59 +0000247 *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot,
cristyd1dd6e42011-09-04 01:46:08 +0000248 *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *),
cristybb503372010-05-27 20:51:26 +0000249 GetPixelCacheTileSize(const Image *,size_t *,size_t *),
cristy3ed852e2009-09-05 21:47:34 +0000250 GetPixelCacheMethods(CacheMethods *),
cristy3ed852e2009-09-05 21:47:34 +0000251 SetPixelCacheMethods(Cache,CacheMethods *);
252
cristy3ed852e2009-09-05 21:47:34 +0000253#if defined(__cplusplus) || defined(c_plusplus)
254}
255#endif
256
257#endif