TuttleOFX
1
|
00001 #include "OCIOColorSpacePluginFactory.hpp" 00002 #include "OCIOColorSpacePlugin.hpp" 00003 #include "OCIOColorSpaceDefinitions.hpp" 00004 00005 #include <tuttle/plugin/exceptions.hpp> 00006 00007 #include <OpenColorIO/OpenColorIO.h> 00008 00009 #include <ofxsImageEffect.h> 00010 #include <ofxsMultiThread.h> 00011 00012 namespace OCIO = OCIO_NAMESPACE; 00013 00014 namespace tuttle 00015 { 00016 namespace plugin 00017 { 00018 namespace ocio 00019 { 00020 namespace colorspace 00021 { 00022 00023 bool global_wasOCIOVarFund; 00024 /** 00025 * @brief Function called to describe the plugin main features. 00026 * @param[in, out] desc Effect descriptor 00027 */ 00028 void 00029 OCIOColorSpacePluginFactory::describe(OFX::ImageEffectDescriptor& desc) 00030 { 00031 desc.setLabels("TuttleOcioColorSpace", "OCIOColorSpace", 00032 "ColorSpace transformation using OpenColorIO configuration file"); 00033 desc.setPluginGrouping("tuttle/image/process/color/ocio"); 00034 00035 desc.setDescription("OCIO ColorSpace\n" 00036 "\n" 00037 "Config filename "); 00038 00039 // add the supported contexts 00040 desc.addSupportedContext(OFX::eContextGeneral); 00041 desc.addSupportedContext(OFX::eContextFilter); 00042 00043 // add supported pixel depths 00044 // desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00045 // desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00046 desc.addSupportedBitDepth(OFX::eBitDepthFloat); 00047 00048 desc.setSupportsTiles(kSupportTiles); 00049 desc.setRenderThreadSafety(OFX::eRenderFullySafe); 00050 00051 } 00052 00053 /** 00054 * @brief Function called to describe the plugin controls and features. 00055 * @param[in, out] desc Effect descriptor 00056 * @param[in] context Application context 00057 */ 00058 00059 void 00060 OCIOColorSpacePluginFactory::describeInContext( 00061 OFX::ImageEffectDescriptor& desc, OFX::EContext context) 00062 { 00063 OFX::ClipDescriptor* srcClip = desc.defineClip( 00064 kOfxImageEffectSimpleSourceClipName); 00065 srcClip->addSupportedComponent(OFX::ePixelComponentRGBA); //@todo mfe, test this 00066 //srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );//@todo mfe, add and test this (cf OCIOPlugin.cpp, render) 00067 srcClip->addSupportedComponent(OFX::ePixelComponentRGB); 00068 srcClip->setSupportsTiles(kSupportTiles); 00069 00070 OFX::ClipDescriptor* dstClip = desc.defineClip( 00071 kOfxImageEffectOutputClipName); 00072 dstClip->addSupportedComponent(OFX::ePixelComponentRGBA); 00073 //dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00074 dstClip->addSupportedComponent(OFX::ePixelComponentRGB); 00075 dstClip->setSupportsTiles(kSupportTiles); 00076 00077 // Controls 00078 00079 OFX::StringParamDescriptor* filename = desc.defineStringParam( 00080 kTuttlePluginFilename); 00081 char* file = std::getenv("OCIO"); 00082 00083 filename->setEnabled(false); 00084 filename->setLabel(kTuttlePluginFilenameLabel); 00085 00086 OFX::ChoiceParamDescriptor* inputSpace = desc.defineChoiceParam( 00087 kParamInputSpace); 00088 inputSpace->setLabel("Input Space"); 00089 ////// 00090 OFX::ChoiceParamDescriptor* outputSpace = desc.defineChoiceParam( 00091 kParamOutputSpace); 00092 outputSpace->setLabel("Output Space"); 00093 00094 if (file == NULL) 00095 { 00096 filename->setDefault( 00097 "WARNING : You must set an OCIO environnement variable"); 00098 inputSpace->setEnabled(false); 00099 outputSpace->setEnabled(false); 00100 global_wasOCIOVarFund = false; 00101 return; 00102 } 00103 global_wasOCIOVarFund = true; 00104 //filename->setStringType(OFX::eStringTypeFilePath); 00105 filename->setDefault(file); 00106 //Add choices 00107 OCIO::ConstConfigRcPtr config = OCIO::Config::CreateFromFile(file); 00108 for (int i = 0; i < config->getNumColorSpaces(); i++) 00109 { 00110 std::string csname = config->getColorSpaceNameByIndex(i); 00111 inputSpace->appendOption(csname); 00112 outputSpace->appendOption(csname); 00113 } 00114 00115 } 00116 00117 /** 00118 * @brief Function called to create a plugin effect instance 00119 * @param[in] handle effect handle 00120 * @param[in] context Application context 00121 * @return plugin instance 00122 */ 00123 OFX::ImageEffect* 00124 OCIOColorSpacePluginFactory::createInstance(OfxImageEffectHandle handle, 00125 OFX::EContext context) 00126 { 00127 return new OCIOColorSpacePlugin(handle, global_wasOCIOVarFund); 00128 } 00129 00130 } 00131 } 00132 } 00133 }