TuttleOFX
1
|
00001 #include "BlurPlugin.hpp" 00002 00003 #include <terry/filter/gaussianKernel.hpp> 00004 #include <terry/filter/convolve.hpp> 00005 00006 #include <tuttle/plugin/memory/OfxAllocator.hpp> 00007 00008 namespace tuttle { 00009 namespace plugin { 00010 namespace blur { 00011 00012 template<class View> 00013 BlurProcess<View>::BlurProcess( BlurPlugin& effect ) 00014 : ImageGilFilterProcessor<View>( effect, eImageOrientationIndependant ) 00015 , _plugin( effect ) 00016 {} 00017 00018 template <class View> 00019 void BlurProcess<View>::setup( const OFX::RenderArguments& args ) 00020 { 00021 ImageGilFilterProcessor<View>::setup( args ); 00022 _params = _plugin.getProcessParams( args.renderScale ); 00023 00024 // TUTTLE_LOG_VAR( TUTTLE_INFO, _params._size ); 00025 // TUTTLE_LOG_VAR2( TUTTLE_INFO, _params._gilKernelX.size(), _params._gilKernelY.size() ); 00026 // std::cout << "x ["; 00027 // std::for_each(_params._gilKernelX.begin(), _params._gilKernelX.end(), std::cout << boost::lambda::_1 << ','); 00028 // std::cout << "]" << std::endl; 00029 // std::cout << "y ["; 00030 // std::for_each(_params._gilKernelY.begin(), _params._gilKernelY.end(), std::cout << boost::lambda::_1 << ','); 00031 // std::cout << "]" << std::endl; 00032 } 00033 00034 /** 00035 * @brief Function called by rendering thread each time a process must be done. 00036 * @param[in] procWindowRoW Processing window 00037 */ 00038 template<class View> 00039 void BlurProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00040 { 00041 using namespace terry; 00042 using namespace terry::filter; 00043 00044 const OfxRectI procWindowOutput = this->translateRoWToOutputClipCoordinates( procWindowRoW ); 00045 const OfxPointI procWindowSize = { 00046 procWindowRoW.x2 - procWindowRoW.x1, 00047 procWindowRoW.y2 - procWindowRoW.y1 00048 }; 00049 00050 View dst = subimage_view( this->_dstView, procWindowOutput.x1, procWindowOutput.y1, 00051 procWindowSize.x, procWindowSize.y ); 00052 00053 const Point proc_tl( procWindowRoW.x1 - this->_srcPixelRod.x1, procWindowRoW.y1 - this->_srcPixelRod.y1 ); 00054 00055 if( _params._size.x == 0 ) 00056 { 00057 correlate_cols_auto<Pixel>( this->_srcView, _params._gilKernelY, dst, proc_tl, _params._boundary_option ); 00058 } 00059 else if( _params._size.y == 0 ) 00060 { 00061 correlate_rows_auto<Pixel>( this->_srcView, _params._gilKernelX, dst, proc_tl, _params._boundary_option ); 00062 } 00063 else 00064 { 00065 correlate_rows_cols_auto<Pixel, OfxAllocator>( 00066 this->_srcView, _params._gilKernelX, _params._gilKernelY, dst, proc_tl, _params._boundary_option ); 00067 } 00068 } 00069 00070 } 00071 } 00072 } 00073