cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 2 | Copyright 1999-2012 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 | cd01fae | 2011-08-06 23:52:42 +0000 | [diff] [blame] | 32 | typedef void |
| 33 | *Cache; |
| 34 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 35 | typedef MagickBooleanType |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 36 | (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t, |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 37 | Quantum *,ExceptionInfo *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 38 | (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod, |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 39 | const ssize_t,const ssize_t,Quantum *,ExceptionInfo *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 40 | (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *); |
| 41 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 42 | typedef const Quantum |
cristy | 5ed838e | 2010-05-31 00:05:35 +0000 | [diff] [blame] | 43 | *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod, |
| 44 | const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 45 | *(*GetVirtualPixelsHandler)(const Image *); |
| 46 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | typedef const void |
| 48 | *(*GetVirtualMetacontentFromHandler)(const Image *); |
| 49 | |
| 50 | typedef Quantum |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 51 | *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t, |
| 52 | const size_t,const size_t,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 53 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 54 | typedef Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 55 | *(*GetAuthenticPixelsFromHandler)(const Image *); |
| 56 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 57 | typedef Quantum |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 58 | *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t, |
| 59 | const size_t,const size_t,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 60 | |
| 61 | typedef void |
| 62 | (*DestroyPixelHandler)(Image *); |
| 63 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 64 | typedef void |
| 65 | *(*GetAuthenticMetacontentFromHandler)(const Image *); |
| 66 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | typedef struct _CacheMethods |
| 68 | { |
| 69 | GetVirtualPixelHandler |
| 70 | get_virtual_pixel_handler; |
| 71 | |
| 72 | GetVirtualPixelsHandler |
| 73 | get_virtual_pixels_handler; |
| 74 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 75 | GetVirtualMetacontentFromHandler |
| 76 | get_virtual_metacontent_from_handler; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 77 | |
| 78 | GetOneVirtualPixelFromHandler |
| 79 | get_one_virtual_pixel_from_handler; |
| 80 | |
| 81 | GetAuthenticPixelsHandler |
| 82 | get_authentic_pixels_handler; |
| 83 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 84 | GetAuthenticMetacontentFromHandler |
| 85 | get_authentic_metacontent_from_handler; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 86 | |
| 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; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 101 | } CacheMethods; |
| 102 | |
| 103 | typedef struct _NexusInfo |
| 104 | NexusInfo; |
| 105 | |
| 106 | typedef struct _CacheInfo |
| 107 | { |
| 108 | ClassType |
| 109 | storage_class; |
| 110 | |
| 111 | ColorspaceType |
| 112 | colorspace; |
| 113 | |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 114 | PixelTrait |
| 115 | alpha_trait; |
| 116 | |
cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 117 | MagickBooleanType |
cristy | 183a5c7 | 2012-01-30 01:40:35 +0000 | [diff] [blame] | 118 | mask; |
cristy | 222b19c | 2011-08-04 01:35:11 +0000 | [diff] [blame] | 119 | |
| 120 | size_t |
| 121 | columns, |
| 122 | rows; |
| 123 | |
cristy | bcc1fdc | 2011-04-29 13:06:35 +0000 | [diff] [blame] | 124 | size_t |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 125 | metacontent_extent, |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 126 | number_channels; |
cristy | 0d26717 | 2011-04-25 20:13:48 +0000 | [diff] [blame] | 127 | |
cristy | 3dfccb2 | 2011-12-28 21:47:20 +0000 | [diff] [blame] | 128 | PixelChannelMap |
| 129 | channel_map[MaxPixelChannels]; |
| 130 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 131 | CacheType |
| 132 | type; |
| 133 | |
cristy | 87528ea | 2009-09-10 14:53:56 +0000 | [diff] [blame] | 134 | MapMode |
| 135 | mode; |
| 136 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 137 | MagickBooleanType |
| 138 | mapped; |
| 139 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 140 | MagickOffsetType |
| 141 | offset; |
| 142 | |
| 143 | MagickSizeType |
| 144 | length; |
| 145 | |
| 146 | VirtualPixelMethod |
| 147 | virtual_pixel_method; |
| 148 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 149 | PixelInfo |
cristy | c3ec0d4 | 2010-04-07 01:18:08 +0000 | [diff] [blame] | 150 | virtual_pixel_color; |
| 151 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 152 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | number_threads; |
| 154 | |
| 155 | NexusInfo |
| 156 | **nexus_info; |
| 157 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 158 | Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 159 | *pixels; |
| 160 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 161 | void |
| 162 | *metacontent; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 163 | |
| 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 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 183 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 184 | reference_count; |
| 185 | |
| 186 | SemaphoreInfo |
| 187 | *semaphore, |
| 188 | *disk_semaphore; |
| 189 | |
cristy | ff1889f | 2012-05-08 18:38:44 +0000 | [diff] [blame] | 190 | time_t |
| 191 | timestamp; |
| 192 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 193 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 194 | signature; |
| 195 | } CacheInfo; |
| 196 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 197 | extern MagickPrivate Cache |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 198 | AcquirePixelCache(const size_t), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 199 | ClonePixelCache(const Cache), |
| 200 | DestroyPixelCache(Cache), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 201 | ReferencePixelCache(Cache); |
| 202 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 203 | extern MagickPrivate ClassType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 204 | GetPixelCacheStorageClass(const Cache); |
| 205 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 206 | extern MagickPrivate ColorspaceType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 207 | GetPixelCacheColorspace(const Cache); |
| 208 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 209 | extern MagickPrivate const Quantum |
cristy | 5ed838e | 2010-05-31 00:05:35 +0000 | [diff] [blame] | 210 | *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod, |
| 211 | const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *, |
cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 212 | ExceptionInfo *) magick_hot_spot, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 213 | *GetVirtualPixelsNexus(const Cache,NexusInfo *); |
| 214 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 215 | extern MagickPrivate const void |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 216 | *AcquirePixelCachePixels(const Image *,MagickSizeType *,ExceptionInfo *), |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 217 | *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 218 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 219 | extern MagickPrivate MagickBooleanType |
cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 220 | CacheComponentGenesis(void), |
cristy | e41d079 | 2012-04-04 00:49:50 +0000 | [diff] [blame] | 221 | SyncAuthenticPixelCacheNexus(Image *,NexusInfo *,ExceptionInfo *) |
| 222 | magick_hot_spot, |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 223 | SyncImagePixelCache(Image *,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 224 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 225 | extern MagickPrivate MagickSizeType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 226 | GetPixelCacheNexusExtent(const Cache,NexusInfo *); |
| 227 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 228 | extern MagickPrivate NexusInfo |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 229 | **AcquirePixelCacheNexus(const size_t), |
| 230 | **DestroyPixelCacheNexus(NexusInfo **,const size_t); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 231 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 232 | extern MagickPrivate Quantum |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 233 | *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t, |
cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 234 | const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 235 | *GetPixelCacheNexusPixels(const Cache,NexusInfo *), |
cristy | c11dace | 2012-01-24 16:39:46 +0000 | [diff] [blame] | 236 | *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t, |
| 237 | const size_t,const size_t,const MagickBooleanType,NexusInfo *, |
cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 238 | ExceptionInfo *) magick_hot_spot; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 239 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 240 | extern MagickPrivate size_t |
cristy | 0d26717 | 2011-04-25 20:13:48 +0000 | [diff] [blame] | 241 | GetPixelCacheChannels(const Cache); |
| 242 | |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 243 | extern MagickPrivate VirtualPixelMethod |
| 244 | GetPixelCacheVirtualMethod(const Image *), |
cristy | 387430f | 2012-02-07 13:09:46 +0000 | [diff] [blame] | 245 | SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *); |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 246 | |
cristy | 9c7a879 | 2011-09-02 19:54:50 +0000 | [diff] [blame] | 247 | extern MagickPrivate void |
cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 248 | CacheComponentTerminus(void), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 249 | ClonePixelCacheMethods(Cache,const Cache), |
cristy | 19596d6 | 2012-02-19 00:24:59 +0000 | [diff] [blame] | 250 | *GetPixelCacheNexusMetacontent(const Cache,NexusInfo *) magick_hot_spot, |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 251 | *GetPixelCachePixels(Image *,MagickSizeType *,ExceptionInfo *), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 252 | GetPixelCacheTileSize(const Image *,size_t *,size_t *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 253 | GetPixelCacheMethods(CacheMethods *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 254 | SetPixelCacheMethods(Cache,CacheMethods *); |
| 255 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 256 | #if defined(__cplusplus) || defined(c_plusplus) |
| 257 | } |
| 258 | #endif |
| 259 | |
| 260 | #endif |