]> granicus.if.org Git - imagemagick/commitdiff
The source pixels need to be copied when a channel mask is set otherwise the values...
authordirk <dirk@git.imagemagick.org>
Thu, 7 Jul 2016 21:16:32 +0000 (23:16 +0200)
committerdirk <dirk@git.imagemagick.org>
Thu, 7 Jul 2016 21:16:32 +0000 (23:16 +0200)
MagickCore/accelerate.c

index 35cc3938a460a39fce3b2dbf16fdd7eb6f674c84..3c8b729537db83d59a5f0bf5d63c88b38eae01c7 100644 (file)
@@ -226,6 +226,28 @@ static MagickCLEnv getOpenCLEnvironment(ExceptionInfo* exception)
   return(clEnv);
 }
 
+static inline void copyPixels(const Image *source,Image *destination,
+  ExceptionInfo *exception)
+{
+  RectangleInfo
+    geometry;
+
+  OffsetInfo
+    offset;
+
+  /* The pixels only need to be copied when a channel mask has been set */
+  if (((source->channel_mask & RedChannel) != 0) &&
+      ((source->channel_mask & GreenChannel) != 0) &&
+      ((source->channel_mask & BlueChannel) != 0) &&
+      ((source->channel_mask & AlphaChannel) != 0))
+    return;
+
+  geometry.width=source->columns;
+  geometry.height=source->rows;
+  geometry.x=geometry.y=offset.x=offset.y=0;
+  CopyImagePixels(destination,source,&geometry,&offset,exception);
+}
+
 /* pad the global workgroup size to the next multiple of 
    the local workgroup size */
 inline static unsigned int padGlobalWorkgroupSizeToLocalWorkgroupSize(
@@ -435,6 +457,7 @@ static Image *ComputeAddNoiseImage(const Image *image,MagickCLEnv clEnv,
     goto cleanup;
   if (filteredImage->number_channels != image->number_channels)
     goto cleanup;
+  copyPixels(image,filteredImage,exception);
   imageBuffer=GetAuthenticOpenCLBuffer(image,device,exception);
   if (imageBuffer == (cl_mem) NULL)
     goto cleanup;
@@ -628,6 +651,7 @@ static Image *ComputeBlurImage(const Image* image,MagickCLEnv clEnv,
     goto cleanup;
   if (filteredImage->number_channels != image->number_channels)
     goto cleanup;
+  copyPixels(image,filteredImage,exception);
   imageBuffer=GetAuthenticOpenCLBuffer(image,device,exception);
   if (imageBuffer == (cl_mem) NULL)
     goto cleanup;
@@ -4609,6 +4633,7 @@ static Image* ComputeRotationalBlurImage(const Image *image,MagickCLEnv clEnv,
     goto cleanup;
   if (filteredImage->number_channels != image->number_channels)
     goto cleanup;
+  copyPixels(image,filteredImage,exception);
   imageBuffer=GetAuthenticOpenCLBuffer(image,device,exception);
   if (imageBuffer == (cl_mem) NULL)
     goto cleanup;
@@ -4809,6 +4834,7 @@ static Image *ComputeUnsharpMaskImage(const Image *image,MagickCLEnv clEnv,
     goto cleanup;
   if (filteredImage->number_channels != image->number_channels)
     goto cleanup;
+  copyPixels(image,filteredImage,exception);
   imageBuffer=GetAuthenticOpenCLBuffer(image,device,exception);
   if (imageBuffer == (cl_mem) NULL)
     goto cleanup;
@@ -4983,6 +5009,7 @@ static Image *ComputeUnsharpMaskImageSingle(const Image *image,
     goto cleanup;
   if (filteredImage->number_channels != image->number_channels)
     goto cleanup;
+  copyPixels(image,filteredImage,exception);
   imageBuffer=GetAuthenticOpenCLBuffer(image,device,exception);
   if (imageBuffer == (cl_mem) NULL)
     goto cleanup;