]> granicus.if.org Git - imagemagick/commitdiff
Moved functions to Functions.h.
authordirk <dirk@git.imagemagick.org>
Tue, 14 Jan 2014 20:30:45 +0000 (20:30 +0000)
committerdirk <dirk@git.imagemagick.org>
Tue, 14 Jan 2014 20:30:45 +0000 (20:30 +0000)
Added methods to enable/disable OpenCL.
Removed deprecated method 'cacheThreshold' from Image.cpp.

Magick++/lib/Functions.cpp
Magick++/lib/Image.cpp
Magick++/lib/Magick++.h
Magick++/lib/Magick++/Functions.h
Magick++/lib/Magick++/Image.h
MagickCore/MagickCore.h

index 2d3a9d4edc60570f8fdb8fa339d26a11c7bbc301..671995eca66881f2535b07a8af62d272e8a12e00 100644 (file)
 using namespace std;
 
 #include "Magick++/Functions.h"
+#include "Magick++/Exception.h"
+
+#define GetPPException \
+  ExceptionInfo \
+    exceptionInfo; \
+  GetExceptionInfo(&exceptionInfo)
+#define ThrowPPException \
+  throwException(exceptionInfo); \
+  (void) DestroyExceptionInfo(&exceptionInfo)
+
+static bool magick_initialized=false;
 
 // Clone C++ string as allocated C string, de-allocating any existing string
-void Magick::CloneString( char **destination_, const std::string &source_ )
+void Magick::CloneString(char **destination_, const std::string &source_)
+{
+  MagickCore::CloneString(destination_,source_.c_str());
+}
+
+MagickPPExport void Magick::CacheThreshold(const MagickSizeType threshold_)
 {
-  MagickCore::CloneString( destination_, source_.c_str() );
+  (void) SetMagickResourceLimit(MemoryResource,threshold_);
 }
+
+MagickPPExport MagickCore::MagickSizeType Magick::CacheThreshold(void)
+{
+  return GetMagickResourceLimit(MemoryResource);
+}
+
+MagickPPExport void Magick::DisableOpenCL(void)
+{
+  GetPPException;
+  MagickCore::InitImageMagickOpenCL(MagickCore::MAGICK_OPENCL_OFF,NULL,NULL,
+    &exceptionInfo);
+  ThrowPPException;
+}
+
+MagickPPExport void Magick::EnableOpenCL(const bool useCache_)
+{
+  GetPPException;
+  if (useCache_)
+    MagickCore::InitImageMagickOpenCL(
+      MagickCore::MAGICK_OPENCL_DEVICE_SELECT_AUTO,NULL,NULL,&exceptionInfo);
+  else
+    MagickCore::InitImageMagickOpenCL(
+      MagickCore::MAGICK_OPENCL_DEVICE_SELECT_AUTO_CLEAR_CACHE,NULL,NULL,
+      &exceptionInfo);
+  ThrowPPException;
+}
+
+MagickPPExport void Magick::InitializeMagick(const char *path_)
+{
+  MagickCore::MagickCoreGenesis(path_,MagickFalse);
+  if (!magick_initialized)
+    magick_initialized=true;
+}
+
+MagickPPExport void Magick::TerminateMagick(void)
+{
+  if (magick_initialized)
+    {
+      magick_initialized=false;
+      MagickCore::MagickCoreTerminus();
+    }
+}
\ No newline at end of file
index 280b75bde0994deec89a5c1733eac3980ddf8d78..7d7304546e0a61d7836c5ca0c56d54c08b7e4edf 100644 (file)
@@ -51,8 +51,6 @@ MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
 
-static bool magick_initialized=false;
-
 MagickPPExport int Magick::operator == (const Magick::Image &left_,
   const Magick::Image &right_)
 {
@@ -94,22 +92,6 @@ MagickPPExport int Magick::operator <= (const Magick::Image &left_,
   return((left_ < right_) || ( left_ == right_));
 }
 
-MagickPPExport void Magick::InitializeMagick(const char *path_)
-{
-  MagickCore::MagickCoreGenesis(path_,MagickFalse);
-  if (!magick_initialized)
-    magick_initialized=true;
-}
-
-MagickPPExport void Magick::TerminateMagick(void)
-{
-  if (magick_initialized)
-    {
-      magick_initialized=false;
-      MagickCore::MagickCoreTerminus();
-    }
-}
-
 Magick::Image::Image(void)
   : _imgRef(new ImageRef)
 {
@@ -518,11 +500,6 @@ Magick::Color Magick::Image::boxColor(void) const
   return(constOptions()->boxColor());
 }
 
-void Magick::Image::cacheThreshold(const MagickSizeType threshold_)
-{
-  SetMagickResourceLimit(MemoryResource, threshold_);
-}
-
 void Magick::Image::channelDepth(const size_t depth_)
 {
   modifyImage();
index a85f7da5861cfa4a4e89a2d2d5315ef227654a92..740d51ef5dc6d93379e051de6443ff17c01fb53f 100644 (file)
@@ -7,6 +7,7 @@
 //
 #ifndef MagickPlusPlus_Header
 #include <Magick++/Include.h>
+#include <Magick++/Functions.h>
 #include <Magick++/Image.h>
 #include <Magick++/Pixels.h>
 #include <Magick++/STL.h>
index 2cbea429a9efd6f7f03fcf72a21a07ee7d0d5558..938a58882cbbba11ca4df520afd3ff6e1cbe6f89 100644 (file)
 
 namespace Magick
 {
-  void MagickPPExport CloneString( char **destination_, const std::string &source_ );
+  // Pixel cache threshold in bytes. Once this memory threshold is exceeded,
+  // all subsequent pixels cache operations are to/from disk
+  MagickPPExport void CacheThreshold(const MagickSizeType threshold_);
+  MagickPPExport MagickSizeType CacheThreshold(void);
 
+  // Clone C++ string as allocated C string, de-allocating any existing string
+  MagickPPExport void CloneString(char **destination_,
+    const std::string &source_);
+
+  // Disable OpenCL acceleration (only works when build with OpenCL support)
+  MagickPPExport void DisableOpenCL(void);
+
+  // Enable OpenCL acceleration (only works when build with OpenCL support)
+  MagickPPExport void EnableOpenCL(const bool useCache_=true);
+
+  // C library initialization routine
+  MagickPPExport void InitializeMagick(const char *path_);
+
+  // C library initialization routine
+  MagickPPExport void TerminateMagick();
 }
 #endif // Magick_Functions_header
index 4c8cd178881d226a4ed8f2183d968535942449dd..9e57dc2b7dbd31eb0793f9c9bd7f808c6a389183 100644 (file)
@@ -43,10 +43,6 @@ namespace Magick
   MagickPPExport int operator <=
     (const Magick::Image &left_,const Magick::Image &right_);
 
-  // C library initialization routine
-  MagickPPExport void InitializeMagick(const char *path_);
-  MagickPPExport void TerminateMagick();
-
   //
   // Image is the representation of an image. In reality, it actually
   // a handle object which contains a pointer to a shared reference
@@ -181,11 +177,6 @@ namespace Magick
     void boxColor(const Color &boxColor_);
     Color boxColor(void) const;
 
-    // Pixel cache threshold in bytes. Once this memory threshold
-    // is exceeded, all subsequent pixels cache operations are to/from
-    // disk. This setting is shared by all Image objects.
-    static void cacheThreshold(const MagickSizeType threshold_);
-
     // Set or obtain modulus channel depth
     void channelDepth(const size_t depth_);
     size_t channelDepth();
index 6670b8f3a96a1a7f88eb237ab5551d01fabba06a..ce6b94ecf783578e5d4b1999b36fe71d1e2548fb 100644 (file)
@@ -124,6 +124,7 @@ extern "C" {
 #include "MagickCore/monitor.h"
 #include "MagickCore/montage.h"
 #include "MagickCore/morphology.h"
+#include "MagickCore/opencl.h"
 #include "MagickCore/option.h"
 #include "MagickCore/paint.h"
 #include "MagickCore/pixel.h"