MCPcopy Create free account
hub / github.com/MrKepzie/Natron / createOfxImageEffectInstance

Method createOfxImageEffectInstance

Engine/OfxEffectInstance.cpp:340–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340void
341OfxEffectInstance::createOfxImageEffectInstance(OFX::Host::ImageEffect::ImageEffectPlugin* plugin,
342 OFX::Host::ImageEffect::Descriptor* desc,
343 ContextEnum context,
344 const NodeSerialization* serialization,
345 const CreateNodeArgs& args
346#ifndef NATRON_ENABLE_IO_META_NODES
347 ,
348 bool allowFileDialogs,
349 bool *hasUsedFileDialog
350#endif
351 )
352{
353 /*Replicate of the code in OFX::Host::ImageEffect::ImageEffectPlugin::createInstance.
354 We need to pass more parameters to the constructor . That means we cannot
355 create it in the virtual function newInstance. Thus we create it before
356 instanciating the OfxImageEffect. The problem is that calling OFX::Host::ImageEffect::ImageEffectPlugin::createInstance
357 creates the OfxImageEffect and calls populate(). populate() will actually create all OfxClipInstance and OfxParamInstance.
358 All these subclasses need a valid pointer to an this. Hence we need to set the pointer to this in
359 OfxImageEffect BEFORE calling populate().
360 */
361
362 ///Only called from the main thread.
363 assert( QThread::currentThread() == qApp->thread() );
364 assert(plugin && desc && context != eContextNone);
365
366
367 _imp->context = context;
368
369 if (context == eContextWriter) {
370 _imp->isOutput = true;
371 }
372 if (context == eContextWriter || context == eContextReader) {
373 // Writers don't support render scale (full-resolution images are written to disk)
374 // Readers don't support render scale otherwise each mipmap level would require a file decoding
375 setSupportsRenderScaleMaybe(eSupportsNo);
376 }
377
378 std::string images;
379
380 try {
381 _imp->effect.reset( new OfxImageEffectInstance(plugin, *desc, mapContextToString(context), false) );
382 assert(_imp->effect);
383
384 boost::shared_ptr<OfxEffectInstance> thisShared = boost::dynamic_pointer_cast<OfxEffectInstance>( shared_from_this() );
385 _imp->effect->setOfxEffectInstance(thisShared);
386
387 _imp->natronPluginID = plugin->getIdentifier();
388
389 OfxEffectInstance::MappedInputV clips = inputClipsCopyWithoutOutput();
390 _imp->nbSourceClips = (int)clips.size();
391
392 _imp->clipsInfos.resize( clips.size() );
393 for (unsigned i = 0; i < clips.size(); ++i) {
394 OfxEffectInstancePrivate::ClipsInfo info;
395 info.optional = clips[i]->isOptional() || info.rotoBrush;
396 info.mask = clips[i]->isMask();
397 info.rotoBrush = clips[i]->getName() == CLIP_OFX_ROTO && getNode()->isRotoNode();

Callers 1

createOfxEffectMethod · 0.80

Calls 15

getAppFunction · 0.85
isMaskMethod · 0.80
getNameMethod · 0.80
getPluginMethod · 0.80
emptyMethod · 0.80
getOfxPluginMethod · 0.80
loadKnobsMethod · 0.80

Tested by

no test coverage detected