]> granicus.if.org Git - imagemagick/commitdiff
Initialize the dcraw environment variables under Windows.
authorDirk Lemstra <dirk@git.imagemagick.org>
Tue, 6 Dec 2016 22:09:46 +0000 (23:09 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Tue, 6 Dec 2016 22:11:24 +0000 (23:11 +0100)
coders/dng.c

index be4ed71e7dab802f8c3cff9413b119a3f6d8ddae..be2df24769f895f6c22864d7565ea45f393ebe76 100644 (file)
@@ -53,6 +53,7 @@
 #include "MagickCore/log.h"
 #include "MagickCore/magick.h"
 #include "MagickCore/memory_.h"
+#include "MagickCore/opencl.h"
 #include "MagickCore/resource_.h"
 #include "MagickCore/quantum-private.h"
 #include "MagickCore/static.h"
 %    o exception: return any errors or warnings in this structure.
 %
 */
+
+#if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(MAGICKCORE_OPENCL_SUPPORT)
+static void InitializeDcrawOpenCL(ExceptionInfo *exception)
+{
+  MagickBooleanType
+    opencl_disabled;
+
+  MagickCLDevice
+    *devices;
+
+  size_t
+    length;
+
+  ssize_t
+    i;
+
+  (void) SetEnvironmentVariable("DCR_CL_PLATFORM",NULL);
+  (void) SetEnvironmentVariable("DCR_CL_DEVICE",NULL);
+  devices=GetOpenCLDevices(&length,exception);
+  if (devices == (MagickCLDevice *) NULL)
+    return;
+  for (i=0; i < (ssize_t) length; i++)
+  {
+    const char
+      *name;
+
+    MagickCLDevice
+      device;
+
+    device=devices[i];
+    if (GetOpenCLDeviceEnabled(device) == MagickFalse)
+      continue;
+    name=GetOpenCLDeviceVendorName(device);
+    if (name != (const char *) NULL)
+      (void) SetEnvironmentVariable("DCR_CL_PLATFORM",name);
+    name=GetOpenCLDeviceName(device);
+    if (name != (const char *) NULL)
+      (void) SetEnvironmentVariable("DCR_CL_DEVICE",name);
+    return;
+  }
+}
+#else
+static void InitializeDcrawOpenCL(ExceptionInfo *magick_unused(exception))
+{
+  magick_unreferenced(exception);
+}
+#endif
 static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   ExceptionInfo
@@ -126,6 +174,7 @@ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Convert DNG to PPM with delegate.
   */
+  InitializeDcrawOpenCL(exception);
   image=AcquireImage(image_info,exception);
   read_info=CloneImageInfo(image_info);
   SetImageInfoBlob(read_info,(void *) NULL,0);