| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| cristy | 45ef08f | 2012-12-07 13:13:34 +0000 | [diff] [blame] | 2 | Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3 | dedicated to making software imaging solutions freely available. |
| cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 4 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5 | You may not use this file except in compliance with the License. |
| 6 | obtain a copy of the License at |
| cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 7 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8 | http://www.imagemagick.org/script/license.php |
| cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 9 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 10 | 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) |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | #include <time.h> |
| cristy | 4ee2b0c | 2012-05-15 00:30:35 +0000 | [diff] [blame] | 26 | #include "MagickCore/cache.h" |
| cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 27 | #include "MagickCore/pixel.h" |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 28 | #include "MagickCore/random_.h" |
| 29 | #include "MagickCore/thread-private.h" |
| 30 | #include "MagickCore/semaphore.h" |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 31 | |
| cristy | 286dea0 | 2013-01-08 21:34:16 +0000 | [diff] [blame^] | 32 | #define MaxNumberDistributedCacheClients 32 |
| 33 | |
| cristy | cd01fae | 2011-08-06 23:52:42 +0000 | [diff] [blame] | 34 | typedef void |
| 35 | *Cache; |
| 36 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 37 | typedef MagickBooleanType |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 38 | (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t, |
| cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 39 | Quantum *,ExceptionInfo *), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 40 | (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod, |
| cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 41 | const ssize_t,const ssize_t,Quantum *,ExceptionInfo *), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 42 | (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *); |
| 43 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 44 | typedef const Quantum |
| cristy | 5ed838e | 2010-05-31 00:05:35 +0000 | [diff] [blame] | 45 | *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod, |
| 46 | const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 47 | *(*GetVirtualPixelsHandler)(const Image *); |
| 48 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 49 | typedef const void |
| 50 | *(*GetVirtualMetacontentFromHandler)(const Image *); |
| 51 | |
| 52 | typedef Quantum |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 53 | *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t, |
| 54 | const size_t,const size_t,ExceptionInfo *); |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 55 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 56 | typedef Quantum |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 57 | *(*GetAuthenticPixelsFromHandler)(const Image *); |
| 58 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 59 | typedef Quantum |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 60 | *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t, |
| 61 | const size_t,const size_t,ExceptionInfo *); |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 62 | |
| 63 | typedef void |
| 64 | (*DestroyPixelHandler)(Image *); |
| 65 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 66 | typedef void |
| 67 | *(*GetAuthenticMetacontentFromHandler)(const Image *); |
| 68 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 69 | typedef struct _CacheMethods |
| 70 | { |
| 71 | GetVirtualPixelHandler |
| 72 | get_virtual_pixel_handler; |
| 73 | |
| 74 | GetVirtualPixelsHandler |
| 75 | get_virtual_pixels_handler; |
| 76 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 77 | GetVirtualMetacontentFromHandler |
| 78 | get_virtual_metacontent_from_handler; |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 79 | |
| 80 | GetOneVirtualPixelFromHandler |
| 81 | get_one_virtual_pixel_from_handler; |
| 82 | |
| 83 | GetAuthenticPixelsHandler |
| 84 | get_authentic_pixels_handler; |
| 85 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 86 | GetAuthenticMetacontentFromHandler |
| 87 | get_authentic_metacontent_from_handler; |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 88 | |
| 89 | GetOneAuthenticPixelFromHandler |
| 90 | get_one_authentic_pixel_from_handler; |
| 91 | |
| 92 | GetAuthenticPixelsFromHandler |
| 93 | get_authentic_pixels_from_handler; |
| 94 | |
| 95 | QueueAuthenticPixelsHandler |
| 96 | queue_authentic_pixels_handler; |
| 97 | |
| 98 | SyncAuthenticPixelsHandler |
| 99 | sync_authentic_pixels_handler; |
| 100 | |
| 101 | DestroyPixelHandler |
| 102 | destroy_pixel_handler; |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 103 | } CacheMethods; |
| 104 | |
| cristy | 286dea0 | 2013-01-08 21:34:16 +0000 | [diff] [blame^] | 105 | typedef struct _DistributedCacheInfo |
| 106 | { |
| 107 | #if defined(MAGICKCORE_HAVE_SOCKET) |
| 108 | int |
| 109 | server; |
| 110 | #endif |
| 111 | |
| 112 | size_t |
| 113 | session; |
| 114 | } DistributedCacheInfo; |
| 115 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 116 | typedef struct _NexusInfo |
| 117 | NexusInfo; |
| 118 | |
| 119 | typedef struct _CacheInfo |
| 120 | { |
| 121 | ClassType |
| 122 | storage_class; |
| 123 | |
| 124 | ColorspaceType |
| 125 | colorspace; |
| 126 | |
| cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 127 | PixelTrait |
| 128 | alpha_trait; |
| 129 | |
| cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 130 | MagickBooleanType |
| cristy | 183a5c7 | 2012-01-30 01:40:35 +0000 | [diff] [blame] | 131 | mask; |
| cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 132 | |
| 133 | size_t |
| 134 | columns, |
| 135 | rows; |
| 136 | |
| cristy | bcc1fdc | 2011-04-29 13:06:35 +0000 | [diff] [blame] | 137 | size_t |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 138 | metacontent_extent, |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 139 | number_channels; |
| cristy | 0d26717 | 2011-04-25 20:13:48 +0000 | [diff] [blame] | 140 | |
| cristy | 3dfccb2 | 2011-12-28 21:47:20 +0000 | [diff] [blame] | 141 | PixelChannelMap |
| 142 | channel_map[MaxPixelChannels]; |
| 143 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 144 | CacheType |
| 145 | type; |
| 146 | |
| cristy | 87528ea | 2009-09-10 14:53:56 +0000 | [diff] [blame] | 147 | MapMode |
| 148 | mode; |
| 149 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 150 | MagickBooleanType |
| 151 | mapped; |
| 152 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | MagickOffsetType |
| 154 | offset; |
| 155 | |
| 156 | MagickSizeType |
| 157 | length; |
| 158 | |
| 159 | VirtualPixelMethod |
| 160 | virtual_pixel_method; |
| 161 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 162 | PixelInfo |
| cristy | c3ec0d4 | 2010-04-07 01:18:08 +0000 | [diff] [blame] | 163 | virtual_pixel_color; |
| 164 | |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 165 | size_t |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 166 | number_threads; |
| 167 | |
| 168 | NexusInfo |
| 169 | **nexus_info; |
| 170 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 171 | Quantum |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 172 | *pixels; |
| 173 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 174 | void |
| 175 | *metacontent; |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 176 | |
| 177 | int |
| 178 | file; |
| 179 | |
| 180 | char |
| 181 | filename[MaxTextExtent], |
| 182 | cache_filename[MaxTextExtent]; |
| 183 | |
| 184 | CacheMethods |
| 185 | methods; |
| 186 | |
| 187 | RandomInfo |
| 188 | *random_info; |
| 189 | |
| cristy | 286dea0 | 2013-01-08 21:34:16 +0000 | [diff] [blame^] | 190 | ssize_t |
| 191 | number_connections; |
| 192 | |
| 193 | DistributedCacheInfo |
| 194 | connection[MaxNumberDistributedCacheClients]; |
| 195 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 196 | MagickBooleanType |
| cristy | fa0ea94 | 2012-12-21 02:42:29 +0000 | [diff] [blame] | 197 | synchronize, |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 198 | debug; |
| 199 | |
| 200 | MagickThreadType |
| 201 | id; |
| 202 | |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 203 | ssize_t |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 204 | reference_count; |
| 205 | |
| 206 | SemaphoreInfo |
| 207 | *semaphore, |
| cristy | 245d4c5 | 2012-11-15 21:13:56 +0000 | [diff] [blame] | 208 | *file_semaphore; |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 209 | |
| cristy | ff1889f | 2012-05-08 18:38:44 +0000 | [diff] [blame] | 210 | time_t |
| 211 | timestamp; |
| 212 | |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 213 | size_t |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 214 | signature; |
| 215 | } CacheInfo; |
| 216 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 217 | extern MagickPrivate Cache |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 218 | AcquirePixelCache(const size_t), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 219 | ClonePixelCache(const Cache), |
| 220 | DestroyPixelCache(Cache), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 221 | ReferencePixelCache(Cache); |
| 222 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 223 | extern MagickPrivate ClassType |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 224 | GetPixelCacheStorageClass(const Cache); |
| 225 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 226 | extern MagickPrivate ColorspaceType |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 227 | GetPixelCacheColorspace(const Cache); |
| 228 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 229 | extern MagickPrivate const Quantum |
| cristy | 5ed838e | 2010-05-31 00:05:35 +0000 | [diff] [blame] | 230 | *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod, |
| 231 | const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *, |
| cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 232 | ExceptionInfo *) magick_hot_spot, |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 233 | *GetVirtualPixelsNexus(const Cache,NexusInfo *); |
| 234 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 235 | extern MagickPrivate const void |
| cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 236 | *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *), |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 237 | *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *); |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 238 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 239 | extern MagickPrivate MagickBooleanType |
| cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 240 | CacheComponentGenesis(void), |
| cristy | e41d079 | 2012-04-04 00:49:50 +0000 | [diff] [blame] | 241 | SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *) |
| 242 | magick_hot_spot, |
| cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 243 | SyncImagePixelCache(Image *,ExceptionInfo *); |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 244 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 245 | extern MagickPrivate MagickSizeType |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 246 | GetPixelCacheNexusExtent(const Cache,NexusInfo *); |
| 247 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 248 | extern MagickPrivate NexusInfo |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 249 | **AcquirePixelCacheNexus(const size_t), |
| 250 | **DestroyPixelCacheNexus(NexusInfo **,const size_t); |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 251 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 252 | extern MagickPrivate Quantum |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 253 | *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t, |
| cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 254 | const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot, |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 255 | *GetPixelCacheNexusPixels(const Cache,NexusInfo *), |
| cristy | c11dace | 2012-01-24 16:39:46 +0000 | [diff] [blame] | 256 | *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t, |
| 257 | const size_t,const size_t,const MagickBooleanType,NexusInfo *, |
| cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 258 | ExceptionInfo *) magick_hot_spot; |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 259 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 260 | extern MagickPrivate size_t |
| cristy | 0d26717 | 2011-04-25 20:13:48 +0000 | [diff] [blame] | 261 | GetPixelCacheChannels(const Cache); |
| 262 | |
| cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 263 | extern MagickPrivate VirtualPixelMethod |
| 264 | GetPixelCacheVirtualMethod(const Image *), |
| cristy | 387430f | 2012-02-07 13:09:46 +0000 | [diff] [blame] | 265 | SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *); |
| cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 266 | |
| cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 267 | extern MagickPrivate void |
| cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 268 | CacheComponentTerminus(void), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 269 | ClonePixelCacheMethods(Cache,const Cache), |
| cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 270 | *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot, |
| cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 271 | *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *), |
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 272 | GetPixelCacheTileSize(const Image *,size_t *,size_t *), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 273 | GetPixelCacheMethods(CacheMethods *), |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 274 | SetPixelCacheMethods(Cache,CacheMethods *); |
| 275 | |
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 276 | #if defined(__cplusplus) || defined(c_plusplus) |
| 277 | } |
| 278 | #endif |
| 279 | |
| 280 | #endif |