MagickCore: cache.c File Reference

# cache.c File Reference

`#include "magick/studio.h"`
`#include "magick/blob.h"`
`#include "magick/blob-private.h"`
`#include "magick/cache.h"`
`#include "magick/cache-private.h"`
`#include "magick/color-private.h"`
`#include "magick/composite-private.h"`
`#include "magick/exception.h"`
`#include "magick/exception-private.h"`
`#include "magick/list.h"`
`#include "magick/log.h"`
`#include "magick/magick.h"`
`#include "magick/memory_.h"`
`#include "magick/pixel-private.h"`
`#include "magick/quantum.h"`
`#include "magick/random_.h"`
`#include "magick/resource_.h"`
`#include "magick/semaphore.h"`
`#include "magick/splay-tree.h"`
`#include "magick/string_.h"`
`#include "magick/utility.h"`
`#include "zlib.h"`
`#include <pthread.h>`

## Data Structures
struct | _NexusInfo
## Defines
#define | DefaultNumberCacheViews 8UL
## Functions
static const PixelPacket * | AcquirePixelCache (const Image *, const VirtualPixelMethod, const long, const long, const unsigned long, const unsigned long, ExceptionInfo *)
static IndexPacket * | GetIndexesFromCache (const Image *)
static MagickBooleanType | OpenCache (Image *, const MapMode, ExceptionInfo *)
static MagickBooleanType | SyncCache (Image *)
static MagickBooleanType | SyncPixelCache (Image *)
static PixelPacket | AcquireOnePixelFromCache (const Image *, const VirtualPixelMethod, const long, const long, ExceptionInfo *)
static PixelPacket | GetOnePixelFromCache (Image *, const long, const long)
static PixelPacket * | GetPixelCache (Image *, const long, const long, const unsigned long, const unsigned long)
static PixelPacket ** | GetPixelsFromCache (const Image *)
static PixelPacket *** | SetPixelCache (Image *, const long, const long, const unsigned long, const unsigned long)
static void | DestroyPixelCache (Image *)
static PixelPacket * | SetNexus (const Image *, const RectangleInfo *, const unsigned long)
static MagickBooleanType | ReadCacheIndexes (CacheInfo *, const unsigned long, ExceptionInfo *)
static MagickBooleanType | ReadCachePixels (CacheInfo *, const unsigned long, ExceptionInfo *)
static MagickBooleanType | WriteCacheIndexes (CacheInfo *, const unsigned long, ExceptionInfo *)
static MagickBooleanType | WriteCachePixels (CacheInfo *, const unsigned long, ExceptionInfo *)
static long | DitherX (const unsigned long columns, const long x)
static long | DitherY (const unsigned long rows, const long y)
static long | EdgeX (const unsigned long columns, const long x)
static long | EdgeY (const unsigned long rows, const long y)
static MagickSizeType | MagickMax (const MagickSizeType x, const MagickSizeType y)
static MagickSizeType | MagickMin (const MagickSizeType x, const MagickSizeType y)
static long | RandomX (const unsigned long columns)
static long | RandomY (const unsigned long rows)
static long | TileX (const unsigned long columns, const long x)
static long | TileY (const unsigned long rows, const long y)
static long | MirrorX (const unsigned long columns, const long x)
static long | MirrorY (const unsigned long rows, const long y)
static MagickBooleanType | IsNexusInCore (const CacheInfo *cache_info, const unsigned long nexus)
MagickExport const PixelPacket * | AcquireCacheNexus (const Image *image, const VirtualPixelMethod virtual_pixel_method, const long x, const long y, const unsigned long columns, const unsigned long rows, const unsigned long nexus, ExceptionInfo *exception)
MagickExport const PixelPacket * | AcquireImagePixels (const Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows, ExceptionInfo *exception)
MagickExport const IndexPacket * | AcquireIndexes (const Image *image)
static const IndexPacket * | AcquireIndexesFromCache (const Image *image)
MagickExport const IndexPacket * | AcquireNexusIndexes (const Cache cache, const unsigned long nexus)
MagickExport MagickPixelPacket | AcquireOneMagickPixel (const Image *image, const long x, const long y, ExceptionInfo *exception)
MagickExport PixelPacket | AcquireOnePixel (const Image *image, const long x, const long y, ExceptionInfo *exception)
MagickExport PixelPacket | AcquireOneVirtualPixel (const Image *image, const VirtualPixelMethod virtual_pixel_method, const long x, const long y, ExceptionInfo *exception)
static MagickBooleanType | ClipCacheNexus (Image *image, const unsigned long nexus)
static void | AcquireNexusPixels (NexusInfo *nexus_info)
static MagickBooleanType | CloneCacheNexus (CacheInfo *destination, CacheInfo *source, const unsigned long nexus)
static MagickBooleanType | CloseDiskCache (CacheInfo *cache_info)
static unsigned long | GetCacheThreadId (void)
static void | LimitOpenCacheDescriptors (void)
static MagickBooleanType | OpenDiskCache (CacheInfo *cache_info, MapMode mode)
static MagickOffsetType | ReadCacheRegion (int file, unsigned char *buffer, MagickSizeType length, MagickOffsetType offset)
static MagickOffsetType | WriteCacheRegion (int file, const unsigned char *buffer, MagickSizeType length, MagickOffsetType offset)
static MagickBooleanType | CloneDiskToDiskPixels (CacheInfo *cache_info, CacheInfo *source_info, ExceptionInfo *exception)
static MagickBooleanType | CloneDiskToMemoryPixels (CacheInfo *cache_info, CacheInfo *source_info, ExceptionInfo *exception)
static MagickBooleanType | CloneMemoryToDiskPixels (CacheInfo *cache_info, CacheInfo *source_info, ExceptionInfo *exception)
static MagickBooleanType | CloneMemoryToMemoryPixels (CacheInfo *cache_info, CacheInfo *source_info, ExceptionInfo *magick_unused(exception))
static MagickBooleanType | ClonePixelCache (CacheInfo *cache_info, CacheInfo *source_info, ExceptionInfo *exception)
MagickExport void | CloneCacheMethods (Cache clone, const Cache cache)
static void | RelinquishCachePixels (CacheInfo *cache_info)
MagickExport Cache | DestroyCacheInfo (Cache cache)
static void | RelinquishNexusPixels (NexusInfo *nexus_info)
MagickExport void | DestroyCacheNexus (Cache cache, const unsigned long nexus)
MagickExport void | DestroyCacheResources (void)
MagickExport void | DestroyImagePixels (Image *image)
MagickExport ClassType | GetCacheClass (const Cache cache)
MagickExport ColorspaceType | GetCacheColorspace (const Cache cache)
MagickExport MagickBooleanType | GetCacheInfo (Cache *cache)
MagickExport void | GetCacheMethods (CacheMethods *cache_methods)
MagickExport PixelPacket * | GetCacheNexus (Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows, const unsigned long nexus)
MagickExport VirtualPixelMethod | GetCacheVirtualPixelMethod (const Image *image)
MagickExport PixelPacket * | GetImagePixels (Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows)
MagickExport IndexPacket * | GetIndexes (const Image *image)
MagickExport unsigned long | GetNexus (Cache cache)
MagickExport IndexPacket * | GetNexusIndexes (const Cache cache, const unsigned long nexus)
MagickExport PixelPacket * | GetNexusPixels (const Cache cache, const unsigned long nexus)
MagickExport PixelPacket | GetOnePixel (Image *image, const long x, const long y)
MagickExport PixelPacket * | GetPixels (const Image *image)
MagickExport MagickSizeType | GetPixelCacheArea (const Image *image)
static void | MagickPixelCompositeMask (const MagickPixelPacket *p, const MagickRealType alpha, const MagickPixelPacket *q, const MagickRealType beta, MagickPixelPacket *composite)
static MagickBooleanType | MaskCacheNexus (Image *image, const unsigned long nexus)
static MagickBooleanType | ModifyCache (Image *image, const unsigned long nexus)
static void | AcquireCachePixels (CacheInfo *cache_info)
static MagickBooleanType | ExtendCache (Image *image, MagickSizeType length)
MagickExport MagickBooleanType | PersistCache (Image *image, const char *filename, const MagickBooleanType attach, MagickOffsetType *offset, ExceptionInfo *exception)
MagickExport Cache | ReferenceCache (Cache cache)
MagickExport void | SetCacheMethods (Cache cache, CacheMethods *cache_methods)
MagickExport PixelPacket * | SetCacheNexus (Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows, const unsigned long nexus)
MagickExport VirtualPixelMethod | SetCacheVirtualPixelMethod (const Image *image, const VirtualPixelMethod virtual_pixel_method)
MagickExport PixelPacket * | SetImagePixels (Image *image, const long x, const long y, const unsigned long columns, const unsigned long rows)
MagickExport MagickBooleanType | SyncCacheNexus (Image *image, const unsigned long nexus)
MagickExport MagickBooleanType | SyncImagePixels (Image *image)
## Variables
static MagickSizeType | serial_number = 0
static SemaphoreInfo * | cache_semaphore = (SemaphoreInfo *) NULL
static SplayTreeInfo * | cache_resources = (SplayTreeInfo *) NULL
static long | DitherMatrix [64]

## Define Documentation

#define DefaultNumberCacheViews 8UL

## Function Documentation

MagickExport const PixelPacket* AcquireCacheNexus | ( | const Image * | image,
|  | const VirtualPixelMethod | virtual_pixel_method,
|  | const long | x,
|  | const long | y,
|  | const unsigned long | columns,
|  | const unsigned long | rows,
|  | const unsigned long | nexus,
|  | ExceptionInfo * | exception |
| ) |  |  |

static void AcquireCachePixels | ( | CacheInfo * | cache_info | ) | `[inline, static]`

MagickExport const PixelPacket* AcquireImagePixels | ( | const Image * | image,
|  | const long | x,
|  | const long | y,
|  | const unsigned long | columns,
|  | const unsigned long | rows,
|  | ExceptionInfo * | exception |
| ) |  |  |

MagickExport const IndexPacket* AcquireIndexes | ( | const Image * | image | ) |

static const IndexPacket* AcquireIndexesFromCache | ( | const Image * | image | ) | `[static]`

MagickExport const IndexPacket* AcquireNexusIndexes | ( | const Cache | cache,
|  | const unsigned long | nexus |
| ) |  |  |

static void AcquireNexusPixels | ( | NexusInfo * | nexus_info | ) | `[inline, static]`

MagickExport MagickPixelPacket AcquireOneMagickPixel | ( | const Image * | image,
|  | const long | x,
|  | const long | y,
|  | ExceptionInfo * | exception |
| ) |  |  |

MagickExport PixelPacket AcquireOnePixel | ( | const Image * | image,
|  | const long | x,
|  | const long | y,
|  | ExceptionInfo * | exception |
| ) |  |  |

static PixelPacket AcquireOnePixelFromCache | ( | const Image * | image,
|  | const | VirtualPixelMethod,
|  | const | long,
|  | const | long,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

MagickExport PixelPacket AcquireOneVirtualPixel | ( | const Image * | image,
|  | const VirtualPixelMethod | virtual_pixel_method,
|  | const long | x,
|  | const long | y,
|  | ExceptionInfo * | exception |
| ) |  |  |

static const PixelPacket * AcquirePixelCache | ( | const Image * | image,
|  | const | VirtualPixelMethod,
|  | const | long,
|  | const | long,
|  | const unsigned long | columns,
|  | const unsigned long | rows,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType ClipCacheNexus | ( | Image * | image,
|  | const unsigned long | nexus |
| ) |  |  | `[static]`

MagickExport void CloneCacheMethods | ( | Cache | clone,
|  | const Cache | cache |
| ) |  |  |

static MagickBooleanType CloneCacheNexus | ( | CacheInfo * | destination,
|  | CacheInfo * | source,
|  | const unsigned long | nexus |
| ) |  |  | `[static]`

static MagickBooleanType CloneDiskToDiskPixels | ( | CacheInfo * | cache_info,
|  | CacheInfo * | source_info,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType CloneDiskToMemoryPixels | ( | CacheInfo * | cache_info,
|  | CacheInfo * | source_info,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType CloneMemoryToDiskPixels | ( | CacheInfo * | cache_info,
|  | CacheInfo * | source_info,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType CloneMemoryToMemoryPixels | ( | CacheInfo * | cache_info,
|  | CacheInfo * | source_info,
|  | ExceptionInfo * | magick_unused(exception) |
| ) |  |  | `[static]`

static MagickBooleanType ClonePixelCache | ( | CacheInfo * | cache_info,
|  | CacheInfo * | source_info,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType CloseDiskCache | ( | CacheInfo * | cache_info | ) | `[static]`

MagickExport Cache DestroyCacheInfo | ( | Cache | cache | ) |

MagickExport void DestroyCacheNexus | ( | Cache | cache,
|  | const unsigned long | nexus |
| ) |  |  |

MagickExport void DestroyCacheResources | ( | void |  | ) |

MagickExport void DestroyImagePixels | ( | Image * | image | ) |

static void DestroyPixelCache | ( | Image * | image | ) | `[static]`

static long DitherX | ( | const unsigned long | columns,
|  | const long | x |
| ) |  |  | `[inline, static]`

static long DitherY | ( | const unsigned long | rows,
|  | const long | y |
| ) |  |  | `[inline, static]`

static long EdgeX | ( | const unsigned long | columns,
|  | const long | x |
| ) |  |  | `[inline, static]`

static long EdgeY | ( | const unsigned long | rows,
|  | const long | y |
| ) |  |  | `[inline, static]`

static MagickBooleanType ExtendCache | ( | Image * | image,
|  | MagickSizeType | length |
| ) |  |  | `[static]`

MagickExport ClassType GetCacheClass | ( | const Cache | cache | ) |

MagickExport ColorspaceType GetCacheColorspace | ( | const Cache | cache | ) |

MagickExport MagickBooleanType GetCacheInfo | ( | Cache * | cache | ) |

MagickExport void GetCacheMethods | ( | CacheMethods * | cache_methods | ) |

MagickExport PixelPacket* GetCacheNexus | ( | Image * | image,
|  | const long | x,
|  | const long | y,
|  | const unsigned long | columns,
|  | const unsigned long | rows,
|  | const unsigned long | nexus |
| ) |  |  |

static unsigned long GetCacheThreadId | ( | void |  | ) | `[static]`

MagickExport VirtualPixelMethod GetCacheVirtualPixelMethod | ( | const Image * | image | ) |

MagickExport PixelPacket* GetImagePixels | ( | Image * | image,
|  | const long | x,
|  | const long | y,
|  | const unsigned long | columns,
|  | const unsigned long | rows |
| ) |  |  |

MagickExport IndexPacket* GetIndexes | ( | const Image * | image | ) |

static IndexPacket * GetIndexesFromCache | ( | const Image * | image | ) | `[static]`

MagickExport unsigned long GetNexus | ( | Cache | cache | ) |

MagickExport IndexPacket* GetNexusIndexes | ( | const Cache | cache,
|  | const unsigned long | nexus |
| ) |  |  |

MagickExport PixelPacket* GetNexusPixels | ( | const Cache | cache,
|  | const unsigned long | nexus |
| ) |  |  |

MagickExport PixelPacket GetOnePixel | ( | Image * | image,
|  | const long | x,
|  | const long | y |
| ) |  |  |

static PixelPacket GetOnePixelFromCache | ( | Image * | image,
|  | const | long,
|  | const | long |
| ) |  |  |

static PixelPacket * GetPixelCache | ( | Image * | image,
|  | const | long,
|  | const | long,
|  | const unsigned long | columns,
|  | const unsigned long | rows |
| ) |  |  |

MagickExport MagickSizeType GetPixelCacheArea | ( | const Image * | image | ) |

MagickExport PixelPacket* GetPixels | ( | const Image * | image | ) |

static PixelPacket * GetPixelsFromCache | ( | const Image * | image | ) |

static MagickBooleanType IsNexusInCore | ( | const CacheInfo * | cache_info,
|  | const unsigned long | nexus |
| ) |  |  | `[inline, static]`

static void LimitOpenCacheDescriptors | ( | void |  | ) | `[static]`

static MagickSizeType MagickMax | ( | const MagickSizeType | x,
|  | const MagickSizeType | y |
| ) |  |  | `[inline, static]`

static MagickSizeType MagickMin | ( | const MagickSizeType | x,
|  | const MagickSizeType | y |
| ) |  |  | `[inline, static]`

static void MagickPixelCompositeMask | ( | const MagickPixelPacket * | p,
|  | const MagickRealType | alpha,
|  | const MagickPixelPacket * | q,
|  | const MagickRealType | beta,
|  | MagickPixelPacket * | composite |
| ) |  |  | `[inline, static]`

static MagickBooleanType MaskCacheNexus | ( | Image * | image,
|  | const unsigned long | nexus |
| ) |  |  | `[static]`

static long MirrorX | ( | const unsigned long | columns,
|  | const long | x |
| ) |  |  | `[inline, static]`

static long MirrorY | ( | const unsigned long | rows,
|  | const long | y |
| ) |  |  | `[inline, static]`

static MagickBooleanType ModifyCache | ( | Image * | image,
|  | const unsigned long | nexus |
| ) |  |  | `[static]`

static MagickBooleanType OpenCache | ( | Image * | image,
|  | const | MapMode,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType OpenDiskCache | ( | CacheInfo * | cache_info,
|  | MapMode | mode |
| ) |  |  | `[static]`

MagickExport MagickBooleanType PersistCache | ( | Image * | image,
|  | const char * | filename,
|  | const MagickBooleanType | attach,
|  | MagickOffsetType * | offset,
|  | ExceptionInfo * | exception |
| ) |  |  |

static long RandomX | ( | const unsigned long | columns | ) | `[inline, static]`

static long RandomY | ( | const unsigned long | rows | ) | `[inline, static]`

static MagickBooleanType ReadCacheIndexes | ( | CacheInfo * | cache_info,
|  | const unsigned long | nexus,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

static MagickBooleanType ReadCachePixels | ( | CacheInfo * | cache_info,
|  | const unsigned long | nexus,
|  | ExceptionInfo * | exception |
| ) |  |  |

static MagickOffsetType ReadCacheRegion | ( | int | file,
|  | unsigned char * | buffer,
|  | MagickSizeType | length,
|  | MagickOffsetType | offset |
| ) |  |  | `[inline, static]`

MagickExport Cache ReferenceCache | ( | Cache | cache | ) |

static void RelinquishCachePixels | ( | CacheInfo * | cache_info | ) | `[inline, static]`

static void RelinquishNexusPixels | ( | NexusInfo * | nexus_info | ) | `[inline, static]`

MagickExport void SetCacheMethods | ( | Cache | cache,
|  | CacheMethods * | cache_methods |
| ) |  |  |

MagickExport PixelPacket* SetCacheNexus | ( | Image * | image,
|  | const long | x,
|  | const long | y,
|  | const unsigned long | columns,
|  | const unsigned long | rows,
|  | const unsigned long | nexus |
| ) |  |  |

MagickExport VirtualPixelMethod SetCacheVirtualPixelMethod | ( | const Image * | image,
|  | const VirtualPixelMethod | virtual_pixel_method |
| ) |  |  |

MagickExport PixelPacket* SetImagePixels | ( | Image * | image,
|  | const long | x,
|  | const long | y,
|  | const unsigned long | columns,
|  | const unsigned long | rows |
| ) |  |  |

static PixelPacket * SetNexus | ( | const Image * | image,
|  | const RectangleInfo * | region,
|  | const unsigned long | nexus |
| ) |  |  | `[static]`

static PixelPacket * SetPixelCache | ( | Image * | image,
|  | const | long,
|  | const | long,
|  | const unsigned long | columns,
|  | const unsigned long | rows |
| ) |  |  |

static MagickBooleanType SyncCache | ( | Image * | image | ) |

MagickExport MagickBooleanType SyncCacheNexus | ( | Image * | image,
|  | const unsigned long | nexus |
| ) |  |  |

MagickExport MagickBooleanType SyncImagePixels | ( | Image * | image | ) |

static MagickBooleanType SyncPixelCache | ( | Image * | image | ) |

static long TileX | ( | const unsigned long | columns,
|  | const long | x |
| ) |  |  | `[inline, static]`

static long TileY | ( | const unsigned long | rows,
|  | const long | y |
| ) |  |  | `[inline, static]`

static MagickBooleanType WriteCacheIndexes | ( | CacheInfo * | cache_info,
|  | const unsigned long | nexus,
|  | ExceptionInfo * | exception |
| ) |  |  |

static MagickBooleanType WriteCachePixels | ( | CacheInfo * | cache_info,
|  | const unsigned long | nexus,
|  | ExceptionInfo * | exception |
| ) |  |  |

static MagickOffsetType WriteCacheRegion | ( | int | file,
|  | const unsigned char * | buffer,
|  | MagickSizeType | length,
|  | MagickOffsetType | offset |
| ) |  |  | `[inline, static]`

## Variable Documentation

SplayTreeInfo* cache_resources = (SplayTreeInfo *) NULL`[static]`

SemaphoreInfo* cache_semaphore = (SemaphoreInfo *) NULL`[static]`

long DitherMatrix[64]`[static]`

Initial value:

      {
         0,  48,  12,  60,   3,  51,  15,  63,
        32,  16,  44,  28,  35,  19,  47,  31,
         8,  56,   4,  52,  11,  59,   7,  55,
        40,  24,  36,  20,  43,  27,  39,  23,
         2,  50,  14,  62,   1,  49,  13,  61,
        34,  18,  46,  30,  33,  17,  45,  29,
        10,  58,   6,  54,   9,  57,   5,  53,
        42,  26,  38,  22,  41,  25,  37,  21
      }

MagickSizeType serial_number = 0`[static]`