1 /* 2 Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization 3 dedicated to making software imaging solutions freely available. 4 5 You may not use this file except in compliance with the License. You may 6 obtain a copy of the License at 7 8 https://imagemagick.org/script/license.php 9 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 #include "MagickCore/cache.h" 22 #include "MagickCore/distribute-cache.h" 23 #include "MagickCore/opencl-private.h" 24 #include "MagickCore/pixel.h" 25 #include "MagickCore/random_.h" 26 #include "MagickCore/thread-private.h" 27 #include "MagickCore/semaphore.h" 28 29 #if defined(__cplusplus) || defined(c_plusplus) 30 extern "C" { 31 #endif 32 33 typedef void 34 *Cache; 35 36 typedef MagickBooleanType 37 (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t, 38 Quantum *,ExceptionInfo *), 39 (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod, 40 const ssize_t,const ssize_t,Quantum *,ExceptionInfo *), 41 (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *); 42 43 typedef const Quantum 44 *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod, 45 const ssize_t,const ssize_t,const size_t,const size_t,ExceptionInfo *), 46 *(*GetVirtualPixelsHandler)(const Image *); 47 48 typedef const void 49 *(*GetVirtualMetacontentFromHandler)(const Image *); 50 51 typedef Quantum 52 *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t, 53 const size_t,const size_t,ExceptionInfo *); 54 55 typedef Quantum 56 *(*GetAuthenticPixelsFromHandler)(const Image *); 57 58 typedef Quantum 59 *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t, 60 const size_t,const size_t,ExceptionInfo *); 61 62 typedef void 63 (*DestroyPixelHandler)(Image *); 64 65 typedef void 66 *(*GetAuthenticMetacontentFromHandler)(const Image *); 67 68 typedef struct _CacheMethods 69 { 70 GetVirtualPixelHandler 71 get_virtual_pixel_handler; 72 73 GetVirtualPixelsHandler 74 get_virtual_pixels_handler; 75 76 GetVirtualMetacontentFromHandler 77 get_virtual_metacontent_from_handler; 78 79 GetOneVirtualPixelFromHandler 80 get_one_virtual_pixel_from_handler; 81 82 GetAuthenticPixelsHandler 83 get_authentic_pixels_handler; 84 85 GetAuthenticMetacontentFromHandler 86 get_authentic_metacontent_from_handler; 87 88 GetOneAuthenticPixelFromHandler 89 get_one_authentic_pixel_from_handler; 90 91 GetAuthenticPixelsFromHandler 92 get_authentic_pixels_from_handler; 93 94 QueueAuthenticPixelsHandler 95 queue_authentic_pixels_handler; 96 97 SyncAuthenticPixelsHandler 98 sync_authentic_pixels_handler; 99 100 DestroyPixelHandler 101 destroy_pixel_handler; 102 } CacheMethods; 103 104 typedef struct _NexusInfo 105 { 106 MagickBooleanType 107 mapped; 108 109 RectangleInfo 110 region; 111 112 MagickSizeType 113 length; 114 115 Quantum 116 *cache, 117 *pixels; 118 119 MagickBooleanType 120 authentic_pixel_cache; 121 122 void 123 *metacontent; 124 125 size_t 126 signature; 127 } NexusInfo; 128 129 typedef struct _CacheInfo 130 { 131 ClassType 132 storage_class; 133 134 ColorspaceType 135 colorspace; 136 137 PixelTrait 138 alpha_trait; 139 140 ChannelType 141 channels; 142 143 size_t 144 columns, 145 rows; 146 147 size_t 148 metacontent_extent, 149 number_channels; 150 151 PixelChannelMap 152 channel_map[MaxPixelChannels]; 153 154 CacheType 155 type; 156 157 MapMode 158 mode, 159 disk_mode; 160 161 MagickBooleanType 162 mapped; 163 164 MagickOffsetType 165 offset; 166 167 MagickSizeType 168 length; 169 170 VirtualPixelMethod 171 virtual_pixel_method; 172 173 PixelInfo 174 virtual_pixel_color; 175 176 size_t 177 number_threads; 178 179 NexusInfo 180 **nexus_info; 181 182 Quantum 183 *pixels; 184 185 void 186 *metacontent; 187 188 int 189 file; 190 191 char 192 filename[MagickPathExtent], 193 cache_filename[MagickPathExtent]; 194 195 CacheMethods 196 methods; 197 198 RandomInfo 199 *random_info; 200 201 void 202 *server_info; 203 204 MagickBooleanType 205 synchronize, 206 debug; 207 208 MagickThreadType 209 id; 210 211 ssize_t 212 reference_count; 213 214 SemaphoreInfo 215 *semaphore, 216 *file_semaphore; 217 218 time_t 219 timestamp; 220 221 size_t 222 signature; 223 224 MagickCLCacheInfo 225 opencl; 226 227 MagickBooleanType 228 composite_mask; 229 } CacheInfo; 230 231 extern MagickPrivate Cache 232 AcquirePixelCache(const size_t), 233 ClonePixelCache(const Cache), 234 DestroyPixelCache(Cache), 235 ReferencePixelCache(Cache); 236 237 extern MagickPrivate ClassType 238 GetPixelCacheStorageClass(const Cache); 239 240 extern MagickPrivate ColorspaceType 241 GetPixelCacheColorspace(const Cache); 242 243 extern MagickPrivate const Quantum 244 *GetVirtualPixelCacheNexus(const Image *,const VirtualPixelMethod, 245 const ssize_t,const ssize_t,const size_t,const size_t,NexusInfo *, 246 ExceptionInfo *) magick_hot_spot, 247 *GetVirtualPixelsNexus(const Cache,NexusInfo *magick_restrict); 248 249 extern MagickPrivate const void 250 *GetVirtualMetacontentFromNexus(const Cache,NexusInfo *magick_restrict); 251 252 extern MagickPrivate MagickBooleanType 253 CacheComponentGenesis(void), 254 SyncAuthenticPixelCacheNexus(Image *,NexusInfo *magick_restrict, 255 ExceptionInfo *) magick_hot_spot, 256 SyncImagePixelCache(Image *,ExceptionInfo *); 257 258 extern MagickPrivate MagickSizeType 259 GetPixelCacheNexusExtent(const Cache,NexusInfo *magick_restrict); 260 261 extern MagickPrivate NexusInfo 262 **AcquirePixelCacheNexus(const size_t), 263 **DestroyPixelCacheNexus(NexusInfo **,const size_t); 264 265 extern MagickPrivate Quantum 266 *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t, 267 const size_t,const size_t,NexusInfo *,ExceptionInfo *) magick_hot_spot, 268 *QueueAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t, 269 const size_t,const size_t,const MagickBooleanType,NexusInfo *, 270 ExceptionInfo *) magick_hot_spot; 271 272 extern MagickPrivate size_t 273 GetPixelCacheChannels(const Cache); 274 275 extern MagickPrivate VirtualPixelMethod 276 GetPixelCacheVirtualMethod(const Image *), 277 SetPixelCacheVirtualMethod(Image *,const VirtualPixelMethod,ExceptionInfo *); 278 279 extern MagickPrivate void 280 CacheComponentTerminus(void), 281 ClonePixelCacheMethods(Cache,const Cache), 282 GetPixelCacheTileSize(const Image *,size_t *,size_t *), 283 GetPixelCacheMethods(CacheMethods *), 284 ResetCacheAnonymousMemory(void), 285 ResetPixelCacheEpoch(void), 286 ResetPixelCacheChannels(Image *), 287 SetPixelCacheMethods(Cache,CacheMethods *); 288 289 #if defined(MAGICKCORE_OPENCL_SUPPORT) 290 extern MagickPrivate cl_mem 291 GetAuthenticOpenCLBuffer(const Image *,MagickCLDevice,ExceptionInfo *); 292 293 extern MagickPrivate void 294 SyncAuthenticOpenCLBuffer(const Image *); 295 #endif 296 297 #if defined(__cplusplus) || defined(c_plusplus) 298 } 299 #endif 300 301 #endif 302