TuttleOFX  1
CTLPluginFactory.cpp
Go to the documentation of this file.
00001 #include "CTLPluginFactory.hpp"
00002 #include "CTLPlugin.hpp"
00003 #include "CTLDefinitions.hpp"
00004 
00005 #include "ofxsImageEffect.h"
00006 
00007 #include <limits>
00008 
00009 namespace tuttle {
00010 namespace plugin {
00011 namespace ctl {
00012 
00013 static const bool kSupportTiles = true;
00014 
00015 
00016 /**
00017  * @brief Function called to describe the plugin main features.
00018  * @param[in, out] desc Effect descriptor
00019  */
00020 void CTLPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00021 {
00022         desc.setLabels( "TuttleCTL", "CTL",
00023                             "ColorTransformationLanguage" );
00024         desc.setPluginGrouping( "tuttle/image/process/color" );
00025 
00026         desc.setDescription(
00027                 "Color Transformation Language"
00028                 "\n\n"
00029                 "The Color Transformation Language, or CTL, is a small programming language that has been designed to serve as a building "
00030                 "block for digital color management systems. CTL allows users to describe color transforms in a concise and unambiguous way "
00031                 "by expressing them as programs."
00032                 "\n"
00033                 "Color transforms can be shared by distributing CTL programs. Two parties with the same CTL program can apply the same "
00034                 "transform to an image. "
00035                 "In addition to the original image, a CTL program can have input parameters whose settings affect how the input image will be "
00036                 "transformed. For example, a transform may have an 'exposure' parameter, such that changing the exposure makes the image "
00037                 "brighter or darker. In order to guarantee identical results, parties that have agreed to use a particular transform must also agree "
00038                 "on the settings for the transform's parameters.\n"
00039                 "A domain-specific programming language such as CTL can be designed to allow only the kinds of operations that are needed to"
00040                 "describe color transforms. This improves the portability of programs, protects users against application software crashes and"
00041                 "malicious code, and permits efficient interpreter implementations."
00042                 "\n" );
00043 
00044         // add the supported contexts, only filter at the moment
00045         desc.addSupportedContext( OFX::eContextFilter );
00046         desc.addSupportedContext( OFX::eContextGeneral );
00047 
00048         // add supported pixel depths
00049         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00050         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00051         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00052 
00053         // plugin flags
00054         desc.setSupportsTiles( kSupportTiles );
00055         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00056 }
00057 
00058 /**
00059  * @brief Function called to describe the plugin controls and features.
00060  * @param[in, out]   desc       Effect descriptor
00061  * @param[in]        context    Application context
00062  */
00063 void CTLPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00064                                                   OFX::EContext context )
00065 {
00066         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00067         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00068         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00069         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00070         srcClip->setSupportsTiles( kSupportTiles );
00071 
00072         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00073         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00074         dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00075         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00076         dstClip->setSupportsTiles( kSupportTiles );
00077 
00078         OFX::ChoiceParamDescriptor* chooseInput = desc.defineChoiceParam( kParamChooseInput );
00079         chooseInput->appendOption( kParamChooseInputCode );
00080         chooseInput->appendOption( kParamChooseInputFile );
00081         chooseInput->setDefault( eParamChooseInputFile );
00082 
00083         OFX::StringParamDescriptor* code = desc.defineStringParam( kParamCTLCode );
00084         code->setLabel( "CTL code" );
00085         code->setHint ( "Your CTL code." );
00086         code->setStringType( OFX::eStringTypeMultiLine );
00087         code->setDefault(
00088                 "void main(\n"
00089                 "                input varying float rIn,\n"
00090                 "                input varying float gIn,\n"
00091                 "                input varying float bIn,\n"
00092                 "                input varying float aIn,\n"
00093                 "                output varying float rOut,\n"
00094                 "                output varying float gOut,\n"
00095                 "                output varying float bOut,\n"
00096                 "                output varying float aOut\n"
00097                 "        )\n"
00098                 "{\n"
00099                 "        rOut = rIn;\n"
00100                 "        gOut = gIn;\n"
00101                 "        bOut = bIn;\n"
00102                 "        aOut = aIn;\n"
00103                 "}\n"
00104         );
00105 
00106         OFX::PushButtonParamDescriptor* updateRender = desc.definePushButtonParam( kParamChooseInputCodeUpdate );
00107         updateRender->setLabel( "Update" );
00108         updateRender->setHint ( "Rendering the CTL code" );
00109 
00110         OFX::StringParamDescriptor* file = desc.defineStringParam( kTuttlePluginFilename );
00111         file->setLabel( kTuttlePluginFilenameLabel );
00112         file->setHint ( "CTL source code file." );
00113         file->setStringType( OFX::eStringTypeFilePath );
00114 
00115 
00116 }
00117 
00118 /**
00119  * @brief Function called to create a plugin effect instance
00120  * @param[in] handle  Effect handle
00121  * @param[in] context Application context
00122  * @return  plugin instance
00123  */
00124 OFX::ImageEffect* CTLPluginFactory::createInstance( OfxImageEffectHandle handle,
00125                                                             OFX::EContext context )
00126 {
00127         return new CTLPlugin( handle );
00128 }
00129 
00130 }
00131 }
00132 }
00133