TuttleOFX
1
|
00001 00002 #include <boost/gil/gil_all.hpp> 00003 00004 namespace tuttle { 00005 namespace plugin { 00006 00007 template< template<class> class Process, 00008 bool planar, class Layout, class Bits, 00009 class Plugin > 00010 void doGilRender( Plugin& plugin, const OFX::RenderArguments& args ) 00011 { 00012 typedef boost::gil::pixel<Bits, Layout> Pixel; 00013 typedef boost::gil::image<Pixel, planar> Image; 00014 typedef typename Image::view_t View; 00015 00016 Process<View> procObj( plugin ); 00017 00018 procObj.setupAndProcess( args ); 00019 } 00020 00021 template< template<class> class Process, 00022 bool planar, class Layout, 00023 class Plugin> 00024 void doGilRender( Plugin& plugin, const OFX::RenderArguments& args, const OFX::EBitDepth bitDepth ) 00025 { 00026 switch( bitDepth ) 00027 { 00028 case OFX::eBitDepthUByte: 00029 { 00030 doGilRender<Process, planar, Layout, boost::gil::bits8>( plugin, args ); 00031 return; 00032 } 00033 case OFX::eBitDepthUShort: 00034 { 00035 doGilRender<Process, planar, Layout, boost::gil::bits16>( plugin, args ); 00036 return; 00037 } 00038 case OFX::eBitDepthFloat: 00039 { 00040 doGilRender<Process, planar, Layout, boost::gil::bits32f>( plugin, args ); 00041 return; 00042 } 00043 case OFX::eBitDepthCustom: 00044 case OFX::eBitDepthNone: 00045 { 00046 BOOST_THROW_EXCEPTION( exception::Unsupported() 00047 << exception::user() + "Bit depth (" + mapBitDepthEnumToString(bitDepth) + ") not recognized by the plugin." ); 00048 } 00049 } 00050 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00051 } 00052 00053 template< template<class> class Process, 00054 bool planar, 00055 class Plugin > 00056 void doGilRender( Plugin& plugin, const OFX::RenderArguments& args, const OFX::EPixelComponent component, const OFX::EBitDepth bitDepth ) 00057 { 00058 switch( component ) 00059 { 00060 case OFX::ePixelComponentRGBA: 00061 { 00062 doGilRender<Process, planar, boost::gil::rgba_layout_t>( plugin, args, bitDepth ); 00063 return; 00064 } 00065 case OFX::ePixelComponentRGB: 00066 { 00067 doGilRender<Process, planar, boost::gil::rgb_layout_t>( plugin, args, bitDepth ); 00068 return; 00069 } 00070 case OFX::ePixelComponentAlpha: 00071 { 00072 doGilRender<Process, planar, boost::gil::gray_layout_t>( plugin, args, bitDepth ); 00073 return; 00074 } 00075 case OFX::ePixelComponentCustom: 00076 case OFX::ePixelComponentNone: 00077 { 00078 BOOST_THROW_EXCEPTION( exception::Unsupported() 00079 << exception::user() + "Pixel component (" + mapPixelComponentEnumToString(component) + ") not supported by the plugin." ); 00080 } 00081 } 00082 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00083 } 00084 00085 template< template<class> class Process, 00086 class Plugin > 00087 void doGilRender( Plugin& plugin, const OFX::RenderArguments& args, const OFX::Clip& clip ) 00088 { 00089 // if( ! clip.isPlanar() ) 00090 doGilRender<Process, false, Plugin>( plugin, args, clip.getPixelComponents(), clip.getPixelDepth() ); 00091 } 00092 00093 /** 00094 * @brief This render function, instanciate a Process class templated with the image type (layout and bit depth). 00095 * @param[in] args Rendering parameters 00096 */ 00097 template<template<class> class Process, class Plugin> 00098 void doGilRender( Plugin& plugin, const OFX::RenderArguments& args ) 00099 { 00100 // instantiate the render code based on the pixel depth of the dst clip 00101 doGilRender<Process, Plugin>( plugin, args, *plugin._clipDst ); 00102 } 00103 00104 00105 template< template<class,class> class Process, 00106 bool sPlanar, class SLayout, class SBits, 00107 bool dPlanar, class DLayout, class DBits, 00108 class Plugin > 00109 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args ) 00110 { 00111 typedef boost::gil::pixel<SBits, SLayout> SPixel; 00112 typedef boost::gil::image<SPixel, sPlanar> SImage; 00113 typedef typename SImage::view_t SView; 00114 00115 typedef boost::gil::pixel<DBits, DLayout> DPixel; 00116 typedef boost::gil::image<DPixel, dPlanar> DImage; 00117 typedef typename DImage::view_t DView; 00118 00119 Process<SView, DView> procObj( plugin ); 00120 00121 procObj.setupAndProcess( args ); 00122 } 00123 00124 template< template<class,class> class Process, 00125 bool sPlanar, class SLayout, class SBits, 00126 bool dPlanar, class DLayout, 00127 class Plugin > 00128 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const OFX::EBitDepth dBitDepth ) 00129 { 00130 switch( dBitDepth ) 00131 { 00132 case OFX::eBitDepthUByte: 00133 { 00134 doGilRender2<Process, sPlanar, SLayout, SBits, dPlanar, DLayout, boost::gil::bits8>( plugin, args ); 00135 return; 00136 } 00137 case OFX::eBitDepthUShort: 00138 { 00139 doGilRender2<Process, sPlanar, SLayout, SBits, dPlanar, DLayout, boost::gil::bits16>( plugin, args ); 00140 return; 00141 } 00142 case OFX::eBitDepthFloat: 00143 { 00144 doGilRender2<Process, sPlanar, SLayout, SBits, dPlanar, DLayout, boost::gil::bits32f>( plugin, args ); 00145 return; 00146 } 00147 case OFX::eBitDepthCustom: 00148 case OFX::eBitDepthNone: 00149 { 00150 BOOST_THROW_EXCEPTION( exception::Unsupported() 00151 << exception::user() + "Bit depth (" + mapBitDepthEnumToString(dBitDepth) + ") not recognized by the plugin." ); 00152 } 00153 } 00154 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00155 } 00156 00157 template< template<class,class> class Process, 00158 bool sPlanar, class SLayout, class SBits, 00159 bool dPlanar, 00160 class Plugin > 00161 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const OFX::EPixelComponent dComponent, const OFX::EBitDepth dBitDepth ) 00162 { 00163 switch( dComponent ) 00164 { 00165 case OFX::ePixelComponentRGBA: 00166 { 00167 doGilRender2<Process, sPlanar, SLayout, SBits, dPlanar, boost::gil::rgba_layout_t>( plugin, args, dBitDepth ); 00168 return; 00169 } 00170 case OFX::ePixelComponentRGB: 00171 { 00172 doGilRender2<Process, sPlanar, SLayout, SBits, dPlanar, boost::gil::rgb_layout_t>( plugin, args, dBitDepth ); 00173 return; 00174 } 00175 case OFX::ePixelComponentAlpha: 00176 { 00177 doGilRender2<Process, sPlanar, SLayout, SBits, dPlanar, boost::gil::gray_layout_t>( plugin, args, dBitDepth ); 00178 return; 00179 } 00180 case OFX::ePixelComponentCustom: 00181 case OFX::ePixelComponentNone: 00182 { 00183 BOOST_THROW_EXCEPTION( exception::Unsupported() 00184 << exception::user() + "Pixel component (" + mapPixelComponentEnumToString(dComponent) + ") not supported by the plugin." ); 00185 } 00186 } 00187 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00188 } 00189 00190 template< template<class,class> class Process, 00191 bool sPlanar, class SLayout, class SBits, 00192 class Plugin > 00193 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const bool dPlanar, const OFX::EPixelComponent dComponent, const OFX::EBitDepth dBitDepth ) 00194 { 00195 if( dPlanar ) 00196 { 00197 // doGilRender2<Process, sPlanar, SLayout, SBits, true>( plugin, args, dComponent, dBitDepth ); 00198 } 00199 else 00200 { 00201 doGilRender2<Process, sPlanar, SLayout, SBits, false>( plugin, args, dComponent, dBitDepth ); 00202 } 00203 } 00204 00205 template< template<class,class> class Process, 00206 bool sPlanar, class SLayout, 00207 class Plugin > 00208 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const OFX::EBitDepth sBitDepth, const bool dPlanar, const OFX::EPixelComponent dComponent, const OFX::EBitDepth dBitDepth ) 00209 { 00210 switch( sBitDepth ) 00211 { 00212 case OFX::eBitDepthUByte: 00213 { 00214 doGilRender2<Process, sPlanar, SLayout, boost::gil::bits8>( plugin, args, dPlanar, dComponent, dBitDepth ); 00215 return; 00216 } 00217 case OFX::eBitDepthUShort: 00218 { 00219 doGilRender2<Process, sPlanar, SLayout, boost::gil::bits16>( plugin, args, dPlanar, dComponent, dBitDepth ); 00220 return; 00221 } 00222 case OFX::eBitDepthFloat: 00223 { 00224 doGilRender2<Process, sPlanar, SLayout, boost::gil::bits32f>( plugin, args, dPlanar, dComponent, dBitDepth ); 00225 return; 00226 } 00227 case OFX::eBitDepthCustom: 00228 case OFX::eBitDepthNone: 00229 { 00230 BOOST_THROW_EXCEPTION( exception::Unsupported() 00231 << exception::user() + "Bit depth (" + mapBitDepthEnumToString(sBitDepth) + ") not recognized by the plugin." ); 00232 } 00233 } 00234 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00235 } 00236 00237 template< template<class,class> class Process, 00238 bool sPlanar, 00239 class Plugin > 00240 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const OFX::EPixelComponent sComponent, const OFX::EBitDepth sBitDepth, const bool dPlanar, const OFX::EPixelComponent dComponent, const OFX::EBitDepth dBitDepth ) 00241 { 00242 switch( sComponent ) 00243 { 00244 case OFX::ePixelComponentRGBA: 00245 { 00246 doGilRender2<Process, sPlanar, boost::gil::rgba_layout_t>( plugin, args, sBitDepth, dPlanar, dComponent, dBitDepth ); 00247 return; 00248 } 00249 case OFX::ePixelComponentRGB: 00250 { 00251 doGilRender2<Process, sPlanar, boost::gil::rgb_layout_t>( plugin, args, sBitDepth, dPlanar, dComponent, dBitDepth ); 00252 return; 00253 } 00254 case OFX::ePixelComponentAlpha: 00255 { 00256 doGilRender2<Process, sPlanar, boost::gil::gray_layout_t>( plugin, args, sBitDepth, dPlanar, dComponent, dBitDepth ); 00257 return; 00258 } 00259 case OFX::ePixelComponentCustom: 00260 case OFX::ePixelComponentNone: 00261 { 00262 BOOST_THROW_EXCEPTION( exception::Unsupported() 00263 << exception::user() + "Pixel component (" + mapPixelComponentEnumToString(sComponent) + ") not supported by the plugin." ); 00264 } 00265 } 00266 } 00267 00268 00269 template< template<class,class> class Process, 00270 class Plugin > 00271 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const bool sPlanar, const OFX::EPixelComponent sComponent, const OFX::EBitDepth sBitDepth, const bool dPlanar, const OFX::EPixelComponent dComponent, const OFX::EBitDepth dBitDepth ) 00272 { 00273 if( sPlanar ) 00274 { 00275 // doGilRender2<Process, true>( plugin, args, sComponent, sBitDepth, dPlanar, dComponent, dBitDepth ); 00276 } 00277 else 00278 { 00279 doGilRender2<Process, false>( plugin, args, sComponent, sBitDepth, dPlanar, dComponent, dBitDepth ); 00280 } 00281 } 00282 00283 template< template<class,class> class Process, 00284 class Plugin> 00285 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args, const OFX::Clip& sClip, const OFX::Clip& dClip ) 00286 { 00287 doGilRender2<Process, Plugin>( plugin, args, false, sClip.getPixelComponents(), sClip.getPixelDepth(), false, dClip.getPixelComponents(), dClip.getPixelDepth() ); 00288 } 00289 00290 /** 00291 * @brief This render function, instanciate a Process class templated with the image type (layout and bit depth). 00292 * @param[in] args Rendering parameters 00293 */ 00294 template<template<class,class> class Process, class Plugin> 00295 void doGilRender2( Plugin& plugin, const OFX::RenderArguments& args ) 00296 { 00297 doGilRender2<Process, Plugin>( plugin, args, *plugin._clipSrc, *plugin._clipDst ); 00298 } 00299 00300 template< template<class,class,class> class Process, 00301 bool s1planar, class S1Layout, class S1Bits, 00302 bool s2planar, class S2Layout, class S2Bits, 00303 bool dPlanar, class DLayout, class DBits, 00304 class Plugin> 00305 void doGilRender3( Plugin& plugin, const OFX::RenderArguments& args ) 00306 { 00307 typedef boost::gil::pixel<S1Bits, S1Layout> S1Pixel; 00308 typedef boost::gil::image<S1Pixel, s1planar> S1Image; 00309 typedef typename S1Image::view_t S1View; 00310 00311 typedef boost::gil::pixel<S2Bits, S2Layout> S2Pixel; 00312 typedef boost::gil::image<S2Pixel, s2planar> S2Image; 00313 typedef typename S2Image::view_t S2View; 00314 00315 typedef boost::gil::pixel<DBits, DLayout> DPixel; 00316 typedef boost::gil::image<DPixel, dPlanar> DImage; 00317 typedef typename DImage::view_t DView; 00318 00319 Process<S1View, S2View, DView> procObj( plugin ); 00320 00321 procObj.setupAndProcess( args ); 00322 } 00323 00324 00325 } 00326 } 00327 00328