% MagickCore Pixel Cache Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1999 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
quotient,
remainder;
} MagickModulo;
-
-struct _NexusInfo
-{
- MagickBooleanType
- mapped;
-
- RectangleInfo
- region;
-
- MagickSizeType
- length;
-
- Quantum
- *cache,
- *pixels;
-
- void
- *metacontent;
-
- size_t
- signature;
-};
\f
/*
Forward declarations.
MagickPrivate Cache AcquirePixelCache(const size_t number_threads)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
char
*synchronize;
cache_info->synchronize=IsStringTrue(synchronize);
synchronize=DestroyString(synchronize);
}
- cache_info->semaphore=AllocateSemaphoreInfo();
+ cache_info->semaphore=AcquireSemaphoreInfo();
cache_info->reference_count=1;
- cache_info->file_semaphore=AllocateSemaphoreInfo();
+ cache_info->file_semaphore=AcquireSemaphoreInfo();
cache_info->debug=IsEventLogging();
cache_info->signature=MagickSignature;
return((Cache ) cache_info);
MagickPrivate NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
{
NexusInfo
- **nexus_info;
+ **restrict nexus_info;
register ssize_t
i;
MagickSizeType *length,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
*/
MagickPrivate MagickBooleanType CacheComponentGenesis(void)
{
- AcquireSemaphoreInfo(&cache_semaphore);
+ if (cache_semaphore == (SemaphoreInfo *) NULL)
+ cache_semaphore=AcquireSemaphoreInfo();
return(MagickTrue);
}
\f
MagickPrivate void CacheComponentTerminus(void)
{
if (cache_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&cache_semaphore);
+ ActivateSemaphoreInfo(&cache_semaphore);
LockSemaphoreInfo(cache_semaphore);
instantiate_cache=MagickFalse;
UnlockSemaphoreInfo(cache_semaphore);
- DestroySemaphoreInfo(&cache_semaphore);
+ RelinquishSemaphoreInfo(&cache_semaphore);
}
\f
/*
MagickPrivate Cache ClonePixelCache(const Cache cache)
{
CacheInfo
- *clone_info;
+ *restrict clone_info;
const CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != NULL);
cache_info=(const CacheInfo *) cache;
MagickPrivate void ClonePixelCacheMethods(Cache clone,const Cache cache)
{
CacheInfo
- *cache_info,
- *source_info;
+ *restrict cache_info,
+ *restrict source_info;
assert(clone != (Cache) NULL);
source_info=(CacheInfo *) clone;
%
*/
+static inline void CopyPixels(Quantum *destination,const Quantum *source,
+ const MagickSizeType number_pixels)
+{
+#if !defined(MAGICKCORE_OPENMP_SUPPORT) || (MAGICKCORE_QUANTUM_DEPTH <= 8)
+ (void) memcpy(destination,source,(size_t) number_pixels*sizeof(*source));
+#else
+ {
+ register MagickOffsetType
+ i;
+
+ if ((number_pixels*sizeof(*source)) < MagickMaxBufferExtent)
+ {
+ (void) memcpy(destination,source,(size_t) number_pixels*
+ sizeof(*source));
+ return;
+ }
+ #pragma omp parallel for
+ for (i=0; i < (MagickOffsetType) number_pixels; i++)
+ destination[i]=source[i];
+ }
+#endif
+}
+
static inline MagickSizeType MagickMin(const MagickSizeType x,
const MagickSizeType y)
{
return(y);
}
-static MagickBooleanType ClonePixelCacheRepository(CacheInfo *clone_info,
- CacheInfo *cache_info,ExceptionInfo *exception)
+static MagickBooleanType ClonePixelCacheRepository(
+ CacheInfo *restrict clone_info,CacheInfo *restrict cache_info,
+ ExceptionInfo *exception)
{
#define MaxCacheThreads 2
#define cache_threads(source,destination,chunk) \
num_threads((chunk) < (16*GetMagickResourceLimit(ThreadResource)) ? 1 : \
- GetMagickResourceLimit(ThreadResource) < MaxCacheThreads ? 1 : \
- MaxCacheThreads)
+ GetMagickResourceLimit(ThreadResource) < MaxCacheThreads ? \
+ GetMagickResourceLimit(ThreadResource) : MaxCacheThreads)
MagickBooleanType
optimize,
status;
NexusInfo
- **cache_nexus,
- **clone_nexus;
+ **restrict cache_nexus,
+ **restrict clone_nexus;
size_t
length;
length=cache_info->number_channels*sizeof(*cache_info->channel_map);
if (((cache_info->type == MemoryCache) || (cache_info->type == MapCache)) &&
((clone_info->type == MemoryCache) || (clone_info->type == MapCache)) &&
- (cache_info->columns == clone_info->columns) &&
- (cache_info->rows == clone_info->rows) &&
- (cache_info->number_channels == clone_info->number_channels) &&
- (memcmp(cache_info->channel_map,clone_info->channel_map,length) == 0))
+ (cache_info->columns == clone_info->columns) &&
+ (cache_info->rows == clone_info->rows) &&
+ (cache_info->number_channels == clone_info->number_channels) &&
+ (memcmp(cache_info->channel_map,clone_info->channel_map,length) == 0) &&
+ (cache_info->metacontent_extent == clone_info->metacontent_extent))
{
- /*
- Identical pixel cache morphology.
- */
- (void) memcpy(clone_info->pixels,cache_info->pixels,cache_info->columns*
- cache_info->number_channels*cache_info->rows*
- sizeof(*cache_info->pixels));
- if ((cache_info->metacontent_extent != 0) &&
- (clone_info->metacontent_extent != 0) &&
- (cache_info->metacontent_extent == clone_info->metacontent_extent))
+ CopyPixels(clone_info->pixels,cache_info->pixels,cache_info->columns*
+ cache_info->number_channels*cache_info->rows);
+ if (cache_info->metacontent_extent != 0)
(void) memcpy(clone_info->metacontent,cache_info->metacontent,
cache_info->columns*cache_info->rows*clone_info->metacontent_extent*
- sizeof(*cache_info->metacontent));
+ sizeof(cache_info->metacontent));
return(MagickTrue);
}
/*
if (status == MagickFalse)
continue;
region.width=clone_info->columns;
- region.y=y;
pixels=SetPixelCacheNexusPixels(clone_info,WriteMode,®ion,
clone_nexus[id],exception);
if (pixels == (Quantum *) NULL)
continue;
+ (void) ResetMagickMemory(clone_nexus[id]->pixels,0,clone_nexus[id]->length);
if (optimize != MagickFalse)
(void) memcpy(clone_nexus[id]->pixels,cache_nexus[id]->pixels,length*
sizeof(Quantum));
*/
length=(size_t) MagickMin(cache_info->metacontent_extent,
clone_info->metacontent_extent);
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ cache_threads(cache_info,clone_info,cache_info->rows)
+#endif
for (y=0; y < (ssize_t) cache_info->rows; y++)
{
const int
if (status == MagickFalse)
continue;
region.width=clone_info->columns;
- region.y=y;
pixels=SetPixelCacheNexusPixels(clone_info,WriteMode,®ion,
clone_nexus[id],exception);
if (pixels == (Quantum *) NULL)
continue;
- (void) memcpy(clone_nexus[id]->metacontent,cache_nexus[id]->metacontent,
- length*sizeof(*cache_nexus[id]->metacontent));
+ if (clone_nexus[id]->metacontent != (void *) NULL)
+ (void) memcpy(clone_nexus[id]->metacontent,
+ cache_nexus[id]->metacontent,length*
+ sizeof(cache_nexus[id]->metacontent));
status=WritePixelCacheMetacontent(clone_info,clone_nexus[id],exception);
}
}
(void) FormatLocaleString(message,MaxTextExtent,"%s => %s",
CommandOptionToMnemonic(MagickCacheOptions,(ssize_t) cache_info->type),
CommandOptionToMnemonic(MagickCacheOptions,(ssize_t) clone_info->type));
- (void) LogMagickEvent(CacheEvent,GetMagickModule(),message);
+ (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",message);
}
return(status);
}
MagickExport void DestroyImagePixels(Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
cache_info->pixels=(Quantum *) RelinquishAlignedMemory(
cache_info->pixels);
else
- cache_info->pixels=(Quantum *) UnmapBlob(cache_info->pixels,
- (size_t) cache_info->length);
+ {
+ (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
+ cache_info->pixels=(Quantum *) NULL;
+ }
RelinquishMagickResource(MemoryResource,cache_info->length);
break;
}
case MapCache:
{
- cache_info->pixels=(Quantum *) UnmapBlob(cache_info->pixels,(size_t)
- cache_info->length);
+ (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
+ cache_info->pixels=(Quantum *) NULL;
if (cache_info->mode != ReadMode)
(void) RelinquishUniqueFileResource(cache_info->cache_filename);
*cache_info->cache_filename='\0';
case DistributedCache:
{
*cache_info->cache_filename='\0';
- (void) RelinquishDistributePixelCache(cache_info->server_info);
+ (void) RelinquishDistributePixelCache((DistributeCacheInfo *)
+ cache_info->server_info);
break;
}
default:
MagickPrivate Cache DestroyPixelCache(Cache cache)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != (Cache) NULL);
cache_info=(CacheInfo *) cache;
}
RelinquishPixelCachePixels(cache_info);
if (cache_info->server_info != (DistributeCacheInfo *) NULL)
- cache_info->server_info=DestroyDistributeCacheInfo(cache_info->server_info);
+ cache_info->server_info=DestroyDistributeCacheInfo((DistributeCacheInfo *)
+ cache_info->server_info);
if (cache_info->nexus_info != (NexusInfo **) NULL)
cache_info->nexus_info=DestroyPixelCacheNexus(cache_info->nexus_info,
cache_info->number_threads);
if (cache_info->random_info != (RandomInfo *) NULL)
cache_info->random_info=DestroyRandomInfo(cache_info->random_info);
if (cache_info->file_semaphore != (SemaphoreInfo *) NULL)
- DestroySemaphoreInfo(&cache_info->file_semaphore);
+ RelinquishSemaphoreInfo(&cache_info->file_semaphore);
if (cache_info->semaphore != (SemaphoreInfo *) NULL)
- DestroySemaphoreInfo(&cache_info->semaphore);
+ RelinquishSemaphoreInfo(&cache_info->semaphore);
cache_info->signature=(~MagickSignature);
cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info);
cache=(Cache) NULL;
MagickExport void *GetAuthenticMetacontent(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
- void
- *metacontent;
-
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
assert(image->cache != (Cache) NULL);
if (cache_info->methods.get_authentic_metacontent_from_handler !=
(GetAuthenticMetacontentFromHandler) NULL)
{
+ void
+ *metacontent;
+
metacontent=cache_info->methods.
get_authentic_metacontent_from_handler(image);
return(metacontent);
}
assert(id < (int) cache_info->number_threads);
- metacontent=GetPixelCacheNexusMetacontent(cache_info,
- cache_info->nexus_info[id]);
- return(metacontent);
+ return(cache_info->nexus_info[id]->metacontent);
}
\f
/*
static void *GetAuthenticMetacontentFromCache(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
- void
- *metacontent;
-
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
assert(image->cache != (Cache) NULL);
cache_info=(CacheInfo *) image->cache;
assert(cache_info->signature == MagickSignature);
assert(id < (int) cache_info->number_threads);
- metacontent=GetPixelCacheNexusMetacontent(image->cache,
- cache_info->nexus_info[id]);
- return(metacontent);
+ return(cache_info->nexus_info[id]->metacontent);
}
\f
/*
%
*/
-static inline MagickBooleanType IsPixelAuthentic(
- const CacheInfo *restrict cache_info,const NexusInfo *restrict nexus_info)
-{
- MagickBooleanType
- status;
-
- MagickOffsetType
- offset;
-
- if (cache_info->type == PingCache)
- return(MagickTrue);
- offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
- nexus_info->region.x;
- status=nexus_info->pixels == (cache_info->pixels+offset*
- cache_info->number_channels) ? MagickTrue : MagickFalse;
- return(status);
-}
-
-MagickPrivate Quantum *GetAuthenticPixelCacheNexus(Image *image,
- const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
- NexusInfo *nexus_info,ExceptionInfo *exception)
+MagickPrivate Quantum *GetAuthenticPixelCacheNexus(Image *image,const ssize_t x,
+ const ssize_t y,const size_t columns,const size_t rows,NexusInfo *nexus_info,
+ ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
Quantum
- *q;
+ *restrict pixels;
/*
Transfer pixels from the cache.
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- q=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickTrue,nexus_info,
- exception);
- if (q == (Quantum *) NULL)
+ pixels=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickTrue,
+ nexus_info,exception);
+ if (pixels == (Quantum *) NULL)
return((Quantum *) NULL);
cache_info=(CacheInfo *) image->cache;
assert(cache_info->signature == MagickSignature);
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
- return(q);
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
+ return(pixels);
if (ReadPixelCachePixels(cache_info,nexus_info,exception) == MagickFalse)
return((Quantum *) NULL);
if (cache_info->metacontent_extent != 0)
if (ReadPixelCacheMetacontent(cache_info,nexus_info,exception) == MagickFalse)
return((Quantum *) NULL);
- return(q);
+ return(pixels);
}
\f
/*
static Quantum *GetAuthenticPixelsFromCache(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
cache_info=(CacheInfo *) image->cache;
assert(cache_info->signature == MagickSignature);
assert(id < (int) cache_info->number_threads);
- return(GetPixelCacheNexusPixels(image->cache,cache_info->nexus_info[id]));
+ return(cache_info->nexus_info[id]->pixels);
}
\f
/*
MagickExport Quantum *GetAuthenticPixelQueue(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
(GetAuthenticPixelsFromHandler) NULL)
return(cache_info->methods.get_authentic_pixels_from_handler(image));
assert(id < (int) cache_info->number_threads);
- return(GetPixelCacheNexusPixels(cache_info,cache_info->nexus_info[id]));
+ return(cache_info->nexus_info[id]->pixels);
}
\f
/*
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
Quantum
- *q;
+ *pixels;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (cache_info->methods.get_authentic_pixels_handler !=
(GetAuthenticPixelsHandler) NULL)
{
- q=cache_info->methods.get_authentic_pixels_handler(image,x,y,columns,rows,
- exception);
- return(q);
+ pixels=cache_info->methods.get_authentic_pixels_handler(image,x,y,columns,
+ rows,exception);
+ return(pixels);
}
assert(id < (int) cache_info->number_threads);
- q=GetAuthenticPixelCacheNexus(image,x,y,columns,rows,
+ pixels=GetAuthenticPixelCacheNexus(image,x,y,columns,rows,
cache_info->nexus_info[id],exception);
- return(q);
+ return(pixels);
}
\f
/*
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
Quantum
- *q;
+ *restrict pixels;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
return((Quantum *) NULL);
assert(cache_info->signature == MagickSignature);
assert(id < (int) cache_info->number_threads);
- q=GetAuthenticPixelCacheNexus(image,x,y,columns,rows,
+ pixels=GetAuthenticPixelCacheNexus(image,x,y,columns,rows,
cache_info->nexus_info[id],exception);
- return(q);
+ return(pixels);
}
\f
/*
MagickExport MagickSizeType GetImageExtent(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
if ((image->storage_class != cache_info->storage_class) ||
(image->colorspace != cache_info->colorspace) ||
(image->alpha_trait != cache_info->alpha_trait) ||
- (image->mask != cache_info->mask) ||
+ (image->read_mask != cache_info->read_mask) ||
+ (image->write_mask != cache_info->write_mask) ||
(image->columns != cache_info->columns) ||
(image->rows != cache_info->rows) ||
(image->number_channels != cache_info->number_channels) ||
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
MagickBooleanType
destroy,
status=MagickTrue;
LockSemaphoreInfo(image->semaphore);
if (cpu_throttle == 0)
- {
- char
- *limit;
-
- /*
- Set CPU throttle in milleseconds.
- */
- cpu_throttle=MagickResourceInfinity;
- limit=GetEnvironmentValue("MAGICK_THROTTLE");
- if (limit == (char *) NULL)
- limit=GetPolicyValue("throttle");
- if (limit != (char *) NULL)
- {
- cpu_throttle=(MagickSizeType) StringToInteger(limit);
- limit=DestroyString(limit);
- }
- }
+ cpu_throttle=GetMagickResourceLimit(ThrottleResource);
if ((cpu_throttle != MagickResourceInfinity) && ((cycles++ % 32) == 0))
MagickDelay(cpu_throttle);
if (time_limit == 0)
}
if ((time_limit != MagickResourceInfinity) &&
((MagickSizeType) (time((time_t *) NULL)-cache_timestamp) >= time_limit))
- ThrowFatalException(ResourceLimitFatalError,"TimeLimitExceeded");
+ {
+#if defined(ECANCELED)
+ errno=ECANCELED;
+#endif
+ ThrowFatalException(ResourceLimitFatalError,"TimeLimitExceeded");
+ }
assert(image->cache != (Cache) NULL);
cache_info=(CacheInfo *) image->cache;
destroy=MagickFalse;
Clone pixel cache.
*/
clone_image=(*image);
- clone_image.semaphore=AllocateSemaphoreInfo();
+ clone_image.semaphore=AcquireSemaphoreInfo();
clone_image.reference_count=1;
clone_image.cache=ClonePixelCache(cache_info);
clone_info=(CacheInfo *) clone_image.cache;
if (status != MagickFalse)
{
if (clone != MagickFalse)
- status=ClonePixelCacheRepository(clone_info,cache_info,exception);
+ status=ClonePixelCacheRepository(clone_info,cache_info,
+ exception);
if (status != MagickFalse)
{
if (cache_info->reference_count == 1)
image->cache=clone_image.cache;
}
}
- DestroySemaphoreInfo(&clone_image.semaphore);
+ RelinquishSemaphoreInfo(&clone_image.semaphore);
}
UnlockSemaphoreInfo(cache_info->semaphore);
}
MagickExport CacheType GetImagePixelCacheType(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
register Quantum
*restrict q;
}
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelChannel(image,i);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
pixel[channel]=q[i];
}
return(MagickTrue);
const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
}
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelChannel(image,i);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
pixel[channel]=q[i];
}
return(MagickTrue);
const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
}
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelChannel(image,i);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
pixel[channel]=p[i];
}
return(MagickTrue);
Quantum *pixel,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
}
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelChannel(image,i);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
pixel[channel]=p[i];
}
return(MagickTrue);
PixelInfo *pixel,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
register const Quantum
- *p;
+ *restrict p;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
MagickPrivate ColorspaceType GetPixelCacheColorspace(const Cache cache)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != (Cache) NULL);
cache_info=(CacheInfo *) cache;
%
*/
MagickPrivate MagickSizeType GetPixelCacheNexusExtent(const Cache cache,
- NexusInfo *nexus_info)
+ NexusInfo *restrict nexus_info)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
MagickSizeType
extent;
% %
% %
% %
-+ G e t P i x e l C a c h e N e x u s M e t a c o n t e n t %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% GetPixelCacheNexusMetacontent() returns the meta-content for the specified
-% cache nexus.
-%
-% The format of the GetPixelCacheNexusMetacontent() method is:
-%
-% void *GetPixelCacheNexusMetacontent(const Cache cache,
-% NexusInfo *nexus_info)
-%
-% A description of each parameter follows:
-%
-% o cache: the pixel cache.
-%
-% o nexus_info: the cache nexus to return the meta-content.
-%
-*/
-MagickPrivate void *GetPixelCacheNexusMetacontent(const Cache cache,
- NexusInfo *nexus_info)
-{
- CacheInfo
- *cache_info;
-
- assert(cache != NULL);
- cache_info=(CacheInfo *) cache;
- assert(cache_info->signature == MagickSignature);
- if (cache_info->storage_class == UndefinedClass)
- return((void *) NULL);
- return(nexus_info->metacontent);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ G e t P i x e l C a c h e N e x u s P i x e l s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% GetPixelCacheNexusPixels() returns the pixels associated with the specified
-% cache nexus.
-%
-% The format of the GetPixelCacheNexusPixels() method is:
-%
-% Quantum *GetPixelCacheNexusPixels(const Cache cache,
-% NexusInfo *nexus_info)
-%
-% A description of each parameter follows:
-%
-% o cache: the pixel cache.
-%
-% o nexus_info: the cache nexus to return the pixels.
-%
-*/
-MagickPrivate Quantum *GetPixelCacheNexusPixels(const Cache cache,
- NexusInfo *nexus_info)
-{
- CacheInfo
- *cache_info;
-
- assert(cache != NULL);
- cache_info=(CacheInfo *) cache;
- assert(cache_info->signature == MagickSignature);
- if (cache_info->storage_class == UndefinedClass)
- return((Quantum *) NULL);
- return(nexus_info->pixels);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ G e t P i x e l C a c h e P i x e l s %
% %
% %
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
MagickPrivate ClassType GetPixelCacheStorageClass(const Cache cache)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != (Cache) NULL);
cache_info=(CacheInfo *) cache;
size_t *height)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
MagickPrivate VirtualPixelMethod GetPixelCacheVirtualMethod(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
static const void *GetVirtualMetacontentFromCache(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
const void
- *metacontent;
+ *restrict metacontent;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
%
*/
MagickPrivate const void *GetVirtualMetacontentFromNexus(const Cache cache,
- NexusInfo *nexus_info)
+ NexusInfo *restrict nexus_info)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != (Cache) NULL);
cache_info=(CacheInfo *) cache;
MagickExport const void *GetVirtualMetacontent(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
const void
- *metacontent;
+ *restrict metacontent;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
MagickOffsetType
offset;
number_pixels;
NexusInfo
- **virtual_nexus;
+ **restrict virtual_nexus;
Quantum
- *pixels,
- virtual_pixel[CompositePixelChannel];
+ *restrict pixels,
+ virtual_pixel[MaxPixelChannels];
RectangleInfo
region;
v;
void
- *virtual_metacontent;
+ *restrict virtual_metacontent;
/*
Acquire pixels.
/*
Pixel request is inside cache extents.
*/
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
return(q);
status=ReadPixelCachePixels(cache_info,nexus_info,exception);
if (status == MagickFalse)
/*
Pixel request is outside cache extents.
*/
- s=(unsigned char *) GetPixelCacheNexusMetacontent(cache_info,nexus_info);
+ s=(unsigned char *) nexus_info->metacontent;
virtual_nexus=AcquirePixelCacheNexus(1);
if (virtual_nexus == (NexusInfo **) NULL)
{
}
for (v=0; v < (ssize_t) rows; v++)
{
+ ssize_t
+ y_offset;
+
+ y_offset=y+v;
+ if ((virtual_pixel_method == EdgeVirtualPixelMethod) ||
+ (virtual_pixel_method == UndefinedVirtualPixelMethod))
+ y_offset=EdgeY(y_offset,cache_info->rows);
for (u=0; u < (ssize_t) columns; u+=length)
{
- length=(MagickSizeType) MagickMin(cache_info->columns-(x+u),columns-u);
- if ((((x+u) < 0) || ((x+u) >= (ssize_t) cache_info->columns)) ||
- (((y+v) < 0) || ((y+v) >= (ssize_t) cache_info->rows)) ||
+ ssize_t
+ x_offset;
+
+ x_offset=x+u;
+ length=(MagickSizeType) MagickMin(cache_info->columns-x_offset,columns-u);
+ if (((x_offset < 0) || (x_offset >= (ssize_t) cache_info->columns)) ||
+ ((y_offset < 0) || (y_offset >= (ssize_t) cache_info->rows)) ||
(length == 0))
{
MagickModulo
length=(MagickSizeType) 1;
switch (virtual_pixel_method)
{
+ case EdgeVirtualPixelMethod:
default:
{
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
- EdgeX(x+u,cache_info->columns),EdgeY(y+v,cache_info->rows),
- 1UL,1UL,*virtual_nexus,exception);
+ EdgeX(x_offset,cache_info->columns),
+ EdgeY(y_offset,cache_info->rows),1UL,1UL,*virtual_nexus,
+ exception);
r=GetVirtualMetacontentFromNexus(cache_info,*virtual_nexus);
break;
}
case DitherVirtualPixelMethod:
{
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
- DitherX(x+u,cache_info->columns),DitherY(y+v,cache_info->rows),
- 1UL,1UL,*virtual_nexus,exception);
+ DitherX(x_offset,cache_info->columns),
+ DitherY(y_offset,cache_info->rows),1UL,1UL,*virtual_nexus,
+ exception);
r=GetVirtualMetacontentFromNexus(cache_info,*virtual_nexus);
break;
}
case TileVirtualPixelMethod:
{
- x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
- y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
+ x_modulo=VirtualPixelModulo(x_offset,cache_info->columns);
+ y_modulo=VirtualPixelModulo(y_offset,cache_info->rows);
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
x_modulo.remainder,y_modulo.remainder,1UL,1UL,*virtual_nexus,
exception);
}
case MirrorVirtualPixelMethod:
{
- x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
+ x_modulo=VirtualPixelModulo(x_offset,cache_info->columns);
if ((x_modulo.quotient & 0x01) == 1L)
x_modulo.remainder=(ssize_t) cache_info->columns-
x_modulo.remainder-1L;
- y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
+ y_modulo=VirtualPixelModulo(y_offset,cache_info->rows);
if ((y_modulo.quotient & 0x01) == 1L)
y_modulo.remainder=(ssize_t) cache_info->rows-
y_modulo.remainder-1L;
}
case HorizontalTileEdgeVirtualPixelMethod:
{
- x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
+ x_modulo=VirtualPixelModulo(x_offset,cache_info->columns);
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
- x_modulo.remainder,EdgeY(y+v,cache_info->rows),1UL,1UL,
+ x_modulo.remainder,EdgeY(y_offset,cache_info->rows),1UL,1UL,
*virtual_nexus,exception);
r=GetVirtualMetacontentFromNexus(cache_info,*virtual_nexus);
break;
}
case VerticalTileEdgeVirtualPixelMethod:
{
- y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
+ y_modulo=VirtualPixelModulo(y_offset,cache_info->rows);
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
- EdgeX(x+u,cache_info->columns),y_modulo.remainder,1UL,1UL,
+ EdgeX(x_offset,cache_info->columns),y_modulo.remainder,1UL,1UL,
*virtual_nexus,exception);
r=GetVirtualMetacontentFromNexus(cache_info,*virtual_nexus);
break;
r=virtual_metacontent;
break;
}
- case EdgeVirtualPixelMethod:
case CheckerTileVirtualPixelMethod:
{
- x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
- y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
+ x_modulo=VirtualPixelModulo(x_offset,cache_info->columns);
+ y_modulo=VirtualPixelModulo(y_offset,cache_info->rows);
if (((x_modulo.quotient ^ y_modulo.quotient) & 0x01) != 0L)
{
p=virtual_pixel;
}
case HorizontalTileVirtualPixelMethod:
{
- if (((y+v) < 0) || ((y+v) >= (ssize_t) cache_info->rows))
+ if ((y_offset < 0) || (y_offset >= (ssize_t) cache_info->rows))
{
p=virtual_pixel;
r=virtual_metacontent;
break;
}
- x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
- y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
+ x_modulo=VirtualPixelModulo(x_offset,cache_info->columns);
+ y_modulo=VirtualPixelModulo(y_offset,cache_info->rows);
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
x_modulo.remainder,y_modulo.remainder,1UL,1UL,*virtual_nexus,
exception);
}
case VerticalTileVirtualPixelMethod:
{
- if (((x+u) < 0) || ((x+u) >= (ssize_t) cache_info->columns))
+ if ((x_offset < 0) || (x_offset >= (ssize_t) cache_info->columns))
{
p=virtual_pixel;
r=virtual_metacontent;
break;
}
- x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
- y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
+ x_modulo=VirtualPixelModulo(x_offset,cache_info->columns);
+ y_modulo=VirtualPixelModulo(y_offset,cache_info->rows);
p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
x_modulo.remainder,y_modulo.remainder,1UL,1UL,*virtual_nexus,
exception);
/*
Transfer a run of pixels.
*/
- p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x+u,y+v,(size_t)
- length,1UL,*virtual_nexus,exception);
+ p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x_offset,y_offset,
+ (size_t) length,1UL,*virtual_nexus,exception);
if (p == (const Quantum *) NULL)
break;
r=GetVirtualMetacontentFromNexus(cache_info,*virtual_nexus);
const size_t columns,const size_t rows,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
const Quantum
- *p;
+ *restrict p;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
MagickExport const Quantum *GetVirtualPixelQueue(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
const Quantum
- *p;
+ *restrict p;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
static const Quantum *GetVirtualPixelsCache(const Image *image)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
%
*/
MagickPrivate const Quantum *GetVirtualPixelsNexus(const Cache cache,
- NexusInfo *nexus_info)
+ NexusInfo *restrict nexus_info)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != (Cache) NULL);
cache_info=(CacheInfo *) cache;
}
}
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+#if defined(SIGBUS)
+static void CacheSignalHandler(int status)
+{
+ ThrowFatalException(CacheFatalError,"UnableToExtendPixelCache");
+}
+#endif
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
static MagickBooleanType OpenPixelCacheOnDisk(CacheInfo *cache_info,
const MapMode mode)
{
static MagickBooleanType SetPixelCacheExtent(Image *image,MagickSizeType length)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
MagickOffsetType
count,
if (status != 0)
return(MagickFalse);
}
+#endif
+#if defined(SIGBUS)
+ (void) signal(SIGBUS,CacheSignalHandler);
#endif
return(count != (MagickOffsetType) 1 ? MagickFalse : MagickTrue);
}
ExceptionInfo *exception)
{
CacheInfo
- *cache_info,
+ *restrict cache_info,
source_info;
char
cache_info->storage_class=image->storage_class;
cache_info->colorspace=image->colorspace;
cache_info->alpha_trait=image->alpha_trait;
- cache_info->mask=image->mask;
+ cache_info->read_mask=image->read_mask;
+ cache_info->write_mask=image->write_mask;
cache_info->rows=image->rows;
cache_info->columns=image->columns;
InitializePixelChannelMap(image);
{
status=OpenDistributePixelCache(server_info,image);
if (status == MagickFalse)
- server_info=DestroyDistributeCacheInfo(server_info);
+ {
+ ThrowFileException(exception,CacheError,"UnableToOpenPixelCache",
+ GetDistributeCacheHostname(server_info));
+ server_info=DestroyDistributeCacheInfo(server_info);
+ }
else
{
/*
cache_info->type=DistributedCache;
cache_info->server_info=server_info;
(void) FormatLocaleString(cache_info->cache_filename,
- MaxTextExtent,"%s:%d",
- GetDistributeCacheHostname(cache_info->server_info),
- GetDistributeCachePort(cache_info->server_info));
+ MaxTextExtent,"%s:%d",GetDistributeCacheHostname(
+ (DistributeCacheInfo *) cache_info->server_info),
+ GetDistributeCachePort((DistributeCacheInfo *)
+ cache_info->server_info));
if ((source_info.storage_class != UndefinedClass) &&
(mode != ReadMode))
{
(void) FormatLocaleString(message,MaxTextExtent,
"open %s (%s[%d], %s, %.20gx%.20gx%.20g %s)",
cache_info->filename,cache_info->cache_filename,
- GetDistributeCacheFile(cache_info->server_info),type,
- (double) cache_info->columns,(double) cache_info->rows,
- (double) cache_info->number_channels,format);
+ GetDistributeCacheFile((DistributeCacheInfo *)
+ cache_info->server_info),type,(double) cache_info->columns,
+ (double) cache_info->rows,(double)
+ cache_info->number_channels,format);
(void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",
message);
}
- return(status);
+ return(MagickTrue);
}
}
+ RelinquishMagickResource(DiskResource,cache_info->length);
(void) ThrowMagickException(exception,GetMagickModule(),CacheError,
"CacheResourcesExhausted","`%s'",image->filename);
return(MagickFalse);
ExceptionInfo *exception)
{
CacheInfo
- *cache_info,
- *clone_info;
+ *restrict cache_info,
+ *restrict clone_info;
Image
clone_image;
const MagickBooleanType clone,NexusInfo *nexus_info,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
MagickOffsetType
offset;
number_pixels;
Quantum
- *pixels;
+ *restrict pixels;
RectangleInfo
region;
if (cache_info == (Cache) NULL)
return((Quantum *) NULL);
assert(cache_info->signature == MagickSignature);
- if ((cache_info->columns == 0) && (cache_info->rows == 0))
- {
- (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
- "NoPixelsDefinedInCache","`%s'",image->filename);
- return((Quantum *) NULL);
- }
- if ((x < 0) || (y < 0) || (x >= (ssize_t) cache_info->columns) ||
+ if ((cache_info->columns == 0) || (cache_info->rows == 0) || (x < 0) ||
+ (y < 0) || (x >= (ssize_t) cache_info->columns) ||
(y >= (ssize_t) cache_info->rows))
{
(void) ThrowMagickException(exception,GetMagickModule(),CacheError,
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
Quantum
- *q;
+ *restrict pixels;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
cache_info=(CacheInfo *) image->cache;
assert(cache_info->signature == MagickSignature);
assert(id < (int) cache_info->number_threads);
- q=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickFalse,
+ pixels=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickFalse,
cache_info->nexus_info[id],exception);
- return(q);
+ return(pixels);
}
\f
/*
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
Quantum
- *q;
+ *restrict pixels;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (cache_info->methods.queue_authentic_pixels_handler !=
(QueueAuthenticPixelsHandler) NULL)
{
- q=cache_info->methods.queue_authentic_pixels_handler(image,x,y,columns,
- rows,exception);
- return(q);
+ pixels=cache_info->methods.queue_authentic_pixels_handler(image,x,y,
+ columns,rows,exception);
+ return(pixels);
}
assert(id < (int) cache_info->number_threads);
- q=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickFalse,
+ pixels=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickFalse,
cache_info->nexus_info[id],exception);
- return(q);
+ return(pixels);
}
\f
/*
return(i);
}
-static MagickBooleanType ReadPixelCacheMetacontent(CacheInfo *cache_info,
- NexusInfo *nexus_info,ExceptionInfo *exception)
+static MagickBooleanType ReadPixelCacheMetacontent(
+ CacheInfo *restrict cache_info,NexusInfo *restrict nexus_info,
+ ExceptionInfo *exception)
{
MagickOffsetType
count,
if (cache_info->metacontent_extent == 0)
return(MagickFalse);
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
return(MagickTrue);
offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
nexus_info->region.x;
*/
LockSemaphoreInfo(cache_info->file_semaphore);
region=nexus_info->region;
- region.height=1UL;
+ if ((cache_info->columns != nexus_info->region.width) ||
+ (extent > MagickMaxBufferExtent))
+ region.height=1UL;
+ else
+ {
+ length=extent;
+ rows=1UL;
+ }
for (y=0; y < (ssize_t) rows; y++)
{
- count=ReadDistributePixelCachePixels(cache_info->server_info,®ion,
- length,(unsigned char *) q);
+ count=ReadDistributePixelCacheMetacontent((DistributeCacheInfo *)
+ cache_info->server_info,®ion,length,(unsigned char *) q);
if (count != (MagickOffsetType) length)
break;
q+=cache_info->metacontent_extent*nexus_info->region.width;
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType ReadPixelCachePixels(CacheInfo *cache_info,
- NexusInfo *nexus_info,ExceptionInfo *exception)
+static MagickBooleanType ReadPixelCachePixels(CacheInfo *restrict cache_info,
+ NexusInfo *restrict nexus_info,ExceptionInfo *exception)
{
MagickOffsetType
count,
size_t
rows;
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
return(MagickTrue);
offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
nexus_info->region.x;
*/
LockSemaphoreInfo(cache_info->file_semaphore);
region=nexus_info->region;
- region.height=1UL;
+ if ((cache_info->columns != nexus_info->region.width) ||
+ (extent > MagickMaxBufferExtent))
+ region.height=1UL;
+ else
+ {
+ length=extent;
+ rows=1UL;
+ }
for (y=0; y < (ssize_t) rows; y++)
{
- count=ReadDistributePixelCachePixels(cache_info->server_info,®ion,
- length,(unsigned char *) q);
+ count=ReadDistributePixelCachePixels((DistributeCacheInfo *)
+ cache_info->server_info,®ion,length,(unsigned char *) q);
if (count != (MagickOffsetType) length)
break;
q+=cache_info->number_channels*nexus_info->region.width;
MagickPrivate Cache ReferencePixelCache(Cache cache)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(cache != (Cache *) NULL);
cache_info=(CacheInfo *) cache;
MagickPrivate void SetPixelCacheMethods(Cache cache,CacheMethods *cache_methods)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
GetOneAuthenticPixelFromHandler
get_one_authentic_pixel_from_handler;
return(MagickTrue);
}
+static inline MagickBooleanType IsPixelCacheAuthentic(
+ const CacheInfo *restrict cache_info,const NexusInfo *restrict nexus_info)
+{
+ MagickBooleanType
+ status;
+
+ MagickOffsetType
+ offset;
+
+ /*
+ Does nexus pixels point directly to in-core cache pixels or is it buffered?
+ */
+ if (cache_info->type == PingCache)
+ return(MagickTrue);
+ offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
+ nexus_info->region.x;
+ status=nexus_info->pixels == (cache_info->pixels+offset*
+ cache_info->number_channels) ? MagickTrue : MagickFalse;
+ return(status);
+}
+
static inline void PrefetchPixelCacheNexusPixels(const NexusInfo *nexus_info,
const MapMode mode)
{
nexus_info->metacontent=(unsigned char *) cache_info->metacontent+
offset*cache_info->metacontent_extent;
PrefetchPixelCacheNexusPixels(nexus_info,mode);
+ nexus_info->authentic_pixel_cache=IsPixelCacheAuthentic(cache_info,
+ nexus_info);
return(nexus_info->pixels);
}
}
/*
- Pixels are stored in a cache region until they are synced to the cache.
+ Pixels are stored in a staging region until they are synced to the cache.
*/
number_pixels=(MagickSizeType) nexus_info->region.width*
nexus_info->region.height;
}
}
else
- if (nexus_info->length != length)
+ if (nexus_info->length < length)
{
RelinquishCacheNexusPixels(nexus_info);
nexus_info->length=length;
nexus_info->metacontent=(void *) (nexus_info->pixels+number_pixels*
cache_info->number_channels);
PrefetchPixelCacheNexusPixels(nexus_info,mode);
+ nexus_info->authentic_pixel_cache=IsPixelCacheAuthentic(cache_info,
+ nexus_info);
return(nexus_info->pixels);
}
\f
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
CacheView
- *image_view;
+ *restrict image_view;
MagickBooleanType
status;
const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
VirtualPixelMethod
method;
(void) SetCacheAlphaChannel(image,OpaqueAlpha,exception);
if ((IsPixelInfoGray(&image->background_color) == MagickFalse) &&
(IsGrayColorspace(image->colorspace) != MagickFalse))
- (void) TransformImageColorspace(image,RGBColorspace,exception);
+ (void) SetImageColorspace(image,sRGBColorspace,exception);
break;
}
case TransparentVirtualPixelMethod:
%
*/
MagickPrivate MagickBooleanType SyncAuthenticPixelCacheNexus(Image *image,
- NexusInfo *nexus_info,ExceptionInfo *exception)
+ NexusInfo *restrict nexus_info,ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
MagickBooleanType
status;
assert(cache_info->signature == MagickSignature);
if (cache_info->type == UndefinedCache)
return(MagickFalse);
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
return(MagickTrue);
assert(cache_info->signature == MagickSignature);
status=WritePixelCachePixels(cache_info,nexus_info,exception);
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
const int
id = GetOpenMPThreadId();
ExceptionInfo *exception)
{
CacheInfo
- *cache_info;
+ *restrict cache_info;
assert(image != (Image *) NULL);
assert(exception != (ExceptionInfo *) NULL);
%
*/
static MagickBooleanType WritePixelCacheMetacontent(CacheInfo *cache_info,
- NexusInfo *nexus_info,ExceptionInfo *exception)
+ NexusInfo *restrict nexus_info,ExceptionInfo *exception)
{
MagickOffsetType
count,
if (cache_info->metacontent_extent == 0)
return(MagickFalse);
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
return(MagickTrue);
offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
nexus_info->region.x;
*/
LockSemaphoreInfo(cache_info->file_semaphore);
region=nexus_info->region;
- region.height=1UL;
+ if ((cache_info->columns != nexus_info->region.width) ||
+ (extent > MagickMaxBufferExtent))
+ region.height=1UL;
+ else
+ {
+ length=extent;
+ rows=1UL;
+ }
for (y=0; y < (ssize_t) rows; y++)
{
- count=WriteDistributePixelCachePixels(cache_info->server_info,®ion,
- length,(const unsigned char *) p);
+ count=WriteDistributePixelCacheMetacontent((DistributeCacheInfo *)
+ cache_info->server_info,®ion,length,(const unsigned char *) p);
if (count != (MagickOffsetType) length)
break;
p+=cache_info->metacontent_extent*nexus_info->region.width;
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType WritePixelCachePixels(CacheInfo *cache_info,
- NexusInfo *nexus_info,ExceptionInfo *exception)
+static MagickBooleanType WritePixelCachePixels(CacheInfo *restrict cache_info,
+ NexusInfo *restrict nexus_info,ExceptionInfo *exception)
{
MagickOffsetType
count,
size_t
rows;
- if (IsPixelAuthentic(cache_info,nexus_info) != MagickFalse)
+ if (nexus_info->authentic_pixel_cache != MagickFalse)
return(MagickTrue);
offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
nexus_info->region.x;
*/
LockSemaphoreInfo(cache_info->file_semaphore);
region=nexus_info->region;
- region.height=1UL;
+ if ((cache_info->columns != nexus_info->region.width) ||
+ (extent > MagickMaxBufferExtent))
+ region.height=1UL;
+ else
+ {
+ length=extent;
+ rows=1UL;
+ }
for (y=0; y < (ssize_t) rows; y++)
{
- count=WriteDistributePixelCachePixels(cache_info->server_info,®ion,
- length,(const unsigned char *) p);
+ count=WriteDistributePixelCachePixels((DistributeCacheInfo *)
+ cache_info->server_info,®ion,length,(const unsigned char *) p);
if (count != (MagickOffsetType) length)
break;
p+=cache_info->number_channels*nexus_info->region.width;