]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/cache.c
(no commit message)
[imagemagick] / MagickCore / cache.c
index f571a56d01cdf16cedc4525b396afca27339a347..59b3f3d12f705ede390ee38317df159697634942 100644 (file)
@@ -54,6 +54,7 @@
 #include "MagickCore/log.h"
 #include "MagickCore/magick.h"
 #include "MagickCore/memory_.h"
+#include "MagickCore/nt-base-private.h"
 #include "MagickCore/pixel.h"
 #include "MagickCore/pixel-accessor.h"
 #include "MagickCore/policy.h"
@@ -242,7 +243,7 @@ MagickPrivate NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
   register ssize_t
     i;
 
-  nexus_info=(NexusInfo **) AcquireQuantumMemory(number_threads,
+  nexus_info=(NexusInfo **) AcquireAlignedMemory(number_threads,
     sizeof(*nexus_info));
   if (nexus_info == (NexusInfo **) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
@@ -1324,7 +1325,7 @@ MagickPrivate Cache DestroyPixelCache(Cache cache)
 static inline void RelinquishCacheNexusPixels(NexusInfo *nexus_info)
 {
   if (nexus_info->mapped == MagickFalse)
-    (void) RelinquishAlignedMemory(nexus_info->cache);
+    (void) RelinquishMagickMemory(nexus_info->cache);
   else
     (void) UnmapBlob(nexus_info->cache,(size_t) nexus_info->length);
   nexus_info->cache=(Quantum *) NULL;
@@ -1348,7 +1349,7 @@ MagickPrivate NexusInfo **DestroyPixelCacheNexus(NexusInfo **nexus_info,
     nexus_info[i]->signature=(~MagickSignature);
   }
   nexus_info[0]=(NexusInfo *) RelinquishMagickMemory(nexus_info[0]);
-  nexus_info=(NexusInfo **) RelinquishMagickMemory(nexus_info);
+  nexus_info=(NexusInfo **) RelinquishAlignedMemory(nexus_info);
   return(nexus_info);
 }
 \f
@@ -4729,7 +4730,7 @@ static inline MagickBooleanType AcquireCacheNexusPixels(CacheInfo *cache_info,
   if (nexus_info->length != (MagickSizeType) ((size_t) nexus_info->length))
     return(MagickFalse);
   nexus_info->mapped=MagickFalse;
-  nexus_info->cache=(Quantum *) AcquireAlignedMemory(1,(size_t)
+  nexus_info->cache=(Quantum *) AcquireMagickMemory((size_t)
     nexus_info->length);
   if (nexus_info->cache == (Quantum *) NULL)
     {
@@ -4867,6 +4868,9 @@ static Quantum *SetPixelCacheNexusPixels(const Image *image,
 static MagickBooleanType SetCacheAlphaChannel(Image *image,const Quantum alpha,
   ExceptionInfo *exception)
 {
+  CacheView
+    *image_view;
+
   CacheInfo
     *cache_info;
 
@@ -4885,14 +4889,12 @@ static MagickBooleanType SetCacheAlphaChannel(Image *image,const Quantum alpha,
   assert(cache_info->signature == MagickSignature);
   image->matte=MagickTrue;
   status=MagickTrue;
+  image_view=AcquireCacheView(image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(static,4) shared(status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    const int
-      id = GetOpenMPThreadId();
-
     register Quantum
       *restrict q;
 
@@ -4901,8 +4903,7 @@ static MagickBooleanType SetCacheAlphaChannel(Image *image,const Quantum alpha,
 
     if (status == MagickFalse)
       continue;
-    q=GetAuthenticPixelCacheNexus(image,0,y,image->columns,1,
-      cache_info->nexus_info[id],exception);
+    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
     if (q == (Quantum *) NULL)
       {
         status=MagickFalse;
@@ -4913,9 +4914,9 @@ static MagickBooleanType SetCacheAlphaChannel(Image *image,const Quantum alpha,
       SetPixelAlpha(image,alpha,q);
       q+=GetPixelChannels(image);
     }
-    status=SyncAuthenticPixelCacheNexus(image,cache_info->nexus_info[id],
-      exception);
+    status=SyncCacheViewAuthenticPixels(image_view,exception);
   }
+  image_view=DestroyCacheView(image_view);
   return(status);
 }