]> granicus.if.org Git - imagemagick/commitdiff
Improve the handling of clip / composite masks
authorCristy <urban-warrior@imagemagick.org>
Sat, 19 May 2018 13:15:14 +0000 (09:15 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 19 May 2018 13:15:14 +0000 (09:15 -0400)
MagickCore/accelerate.c
MagickCore/cache-private.h
MagickCore/cache.c
MagickCore/channel.c
MagickCore/distribute-cache.c
MagickCore/image.c
MagickCore/image.h
MagickCore/pixel.c
PerlMagick/quantum/quantum.xs.in
coders/clip.c
coders/ps3.c

index 923926cdf4b3f3d18730f276277b555e199fe072..2d76492348ab7a618f392c6b0e0ca5edce622aa3 100644 (file)
@@ -124,9 +124,9 @@ static MagickBooleanType checkAccelerateCondition(const Image* image)
     return(MagickFalse);
 
   /* check if the image has mask */
-  if (image->composite_mask != MagickFalse ||
-      image->read_mask != MagickFalse ||
-      image->write_mask != MagickFalse)
+  if (((image->channels & ReadMaskChannel) != 0) ||
+      ((image->channels & WriteMaskChannel) != 0) ||
+      ((image->channels & CompositeMaskChannel) != 0))
     return(MagickFalse);
 
   if (image->number_channels > 4)
@@ -248,10 +248,10 @@ static Image *cloneImage(const Image* image,ExceptionInfo *exception)
   return(clone);
 }
 
-/* pad the global workgroup size to the next multiple of 
+/* pad the global workgroup size to the next multiple of
    the local workgroup size */
 inline static unsigned int padGlobalWorkgroupSizeToLocalWorkgroupSize(
-  const unsigned int orgGlobalSize,const unsigned int localGroupSize) 
+  const unsigned int orgGlobalSize,const unsigned int localGroupSize)
 {
   return ((orgGlobalSize+(localGroupSize-1))/localGroupSize*localGroupSize);
 }
@@ -332,7 +332,7 @@ static MagickBooleanType LaunchHistogramKernel(MagickCLEnv clEnv,
   size_t
     global_work_size[2];
 
-  histogramKernel = NULL; 
+  histogramKernel = NULL;
 
   outputReady = MagickFalse;
   colorspace = image->colorspace;
@@ -375,7 +375,7 @@ static MagickBooleanType LaunchHistogramKernel(MagickCLEnv clEnv,
   outputReady = MagickTrue;
 
 cleanup:
+
   if (histogramKernel!=NULL)
     ReleaseOpenCLKernel(histogramKernel);
 
@@ -990,8 +990,8 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
   imageBuffer = NULL;
   histogramBuffer = NULL;
   stretchMapBuffer = NULL;
-  histogramKernel = NULL; 
-  stretchKernel = NULL; 
+  histogramKernel = NULL;
+  stretchKernel = NULL;
   queue = NULL;
   outputReady = MagickFalse;
 
@@ -1016,7 +1016,7 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
 
   if (histogram == (cl_uint4 *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename);
+
   /* reset histogram */
   (void) memset(histogram,0,(MaxMap+1)*sizeof(*histogram));
 
@@ -1042,14 +1042,14 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
     (void) OpenCLThrowMagickException(device,exception,GetMagickModule(),CacheWarning,"UnableToReadPixelCache.","`%s'",image->filename);
     goto cleanup;
   }
-  /* If the host pointer is aligned to the size of CLPixelPacket, 
-     then use the host buffer directly from the GPU; otherwise, 
+  /* If the host pointer is aligned to the size of CLPixelPacket,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR;
   }
@@ -1062,21 +1062,21 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
     goto cleanup;
   }
 
-  /* If the host pointer is aligned to the size of cl_uint, 
-     then use the host buffer directly from the GPU; otherwise, 
+  /* If the host pointer is aligned to the size of cl_uint,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(histogram,cl_uint4)) 
+  if (ALIGNED(histogram,cl_uint4))
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_USE_HOST_PTR;
     hostPtr = histogram;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
     hostPtr = histogram;
   }
   /* create a CL buffer for histogram  */
-  length = (MaxMap+1); 
+  length = (MaxMap+1);
   histogramBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags, length * sizeof(cl_uint4), hostPtr, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
@@ -1089,14 +1089,14 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
     goto cleanup;
 
   /* read from the kenel output */
-  if (ALIGNED(histogram,cl_uint4)) 
+  if (ALIGNED(histogram,cl_uint4))
   {
-    length = (MaxMap+1); 
+    length = (MaxMap+1);
     clEnv->library->clEnqueueMapBuffer(queue, histogramBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(cl_uint4), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
-    length = (MaxMap+1); 
+    length = (MaxMap+1);
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, histogramBuffer, CL_TRUE, 0, length * sizeof(cl_uint4), histogram, 0, NULL, NULL);
   }
   if (clStatus != CL_SUCCESS)
@@ -1117,8 +1117,8 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
   }
 
   /* recreate input buffer later, in case image updated */
-#ifdef RECREATEBUFFER 
-  if (imageBuffer!=NULL)                     
+#ifdef RECREATEBUFFER
+  if (imageBuffer!=NULL)
     clEnv->library->clReleaseMemObject(imageBuffer);
 #endif
 
@@ -1217,7 +1217,7 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
   if (stretch_map == (PixelPacket *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
+
   /*
     Stretch the histogram to create the stretched image mapping.
   */
@@ -1324,15 +1324,15 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
     stretch_map:  uchar4 (PixelPacket)
     black, white: float4 (FloatPixelPacket) */
 
-#ifdef RECREATEBUFFER 
-  /* If the host pointer is aligned to the size of CLPixelPacket, 
-     then use the host buffer directly from the GPU; otherwise, 
+#ifdef RECREATEBUFFER
+  /* If the host pointer is aligned to the size of CLPixelPacket,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
   }
@@ -1347,18 +1347,18 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
 #endif
 
   /* Create and initialize OpenCL buffers. */
-  if (ALIGNED(stretch_map, PixelPacket)) 
+  if (ALIGNED(stretch_map, PixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
     hostPtr = stretch_map;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
     hostPtr = stretch_map;
   }
   /* create a CL buffer for stretch_map  */
-  length = (MaxMap+1); 
+  length = (MaxMap+1);
   stretchMapBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags, length * sizeof(PixelPacket), hostPtr, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
@@ -1401,12 +1401,12 @@ static MagickBooleanType ComputeContrastStretchImage(Image *image,
   RecordProfileData(device,stretchKernel,event);
 
   /* read the data back */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
     clEnv->library->clEnqueueMapBuffer(queue, imageBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, imageBuffer, CL_TRUE, 0, length * sizeof(CLPixelPacket), inputPixels, 0, NULL, NULL);
@@ -1423,7 +1423,7 @@ cleanup:
 
   image_view=DestroyCacheView(image_view);
 
-  if (imageBuffer!=NULL)                     
+  if (imageBuffer!=NULL)
     clEnv->library->clReleaseMemObject(imageBuffer);
 
   if (stretchMapBuffer!=NULL)
@@ -1572,14 +1572,14 @@ static Image *ComputeConvolveImage(const Image* image,MagickCLEnv clEnv,
 
   /* Create and initialize OpenCL buffers. */
 
-  /* If the host pointer is aligned to the size of CLPixelPacket, 
-     then use the host buffer directly from the GPU; otherwise, 
+  /* If the host pointer is aligned to the size of CLPixelPacket,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR;
   }
@@ -1607,12 +1607,12 @@ static Image *ComputeConvolveImage(const Image* image,MagickCLEnv clEnv,
     goto cleanup;
   }
 
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR;
     hostPtr = filteredPixels;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_WRITE_ONLY;
     hostPtr = NULL;
@@ -1752,7 +1752,7 @@ static Image *ComputeConvolveImage(const Image* image,MagickCLEnv clEnv,
     global_work_size[0] = (image->columns + (localGroupSize[0]-1))/localGroupSize[0] * localGroupSize[0];
     global_work_size[1] = (image->rows    + (localGroupSize[1]-1))/localGroupSize[1] * localGroupSize[1];
        clStatus = clEnv->library->clEnqueueNDRangeKernel(queue, clkernel, 2, NULL, global_work_size, localGroupSize, 0, NULL, &event);
-    
+
     if (clStatus != CL_SUCCESS)
     {
       (void) OpenCLThrowMagickException(device,exception, GetMagickModule(), ResourceLimitWarning, "clEnv->library->clEnqueueNDRangeKernel failed.", ".");
@@ -1761,12 +1761,12 @@ static Image *ComputeConvolveImage(const Image* image,MagickCLEnv clEnv,
   }
   RecordProfileData(device,clkernel,event);
 
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
     clEnv->library->clEnqueueMapBuffer(queue, filteredImageBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, filteredImageBuffer, CL_TRUE, 0, length * sizeof(CLPixelPacket), filteredPixels, 0, NULL, NULL);
@@ -1847,7 +1847,7 @@ MagickPrivate Image *AccelerateConvolveImage(const Image *image,
 static Image *ComputeDespeckleImage(const Image *image,MagickCLEnv clEnv,
   ExceptionInfo*exception)
 {
-  static const int 
+  static const int
     X[4] = {0, 1, 1,-1},
     Y[4] = {1, 0, 1, 1};
 
@@ -1920,7 +1920,7 @@ static Image *ComputeDespeckleImage(const Image *image,MagickCLEnv clEnv,
 
   device = RequestOpenCLDevice(clEnv);
   queue = AcquireOpenCLCommandQueue(device);
+
   image_view=AcquireAuthenticCacheView(image,exception);
   inputPixels=GetCacheViewAuthenticPixels(image_view,0,0,image->columns,image->rows,exception);
   if (inputPixels == (void *) NULL)
@@ -1929,11 +1929,11 @@ static Image *ComputeDespeckleImage(const Image *image,MagickCLEnv clEnv,
     goto cleanup;
   }
 
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR;
   }
@@ -1973,12 +1973,12 @@ static Image *ComputeDespeckleImage(const Image *image,MagickCLEnv clEnv,
     goto cleanup;
   }
 
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR;
     hostPtr = filteredPixels;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_WRITE_ONLY;
     hostPtr = NULL;
@@ -2027,13 +2027,13 @@ static Image *ComputeDespeckleImage(const Image *image,MagickCLEnv clEnv,
   global_work_size[0] = image->columns;
   global_work_size[1] = image->rows;
 
-  
+
   for (k = 0; k < 4; k++)
   {
     cl_int2 offset;
     int polarity;
 
-    
+
     offset.s[0] = X[k];
     offset.s[1] = Y[k];
     polarity = 1;
@@ -2161,12 +2161,12 @@ static Image *ComputeDespeckleImage(const Image *image,MagickCLEnv clEnv,
     RecordProfileData(device,hullPass2,event);
   }
 
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
     clEnv->library->clEnqueueMapBuffer(queue, filteredImageBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, filteredImageBuffer, CL_TRUE, 0, length * sizeof(CLPixelPacket), filteredPixels, 0, NULL, NULL);
@@ -2311,8 +2311,8 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
   imageBuffer = NULL;
   histogramBuffer = NULL;
   equalizeMapBuffer = NULL;
-  histogramKernel = NULL; 
-  equalizeKernel = NULL; 
+  histogramKernel = NULL;
+  equalizeKernel = NULL;
   queue = NULL;
   outputReady = MagickFalse;
 
@@ -2348,14 +2348,14 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
     (void) OpenCLThrowMagickException(device,exception,GetMagickModule(),CacheWarning,"UnableToReadPixelCache.","`%s'",image->filename);
     goto cleanup;
   }
-  /* If the host pointer is aligned to the size of CLPixelPacket, 
-     then use the host buffer directly from the GPU; otherwise, 
+  /* If the host pointer is aligned to the size of CLPixelPacket,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR;
   }
@@ -2368,21 +2368,21 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
     goto cleanup;
   }
 
-  /* If the host pointer is aligned to the size of cl_uint, 
-     then use the host buffer directly from the GPU; otherwise, 
+  /* If the host pointer is aligned to the size of cl_uint,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(histogram,cl_uint4)) 
+  if (ALIGNED(histogram,cl_uint4))
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_USE_HOST_PTR;
     hostPtr = histogram;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
     hostPtr = histogram;
   }
   /* create a CL buffer for histogram  */
-  length = (MaxMap+1); 
+  length = (MaxMap+1);
   histogramBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags, length * sizeof(cl_uint4), hostPtr, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
@@ -2395,14 +2395,14 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
     goto cleanup;
 
   /* read from the kenel output */
-  if (ALIGNED(histogram,cl_uint4)) 
+  if (ALIGNED(histogram,cl_uint4))
   {
-    length = (MaxMap+1); 
+    length = (MaxMap+1);
     clEnv->library->clEnqueueMapBuffer(queue, histogramBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(cl_uint4), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
-    length = (MaxMap+1); 
+    length = (MaxMap+1);
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, histogramBuffer, CL_TRUE, 0, length * sizeof(cl_uint4), histogram, 0, NULL, NULL);
   }
   if (clStatus != CL_SUCCESS)
@@ -2423,11 +2423,11 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
   }
 
   /* recreate input buffer later, in case image updated */
-#ifdef RECREATEBUFFER 
-  if (imageBuffer!=NULL)                     
+#ifdef RECREATEBUFFER
+  if (imageBuffer!=NULL)
     clEnv->library->clReleaseMemObject(imageBuffer);
 #endif
+
   /* CPU stuff */
   equalize_map=(PixelPacket *) AcquireQuantumMemory(MaxMap+1UL, sizeof(*equalize_map));
   if (equalize_map == (PixelPacket *) NULL)
@@ -2531,15 +2531,15 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
     equalize_map: uchar4 (PixelPacket)
     black, white: float4 (FloatPixelPacket) */
 
-#ifdef RECREATEBUFFER 
-  /* If the host pointer is aligned to the size of CLPixelPacket, 
-     then use the host buffer directly from the GPU; otherwise, 
+#ifdef RECREATEBUFFER
+  /* If the host pointer is aligned to the size of CLPixelPacket,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
   }
@@ -2554,18 +2554,18 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
 #endif
 
   /* Create and initialize OpenCL buffers. */
-  if (ALIGNED(equalize_map, PixelPacket)) 
+  if (ALIGNED(equalize_map, PixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
     hostPtr = equalize_map;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
     hostPtr = equalize_map;
   }
   /* create a CL buffer for eqaulize_map  */
-  length = (MaxMap+1); 
+  length = (MaxMap+1);
   equalizeMapBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags, length * sizeof(PixelPacket), hostPtr, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
@@ -2608,12 +2608,12 @@ static MagickBooleanType ComputeEqualizeImage(Image *image,MagickCLEnv clEnv,
   RecordProfileData(device,equalizeKernel,event);
 
   /* read the data back */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
     clEnv->library->clEnqueueMapBuffer(queue, imageBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, imageBuffer, CL_TRUE, 0, length * sizeof(CLPixelPacket), inputPixels, 0, NULL, NULL);
@@ -3045,14 +3045,14 @@ static Image *ComputeLocalContrastImage(const Image *image,MagickCLEnv clEnv,
       goto cleanup;
     }
 
-    /* If the host pointer is aligned to the size of CLPixelPacket, 
-     then use the host buffer directly from the GPU; otherwise, 
+    /* If the host pointer is aligned to the size of CLPixelPacket,
+     then use the host buffer directly from the GPU; otherwise,
      create a buffer on the GPU and copy the data over */
-    if (ALIGNED(inputPixels,CLPixelPacket)) 
+    if (ALIGNED(inputPixels,CLPixelPacket))
     {
       mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
     }
-    else 
+    else
     {
       mem_flags = CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR;
     }
@@ -3083,12 +3083,12 @@ static Image *ComputeLocalContrastImage(const Image *image,MagickCLEnv clEnv,
       goto cleanup;
     }
 
-    if (ALIGNED(filteredPixels,CLPixelPacket)) 
+    if (ALIGNED(filteredPixels,CLPixelPacket))
     {
       mem_flags = CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR;
       hostPtr = filteredPixels;
     }
-    else 
+    else
     {
       mem_flags = CL_MEM_WRITE_ONLY;
       hostPtr = NULL;
@@ -3149,7 +3149,7 @@ static Image *ComputeLocalContrastImage(const Image *image,MagickCLEnv clEnv,
       clStatus|=clEnv->library->clSetKernelArg(blurRowKernel,i++,sizeof(cl_int),(void *)&iRadius);
       clStatus|=clEnv->library->clSetKernelArg(blurRowKernel,i++,sizeof(unsigned int),(void *)&imageColumns);
       clStatus|=clEnv->library->clSetKernelArg(blurRowKernel,i++,sizeof(unsigned int),(void *)&imageRows);
-      
+
       if (clStatus != CL_SUCCESS)
       {
         (void) OpenCLThrowMagickException(device,exception, GetMagickModule(), ResourceLimitWarning, "clEnv->library->clSetKernelArg failed.", ".");
@@ -3229,12 +3229,12 @@ static Image *ComputeLocalContrastImage(const Image *image,MagickCLEnv clEnv,
   }
 
   /* get result */
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
     clEnv->library->clEnqueueMapBuffer(queue, filteredImageBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, filteredImageBuffer, CL_TRUE, 0, length * sizeof(CLPixelPacket), filteredPixels, 0, NULL, NULL);
@@ -3366,7 +3366,7 @@ static MagickBooleanType ComputeModulateImage(Image *image,MagickCLEnv clEnv,
 
   inputPixels = NULL;
   imageBuffer = NULL;
-  modulateKernel = NULL; 
+  modulateKernel = NULL;
 
   assert(image != (Image *) NULL);
   assert(image->signature == MagickCoreSignature);
@@ -3393,15 +3393,15 @@ static MagickBooleanType ComputeModulateImage(Image *image,MagickCLEnv clEnv,
     goto cleanup;
   }
 
-  /* If the host pointer is aligned to the size of CLPixelPacket, 
-   then use the host buffer directly from the GPU; otherwise, 
+  /* If the host pointer is aligned to the size of CLPixelPacket,
+   then use the host buffer directly from the GPU; otherwise,
    create a buffer on the GPU and copy the data over
    */
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR;
   }
@@ -3452,12 +3452,12 @@ static MagickBooleanType ComputeModulateImage(Image *image,MagickCLEnv clEnv,
     RecordProfileData(device,modulateKernel,event);
   }
 
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
     clEnv->library->clEnqueueMapBuffer(queue, imageBuffer, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
     clStatus = clEnv->library->clEnqueueReadBuffer(queue, imageBuffer, CL_TRUE, 0, length * sizeof(CLPixelPacket), inputPixels, 0, NULL, NULL);
@@ -3554,7 +3554,7 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
   cl_mem
     filteredImageBuffer,
     imageBuffer,
-    imageKernelBuffer, 
+    imageKernelBuffer,
     offsetBuffer;
 
   cl_mem_flags
@@ -3620,20 +3620,20 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
     goto cleanup;
   }
 
-  // If the host pointer is aligned to the size of CLPixelPacket, 
-  // then use the host buffer directly from the GPU; otherwise, 
+  // If the host pointer is aligned to the size of CLPixelPacket,
+  // then use the host buffer directly from the GPU; otherwise,
   // create a buffer on the GPU and copy the data over
-  if (ALIGNED(inputPixels,CLPixelPacket)) 
+  if (ALIGNED(inputPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR;
   }
   // create a CL buffer from image pixel buffer
   length = image->columns * image->rows;
-  imageBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags, 
+  imageBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags,
     length * sizeof(CLPixelPacket), (void*)inputPixels, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
@@ -3648,7 +3648,7 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
   assert(filteredImage != NULL);
   if (SetImageStorageClass(filteredImage,DirectClass,exception) != MagickTrue)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), 
+    (void) ThrowMagickException(exception, GetMagickModule(),
       ResourceLimitError, "CloneImage failed.", ".");
     goto cleanup;
   }
@@ -3656,49 +3656,49 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
   filteredPixels=GetCacheViewAuthenticPixels(filteredImage_view,0,0,filteredImage->columns,filteredImage->rows,exception);
   if (filteredPixels == (void *) NULL)
   {
-    (void) ThrowMagickException(exception,GetMagickModule(),CacheError, 
+    (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
       "UnableToReadPixelCache.","`%s'",filteredImage->filename);
     goto cleanup;
   }
 
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     mem_flags = CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR;
     hostPtr = filteredPixels;
   }
-  else 
+  else
   {
     mem_flags = CL_MEM_WRITE_ONLY;
     hostPtr = NULL;
   }
   // create a CL buffer from image pixel buffer
   length = image->columns * image->rows;
-  filteredImageBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags, 
+  filteredImageBuffer = clEnv->library->clCreateBuffer(device->context, mem_flags,
     length * sizeof(CLPixelPacket), hostPtr, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), 
+    (void) ThrowMagickException(exception, GetMagickModule(),
       ResourceLimitError, "clEnv->library->clCreateBuffer failed.",".");
     goto cleanup;
   }
 
 
-  imageKernelBuffer = clEnv->library->clCreateBuffer(device->context, 
+  imageKernelBuffer = clEnv->library->clCreateBuffer(device->context,
     CL_MEM_READ_ONLY|CL_MEM_ALLOC_HOST_PTR, width * sizeof(float), NULL,
     &clStatus);
   if (clStatus != CL_SUCCESS)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), 
+    (void) ThrowMagickException(exception, GetMagickModule(),
       ResourceLimitError, "clEnv->library->clCreateBuffer failed.",".");
     goto cleanup;
   }
 
   queue = AcquireOpenCLCommandQueue(device);
-  kernelBufferPtr = (float*)clEnv->library->clEnqueueMapBuffer(queue, imageKernelBuffer, 
+  kernelBufferPtr = (float*)clEnv->library->clEnqueueMapBuffer(queue, imageKernelBuffer,
     CL_TRUE, CL_MAP_WRITE, 0, width * sizeof(float), 0, NULL, NULL, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), 
+    (void) ThrowMagickException(exception, GetMagickModule(),
       ResourceLimitError, "clEnv->library->clEnqueueMapBuffer failed.",".");
     goto cleanup;
   }
@@ -3710,26 +3710,26 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
     0, NULL, NULL);
  if (clStatus != CL_SUCCESS)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), ModuleFatalError, 
+    (void) ThrowMagickException(exception, GetMagickModule(), ModuleFatalError,
       "clEnv->library->clEnqueueUnmapMemObject failed.", ".");
     goto cleanup;
   }
 
-  offsetBuffer = clEnv->library->clCreateBuffer(device->context, 
+  offsetBuffer = clEnv->library->clCreateBuffer(device->context,
     CL_MEM_READ_ONLY|CL_MEM_ALLOC_HOST_PTR, width * sizeof(cl_int2), NULL,
     &clStatus);
   if (clStatus != CL_SUCCESS)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), 
+    (void) ThrowMagickException(exception, GetMagickModule(),
       ResourceLimitError, "clEnv->library->clCreateBuffer failed.",".");
     goto cleanup;
   }
 
-  offsetBufferPtr = (int*)clEnv->library->clEnqueueMapBuffer(queue, offsetBuffer, CL_TRUE, 
+  offsetBufferPtr = (int*)clEnv->library->clEnqueueMapBuffer(queue, offsetBuffer, CL_TRUE,
     CL_MAP_WRITE, 0, width * sizeof(cl_int2), 0, NULL, NULL, &clStatus);
   if (clStatus != CL_SUCCESS)
   {
-    (void) ThrowMagickException(exception, GetMagickModule(), 
+    (void) ThrowMagickException(exception, GetMagickModule(),
       ResourceLimitError, "clEnv->library->clEnqueueMapBuffer failed.",".");
     goto cleanup;
   }
@@ -3738,7 +3738,7 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
     offsetBufferPtr[2*i] = (int)offset[i].x;
     offsetBufferPtr[2*i+1] = (int)offset[i].y;
   }
-  clStatus = clEnv->library->clEnqueueUnmapMemObject(queue, offsetBuffer, offsetBufferPtr, 0, 
+  clStatus = clEnv->library->clEnqueueUnmapMemObject(queue, offsetBuffer, offsetBufferPtr, 0,
     NULL, NULL);
  if (clStatus != CL_SUCCESS)
   {
@@ -3756,7 +3756,7 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
       "AcquireOpenCLKernel failed.", ".");
     goto cleanup;
   }
-  
+
   // set the kernel arguments
   i = 0;
   clStatus=clEnv->library->clSetKernelArg(motionBlurKernel,i++,sizeof(cl_mem),
@@ -3800,7 +3800,7 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
                                 (unsigned int) image->columns,(unsigned int) local_work_size[0]);
   global_work_size[1] = (size_t)padGlobalWorkgroupSizeToLocalWorkgroupSize(
                                 (unsigned int) image->rows,(unsigned int) local_work_size[1]);
-  clStatus = clEnv->library->clEnqueueNDRangeKernel(queue, motionBlurKernel, 2, NULL, 
+  clStatus = clEnv->library->clEnqueueNDRangeKernel(queue, motionBlurKernel, 2, NULL,
          global_work_size, local_work_size, 0, NULL, &event);
 
   if (clStatus != CL_SUCCESS)
@@ -3811,17 +3811,17 @@ static Image* ComputeMotionBlurImage(const Image *image,MagickCLEnv clEnv,
   }
   RecordProfileData(device,motionBlurKernel,event);
 
-  if (ALIGNED(filteredPixels,CLPixelPacket)) 
+  if (ALIGNED(filteredPixels,CLPixelPacket))
   {
     length = image->columns * image->rows;
-    clEnv->library->clEnqueueMapBuffer(queue, filteredImageBuffer, CL_TRUE, 
-      CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL, 
+    clEnv->library->clEnqueueMapBuffer(queue, filteredImageBuffer, CL_TRUE,
+      CL_MAP_READ|CL_MAP_WRITE, 0, length * sizeof(CLPixelPacket), 0, NULL,
       NULL, &clStatus);
   }
-  else 
+  else
   {
     length = image->columns * image->rows;
-    clStatus = clEnv->library->clEnqueueReadBuffer(queue, filteredImageBuffer, CL_TRUE, 0, 
+    clStatus = clEnv->library->clEnqueueReadBuffer(queue, filteredImageBuffer, CL_TRUE, 0,
       length * sizeof(CLPixelPacket), filteredPixels, 0, NULL, NULL);
   }
   if (clStatus != CL_SUCCESS)
@@ -3962,7 +3962,7 @@ static MagickBooleanType resizeHorizontalFilter(MagickCLDevice device,
   }
   scale=PerceptibleReciprocal(scale);
 
-  if (resizedColumns < workgroupSize) 
+  if (resizedColumns < workgroupSize)
   {
     chunkSize=32;
     pixelPerWorkgroup=32;
@@ -4146,7 +4146,7 @@ static MagickBooleanType resizeVerticalFilter(MagickCLDevice device,
   }
   scale=PerceptibleReciprocal(scale);
 
-  if (resizedRows < workgroupSize) 
+  if (resizedRows < workgroupSize)
   {
     chunkSize=32;
     pixelPerWorkgroup=32;
@@ -4433,7 +4433,7 @@ static MagickBooleanType gpuSupportedResizeWeighting(
 
 MagickPrivate Image *AccelerateResizeImage(const Image *image,
   const size_t resizedColumns,const size_t resizedRows,
-  const ResizeFilter *resizeFilter,ExceptionInfo *exception) 
+  const ResizeFilter *resizeFilter,ExceptionInfo *exception)
 {
   Image
     *filteredImage;
index 58c488f90b0c1c096a0135d3a86268fb503a39eb..deb2fe5ce88ad81585ca7ae1a367dabc23f853c5 100644 (file)
@@ -137,9 +137,8 @@ typedef struct _CacheInfo
   PixelTrait
     alpha_trait;
 
-  MagickBooleanType
-    read_mask,
-    write_mask;
+  ChannelType
+    channels;
 
   size_t
     columns,
index 2a8f20ee92854ce83e489ddd19c3d2a882edea14..7563177ea99e03c13af76898e06fbd1b7be314a1 100644 (file)
@@ -427,7 +427,7 @@ static MagickBooleanType ClipPixelCacheNexus(Image *image,
   */
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  if (image->write_mask == MagickFalse)
+  if ((image->channels & WriteMaskChannel) == 0)
     return(MagickTrue);
   cache_info=(CacheInfo *) image->cache;
   if (cache_info == (Cache) NULL)
@@ -1655,9 +1655,7 @@ static inline MagickBooleanType ValidatePixelCacheMorphology(
   if ((image->storage_class != cache_info->storage_class) ||
       (image->colorspace != cache_info->colorspace) ||
       (image->alpha_trait != cache_info->alpha_trait) ||
-      (image->composite_mask != cache_info->composite_mask) ||
-      (image->read_mask != cache_info->read_mask) ||
-      (image->write_mask != cache_info->write_mask) ||
+      (image->channels != cache_info->channels) ||
       (image->columns != cache_info->columns) ||
       (image->rows != cache_info->rows) ||
       (image->number_channels != cache_info->number_channels) ||
@@ -2769,7 +2767,9 @@ MagickPrivate const Quantum *GetVirtualPixelsFromNexus(const Image *image,
   region.width=columns;
   region.height=rows;
   pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,
-    image->write_mask || image->composite_mask ? MagickTrue : MagickFalse,
+    ((image->channels & ReadMaskChannel) != 0) ||
+    ((image->channels & WriteMaskChannel) != 0) ||
+    ((image->channels & CompositeMaskChannel) != 0) ?  MagickTrue : MagickFalse,
     nexus_info,exception);
   if (pixels == (Quantum *) NULL)
     return((const Quantum *) NULL);
@@ -3421,7 +3421,7 @@ static MagickBooleanType MaskPixelCacheNexus(Image *image,NexusInfo *nexus_info,
   */
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  if (image->composite_mask == MagickFalse)
+  if ((image->channels & CompositeMaskChannel) == 0)
     return(MagickTrue);
   cache_info=(CacheInfo *) image->cache;
   if (cache_info == (Cache) NULL)
@@ -3698,9 +3698,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
   cache_info->storage_class=image->storage_class;
   cache_info->colorspace=image->colorspace;
   cache_info->alpha_trait=image->alpha_trait;
-  cache_info->composite_mask=image->composite_mask;
-  cache_info->read_mask=image->read_mask;
-  cache_info->write_mask=image->write_mask;
+  cache_info->channels=image->channels;
   cache_info->rows=image->rows;
   cache_info->columns=image->columns;
   InitializePixelChannelMap(image);
@@ -4069,9 +4067,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image,
   clone_info->storage_class=cache_info->storage_class;
   clone_info->colorspace=cache_info->colorspace;
   clone_info->alpha_trait=cache_info->alpha_trait;
-  clone_info->composite_mask=cache_info->composite_mask;
-  clone_info->read_mask=cache_info->read_mask;
-  clone_info->write_mask=cache_info->write_mask;
+  clone_info->channels=cache_info->channels;
   clone_info->columns=cache_info->columns;
   clone_info->rows=cache_info->rows;
   clone_info->number_channels=cache_info->number_channels;
@@ -4177,7 +4173,9 @@ MagickPrivate Quantum *QueueAuthenticPixelCacheNexus(Image *image,
   region.width=columns;
   region.height=rows;
   pixels=SetPixelCacheNexusPixels(cache_info,WriteMode,&region,
-    image->write_mask || image->composite_mask ? MagickTrue : MagickFalse,
+    ((image->channels & ReadMaskChannel) != 0) ||
+    ((image->channels & WriteMaskChannel) != 0) ||
+    ((image->channels & CompositeMaskChannel) != 0) ?  MagickTrue : MagickFalse,
     nexus_info,exception);
   return(pixels);
 }
@@ -5342,10 +5340,10 @@ MagickPrivate MagickBooleanType SyncAuthenticPixelCacheNexus(Image *image,
     return(MagickFalse);
   if (image->mask_trait != UpdatePixelTrait)
     {
-      if ((image->write_mask != MagickFalse) &&
+      if (((image->channels & WriteMaskChannel) != 0) &&
           (ClipPixelCacheNexus(image,nexus_info,exception) == MagickFalse))
         return(MagickFalse);
-      if ((image->composite_mask != MagickFalse) &&
+      if (((image->channels & CompositeMaskChannel) != 0) &&
           (MaskPixelCacheNexus(image,nexus_info,exception) == MagickFalse))
         return(MagickFalse);
     }
index c2aafb73839b70cb5886e5a99e339d551d6fa7a2..854c6c287b94bde4769681e48a32fe06808cfdb3 100644 (file)
@@ -378,17 +378,17 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
             }
             case CompositeMaskPixelChannel:
             {
-              destination_image->composite_mask=MagickTrue;
+              destination_image->channels|=CompositeMaskChannel;
               break;
             }
             case ReadMaskPixelChannel:
             {
-              destination_image->read_mask=MagickTrue;
+              destination_image->channels|=ReadMaskChannel;
               break;
             }
             case WriteMaskPixelChannel:
             {
-              destination_image->write_mask=MagickTrue;
+              destination_image->channels|=WriteMaskChannel;
               break;
             }
             case MetaPixelChannel:
@@ -777,7 +777,7 @@ MagickExport Image *SeparateImage(const Image *image,
       register ssize_t
         i;
 
-      SetPixelChannel(separate_image,GrayPixelChannel,0,q);
+      SetPixelChannel(separate_image,GrayPixelChannel,(Quantum) 0,q);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
index d82435bdbd80d64d2821347d807306c69493e7b5..3a31f2af2bcaef0b77c310ab6db7d38925ccfcb4 100644 (file)
@@ -491,10 +491,9 @@ static MagickBooleanType OpenDistributeCache(SplayTreeInfo *registry,int file,
   if (image == (Image *) NULL)
     return(MagickFalse);
   length=sizeof(image->storage_class)+sizeof(image->colorspace)+
-    sizeof(image->alpha_trait)+sizeof(image->read_mask)+
-    sizeof(image->write_mask)+sizeof(image->columns)+sizeof(image->rows)+
-    sizeof(image->number_channels)+MaxPixelChannels*sizeof(*image->channel_map)+
-    sizeof(image->metacontent_extent);
+    sizeof(image->alpha_trait)+sizeof(image->channels)+sizeof(image->columns)+
+    sizeof(image->rows)+sizeof(image->number_channels)+MaxPixelChannels*
+    sizeof(*image->channel_map)+sizeof(image->metacontent_extent);
   count=dpc_read(file,length,message);
   if (count != (MagickOffsetType) length)
     return(MagickFalse);
@@ -508,10 +507,10 @@ static MagickBooleanType OpenDistributeCache(SplayTreeInfo *registry,int file,
   p+=sizeof(image->colorspace);
   (void) memcpy(&image->alpha_trait,p,sizeof(image->alpha_trait));
   p+=sizeof(image->alpha_trait);
-  (void) memcpy(&image->read_mask,p,sizeof(image->read_mask));
-  p+=sizeof(image->read_mask);
-  (void) memcpy(&image->write_mask,p,sizeof(image->write_mask));
-  p+=sizeof(image->write_mask);
+  (void) memcpy(&image->channels,p,sizeof(image->channels));
+  p+=sizeof(image->channels);
+  (void) memcpy(&image->channels,p,sizeof(image->channels));
+  p+=sizeof(image->channels);
   (void) memcpy(&image->columns,p,sizeof(image->columns));
   p+=sizeof(image->columns);
   (void) memcpy(&image->rows,p,sizeof(image->rows));
@@ -1159,10 +1158,8 @@ MagickPrivate MagickBooleanType OpenDistributePixelCache(
   p+=sizeof(image->colorspace);
   (void) memcpy(p,&image->alpha_trait,sizeof(image->alpha_trait));
   p+=sizeof(image->alpha_trait);
-  (void) memcpy(p,&image->read_mask,sizeof(image->read_mask));
-  p+=sizeof(image->read_mask);
-  (void) memcpy(p,&image->write_mask,sizeof(image->write_mask));
-  p+=sizeof(image->write_mask);
+  (void) memcpy(p,&image->channels,sizeof(image->channels));
+  p+=sizeof(image->channels);
   (void) memcpy(p,&image->columns,sizeof(image->columns));
   p+=sizeof(image->columns);
   (void) memcpy(p,&image->rows,sizeof(image->rows));
index 620c089fff5f35fa63f40d7cdedbc7ead2cd54ab..fa262378d73878c5bef503f80c0f3c9f72396036 100644 (file)
@@ -826,10 +826,8 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns,
   clone_image->number_meta_channels=image->number_meta_channels;
   clone_image->metacontent_extent=image->metacontent_extent;
   clone_image->colorspace=image->colorspace;
-  clone_image->read_mask=image->read_mask;
-  clone_image->write_mask=image->write_mask;
-  clone_image->composite_mask=image->composite_mask;
   clone_image->alpha_trait=image->alpha_trait;
+  clone_image->channels=image->channels;
   clone_image->mask_trait=image->mask_trait;
   clone_image->columns=image->columns;
   clone_image->rows=image->rows;
@@ -1455,13 +1453,13 @@ MagickExport Image *GetImageMask(const Image *image,const PixelMask type,
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(image->signature == MagickCoreSignature);
-  mask_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
-  if (mask_image == (Image *) NULL)
-    return((Image *) NULL);
+  mask_image=AcquireImage((ImageInfo *) NULL,exception);
+  status=SetImageExtent(mask_image,image->columns,image->rows,exception);
+  if (status == MagickFalse)
+    return(DestroyImage(mask_image));
   status=MagickTrue;
   mask_image->alpha_trait=UndefinedPixelTrait;
   (void) SetImageColorspace(mask_image,GRAYColorspace,exception);
-  mask_image->read_mask=MagickFalse;
   image_view=AcquireVirtualCacheView(image,exception);
   mask_view=AcquireAuthenticCacheView(mask_image,exception);
   for (y=0; y < (ssize_t) image->rows; y++)
@@ -3180,17 +3178,17 @@ MagickExport MagickBooleanType SetImageMask(Image *image,const PixelMask type,
     {
       switch (type)
       {
-        case ReadPixelMask: image->read_mask=MagickFalse; break;
-        case WritePixelMask: image->write_mask=MagickFalse; break;
-        default: image->composite_mask=MagickFalse; break;
+        case ReadPixelMask: image->channels&=(~ReadMaskChannel); break;
+        case WritePixelMask: image->channels&=(~WriteMaskChannel); break;
+        default: image->channels&=(~CompositeMaskChannel); break;
       }
       return(SyncImagePixelCache(image,exception));
     }
   switch (type)
   {
-    case ReadPixelMask: image->read_mask=MagickTrue; break;
-    case WritePixelMask: image->write_mask=MagickTrue; break;
-    default: image->composite_mask=MagickTrue; break;
+    case ReadPixelMask: image->channels|=ReadMaskChannel; break;
+    case WritePixelMask: image->channels|=WriteMaskChannel; break;
+    default: image->channels|=CompositeMaskChannel; break;
   }
   if (SyncImagePixelCache(image,exception) == MagickFalse)
     return(MagickFalse);
@@ -3313,17 +3311,17 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image,
     {
       switch (type)
       {
-        case ReadPixelMask: image->read_mask=MagickFalse; break;
-        case WritePixelMask: image->write_mask=MagickFalse; break;
-        default: image->composite_mask=MagickFalse; break;
+        case ReadPixelMask: image->channels&=(~ReadMaskChannel); break;
+        case WritePixelMask: image->channels&=(~WriteMaskChannel); break;
+        default: image->channels&=(~CompositeMaskChannel); break;
       }
       return(SyncImagePixelCache(image,exception));
     }
   switch (type)
   {
-    case ReadPixelMask: image->read_mask=MagickTrue; break;
-    case WritePixelMask: image->write_mask=MagickTrue; break;
-    default: image->composite_mask=MagickTrue; break;
+    case ReadPixelMask: image->channels|=ReadMaskChannel; break;
+    case WritePixelMask: image->channels|=WriteMaskChannel; break;
+    default: image->channels|=CompositeMaskChannel; break;
   }
   if (SyncImagePixelCache(image,exception) == MagickFalse)
     return(MagickFalse);
index 62a56a21d4e13597f57dddd12608da2899c4b4d2..1ccd7e5a0d898d3bb06fa8c43e11469a9fd67826 100644 (file)
@@ -273,8 +273,8 @@ struct _Image
     ping;              /* no image data read, just attributes */
 
   MagickBooleanType
-    read_mask,
-    write_mask;
+    Xread_mask,
+    Xwrite_mask;
 
   PixelTrait
     alpha_trait;       /* is transparency channel defined and active */
@@ -357,10 +357,13 @@ struct _Image
     matte_color;        /* current mattecolor attribute */
 
   MagickBooleanType
-    composite_mask;
+    Xcomposite_mask;
 
   PixelTrait
     mask_trait;       /* apply the clip or composite mask */
+
+  ChannelType
+    channels;
 };
 
 /*
index f74170465aa789ff232351d4f606adcb68e266be..e935b0994d21595b9f7585aa7880a3a4de6df1ff 100644 (file)
@@ -4368,11 +4368,11 @@ MagickExport void InitializePixelChannelMap(Image *image)
     SetPixelChannelAttributes(image,AlphaPixelChannel,CopyPixelTrait,n++);
   if (image->storage_class == PseudoClass)
     SetPixelChannelAttributes(image,IndexPixelChannel,CopyPixelTrait,n++);
-  if (image->read_mask != MagickFalse)
+  if ((image->channels & ReadMaskChannel) != 0)
     SetPixelChannelAttributes(image,ReadMaskPixelChannel,CopyPixelTrait,n++);
-  if (image->write_mask != MagickFalse)
+  if ((image->channels & WriteMaskChannel) != 0)
     SetPixelChannelAttributes(image,WriteMaskPixelChannel,CopyPixelTrait,n++);
-  if (image->composite_mask != MagickFalse)
+  if ((image->channels & CompositeMaskChannel) != 0)
     SetPixelChannelAttributes(image,CompositeMaskPixelChannel,CopyPixelTrait,
       n++);
   image->number_channels=(size_t) n;
@@ -6319,11 +6319,11 @@ MagickExport ChannelType SetPixelChannelMask(Image *image,
   }
   if (image->storage_class == PseudoClass)
     SetPixelChannelTraits(image,IndexPixelChannel,CopyPixelTrait);
-  if (image->read_mask != MagickFalse)
+  if ((image->channels & ReadMaskChannel) != 0)
     SetPixelChannelTraits(image,ReadMaskPixelChannel,CopyPixelTrait);
-  if (image->write_mask != MagickFalse)
+  if ((image->channels & WriteMaskChannel) != 0)
     SetPixelChannelTraits(image,WriteMaskPixelChannel,CopyPixelTrait);
-  if (image->composite_mask != MagickFalse)
+  if ((image->channels & CompositeMaskChannel) != 0)
     SetPixelChannelTraits(image,CompositeMaskPixelChannel,CopyPixelTrait);
   if (image->debug != MagickFalse)
     LogPixelChannels(image);
index 7676b4acea52821759f67f09f83a69e3adab2c5a..a5fd5c7c873afa463edc07bcc12d233543bc6c10 100644 (file)
@@ -4836,8 +4836,8 @@ Get(ref,...)
                     *sv;
 
                   sv=NULL;
-                  if (image->read_mask == MagickFalse)
-                    ClipImage(image,exception);
+                  if (image->channels & WriteMaskChannel) == 0)
+                    (void) ClipImage(image,exception);
                   mask_image=GetImageMask(image,ReadPixelMask,exception);
                   if (mask_image != (Image *) NULL)
                     {
@@ -4859,8 +4859,8 @@ Get(ref,...)
                     *sv;
 
                   sv=NULL;
-                  if (image->read_mask != MagickFalse)
-                    ClipImage(image,exception);
+                  if (image->channels & WriteMaskChannel) == 0)
+                    (void) ClipImage(image,exception);
                   mask_image=GetImageMask(image,ReadPixelMask,exception);
                   if (mask_image != (Image *) NULL)
                     {
index e5fcb29615b967050c6e715641ea4b0e3bc9318c..7d4b60dd10241579b70b90fd7875f8133ab91688 100644 (file)
@@ -225,9 +225,9 @@ static MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  if (image->write_mask == MagickFalse)
-    (void) ClipImage(image,exception);
-  if (image->write_mask == MagickFalse)
+  if ((image->channels & WriteMaskChannel) == 0)
+    status=ClipImage(image,exception);
+  if ((image->channels & WriteMaskChannel) == 0)
     ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask");
   clip_image=GetImageMask(image,WritePixelMask,exception);
   if (clip_image == (Image *) NULL)
index 1a60d2422112f2e2ebe96ca6941e2626d9492bac..e9c6e531c80cc78ae4c2381673d7c79556c36783 100644 (file)
@@ -962,8 +962,8 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
       }
     if (image->units == PixelsPerCentimeterResolution)
       {
-        resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0;
-        resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0;
+        resolution.x=(size_t) ((100.0*2.54*resolution.x+0.5)/100.0);
+        resolution.y=(size_t) ((100.0*2.54*resolution.y+0.5)/100.0);
       }
     SetGeometry(image,&geometry);
     (void) FormatLocaleString(page_geometry,MagickPathExtent,"%.20gx%.20g",
@@ -1155,7 +1155,7 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
     /*
       PS clipping path from Photoshop clipping path.
     */
-    if ((image->read_mask != MagickFalse) ||
+    if (((image->channels & WriteMaskChannel) != 0) ||
         (LocaleNCompare("8BIM:",image->magick_filename,5) != 0))
       (void) WriteBlobString(image,"/ClipImage {} def\n");
     else
@@ -1235,7 +1235,7 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
     /*
       Photoshop clipping path active?
     */
-    if ((image->read_mask != MagickFalse) &&
+    if (((image->channels & WriteMaskChannel) != 0) &&
         (LocaleNCompare("8BIM:",image->magick_filename,5) == 0))
         (void) WriteBlobString(image,"true\n");
       else