TuttleOFX
1
|
00001 #include "FadePlugin.hpp" 00002 #include "FadeProcess.hpp" 00003 #include "FadeDefinitions.hpp" 00004 00005 #include <boost/gil/gil_all.hpp> 00006 00007 namespace tuttle { 00008 namespace plugin { 00009 namespace fade { 00010 00011 00012 FadePlugin::FadePlugin( OfxImageEffectHandle handle ) 00013 : OFX::ImageEffect( handle ) 00014 { 00015 _clipSrcFrom = fetchClip( kOfxImageEffectTransitionSourceFromClipName ); 00016 _clipSrcTo = fetchClip( kOfxImageEffectTransitionSourceToClipName ); 00017 _clipDst = fetchClip( kOfxImageEffectOutputClipName ); 00018 00019 _paramTransition = fetchDoubleParam( kOfxImageEffectTransitionParamName ); 00020 _paramRod = fetchChoiceParam( kParamRod ); 00021 _paramColor = fetchRGBAParam( kParamColor ); 00022 } 00023 00024 FadeProcessParams FadePlugin::getProcessParams() const 00025 { 00026 FadeProcessParams params; 00027 params._transition = _paramTransition->getValue(); 00028 params._rod = static_cast<EParamRod>( _paramRod->getValue() ); 00029 params._color = ofxToGil( _paramColor->getValue() ); 00030 return params; 00031 } 00032 00033 void FadePlugin::changedParam( const OFX::InstanceChangedArgs &args, const std::string ¶mName ) 00034 { 00035 // if( paramName == kParamHelpButton ) 00036 // { 00037 // sendMessage( OFX::Message::eMessageMessage, 00038 // "", // No XML resources 00039 // kParamHelpString ); 00040 // } 00041 } 00042 00043 //bool FadePlugin::getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod ) 00044 //{ 00045 // FadeProcessParams<Scalar> params = getProcessParams(); 00046 // OfxRectD srcRod = _clipSrc->getCanonicalRod( args.time ); 00047 // 00048 // switch( params._border ) 00049 // { 00050 // case eParamBorderPadded: 00051 // rod.x1 = srcRod.x1 + 1; 00052 // rod.y1 = srcRod.y1 + 1; 00053 // rod.x2 = srcRod.x2 - 1; 00054 // rod.y2 = srcRod.y2 - 1; 00055 // return true; 00056 // default: 00057 // break; 00058 // } 00059 // return false; 00060 //} 00061 00062 bool FadePlugin::isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime ) 00063 { 00064 FadeProcessParams params = getProcessParams(); 00065 if( params._transition == 0.0 && _clipSrcFrom->isConnected() ) 00066 { 00067 identityClip = _clipSrcFrom; 00068 identityTime = args.time; 00069 return true; 00070 } 00071 else if( params._transition == 1.0 && _clipSrcTo->isConnected() ) 00072 { 00073 identityClip = _clipSrcTo; 00074 identityTime = args.time; 00075 return true; 00076 } 00077 return false; 00078 } 00079 00080 /** 00081 * @brief The overridden render function 00082 * @param[in] args Rendering parameters 00083 */ 00084 void FadePlugin::render( const OFX::RenderArguments &args ) 00085 { 00086 doGilRender<FadeProcess>( *this, args ); 00087 } 00088 00089 00090 } 00091 } 00092 }