% MagickCore Cache View Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% February 2000 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2015 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 %
#include "MagickCore/cache-private.h"
#include "MagickCore/cache-view.h"
#include "MagickCore/memory_.h"
+#include "MagickCore/memory-private.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/pixel-accessor.h"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
+% It always succeeds but may return a warning or informational exception.
%
% The format of the AcquireAuthenticCacheView method is:
%
ExceptionInfo *exception)
{
CacheView
- *cache_view;
-
- MagickBooleanType
- status;
+ *restrict cache_view;
cache_view=AcquireVirtualCacheView(image,exception);
- status=SyncImagePixelCache(cache_view->image,exception);
- if (status == MagickFalse)
- ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
+ (void) SyncImagePixelCache(cache_view->image,exception);
return(cache_view);
}
\f
%
% AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
% using the VirtualPixelMethod that is defined within the given image itself.
+% It always succeeds but may return a warning or informational exception.
%
% The format of the AcquireVirtualCacheView method is:
%
ExceptionInfo *exception)
{
CacheView
- *cache_view;
+ *restrict cache_view;
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
(void) exception;
- cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
+ cache_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
+ sizeof(*cache_view)));
if (cache_view == (CacheView *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
cache_view->image=ReferenceImage((Image *) image);
cache_view->number_threads=GetOpenMPMaximumThreads();
+ if (GetMagickResourceLimit(ThreadResource) > cache_view->number_threads)
+ cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
+ if (cache_view->number_threads == 0)
+ cache_view->number_threads=1;
cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
cache_view->debug=IsEventLogging();
- cache_view->signature=MagickSignature;
+ cache_view->signature=MagickCoreSignature;
if (cache_view->nexus_info == (NexusInfo **) NULL)
ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
return(cache_view);
MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
{
CacheView
- *clone_view;
+ *restrict clone_view;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
- clone_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*clone_view));
+ clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
+ sizeof(*clone_view)));
if (clone_view == (CacheView *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
clone_view->debug=cache_view->debug;
- clone_view->signature=MagickSignature;
+ clone_view->signature=MagickCoreSignature;
return(clone_view);
}
\f
MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
{
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
cache_view->number_threads);
cache_view->image=DestroyImage(cache_view->image);
- cache_view->signature=(~MagickSignature);
- cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
+ cache_view->signature=(~MagickCoreSignature);
+ cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
return(cache_view);
}
\f
id = GetOpenMPThreadId();
Quantum
- *pixels;
+ *restrict pixels;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
cache_view->nexus_info[id],exception);
const int
id = GetOpenMPThreadId();
- void
- *metacontent;
-
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(cache_view->image->cache != (Cache) NULL);
assert(id < (int) cache_view->number_threads);
- metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
- cache_view->nexus_info[id]);
- return(metacontent);
+ return(cache_view->nexus_info[id]->metacontent);
}
\f
/*
const int
id = GetOpenMPThreadId();
- Quantum
- *pixels;
-
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(cache_view->image->cache != (Cache) NULL);
assert(id < (int) cache_view->number_threads);
- pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
- cache_view->nexus_info[id]);
- return(pixels);
+ return(cache_view->nexus_info[id]->pixels);
}
\f
/*
MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
{
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
extent;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
{
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
{
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
id = GetOpenMPThreadId();
const void
- *metacontent;
+ *restrict metacontent;
assert(cache_view != (const CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(cache_view->image->cache != (Cache) NULL);
assert(id < (int) cache_view->number_threads);
metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
id = GetOpenMPThreadId();
const Quantum
- *pixels;
+ *restrict pixels;
assert(cache_view != (const CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(cache_view->image->cache != (Cache) NULL);
assert(id < (int) cache_view->number_threads);
pixels=GetVirtualPixelsNexus(cache_view->image->cache,
id = GetOpenMPThreadId();
const Quantum
- *pixels;
+ *restrict pixels;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
pixels=GetVirtualPixelsFromNexus(cache_view->image,
cache_view->virtual_pixel_method,x,y,columns,rows,
id = GetOpenMPThreadId();
Quantum
- *p;
+ *restrict q;
register ssize_t
i;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
(void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
- p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
+ q=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
cache_view->nexus_info[id],exception);
- if (p == (const Quantum *) NULL)
+ if (q == (const Quantum *) NULL)
{
PixelInfo
background_color;
}
for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelMapChannel(cache_view->image,i);
- pixel[channel]=p[i];
+ PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
+ pixel[channel]=q[i];
}
return(MagickTrue);
}
id = GetOpenMPThreadId();
register const Quantum
- *p;
+ *restrict p;
register ssize_t
i;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
(void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
p=GetVirtualPixelsFromNexus(cache_view->image,
}
for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelMapChannel(cache_view->image,i);
+ PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
pixel[channel]=p[i];
}
return(MagickTrue);
id = GetOpenMPThreadId();
register const Quantum
- *p;
+ *restrict p;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
GetPixelInfo(cache_view->image,pixel);
p=GetVirtualPixelsFromNexus(cache_view->image,
id = GetOpenMPThreadId();
const Quantum
- *p;
+ *restrict p;
register ssize_t
i;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
(void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
}
for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
{
- PixelChannel
- channel;
-
- channel=GetPixelChannelMapChannel(cache_view->image,i);
+ PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
pixel[channel]=p[i];
}
return(MagickTrue);
id = GetOpenMPThreadId();
Quantum
- *pixels;
+ *restrict pixels;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
MagickFalse,cache_view->nexus_info[id],exception);
const ClassType storage_class,ExceptionInfo *exception)
{
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
%
*/
MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
- CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
+ CacheView *restrict cache_view,const VirtualPixelMethod virtual_pixel_method)
{
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
if (cache_view->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
cache_view->image->filename);
%
*/
MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
- CacheView *cache_view,ExceptionInfo *exception)
+ CacheView *restrict cache_view,ExceptionInfo *exception)
{
const int
id = GetOpenMPThreadId();
status;
assert(cache_view != (CacheView *) NULL);
- assert(cache_view->signature == MagickSignature);
+ assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
status=SyncAuthenticPixelCacheNexus(cache_view->image,
cache_view->nexus_info[id],exception);