void ProgressPanel::startTask(const NodePtr& node, const int firstFrame, const int lastFrame, const int frameStep, const bool canPause, const bool canCancel, const QString& message, const boost::shared_ptr<ProcessHandler>& process) { assert( QThread::currentThread() == qApp->thread() ); if (!node) { return; } assert( (canPause && firstFrame != INT_MIN && lastFrame != INT_MAX) || !canPause ); ProgressTaskInfoPtr task; { QMutexLocker k(&_imp->tasksMutex); task = _imp->findTask(node); } if (task) { task->cancelTask(false, 1); removeTaskFromTable(task); } QMutexLocker k(&_imp->tasksMutex); task.reset( new ProgressTaskInfo(this, node, firstFrame, lastFrame, frameStep, canPause, canCancel, message, process) ); if ( canPause || node->getEffectInstance()->isOutput() ) { task->createItems(); QTimer::singleShot( NATRON_DISPLAY_PROGRESS_PANEL_AFTER_MS, this, SLOT(onShowProgressPanelTimerTriggered()) ); } if (process) { connectProcessSlots( task.get(), process.get() ); } if (!process) { if ( node->getEffectInstance()->isOutput() ) { OutputEffectInstance* isOutput = dynamic_cast<OutputEffectInstance*>( node->getEffectInstance().get() ); if (isOutput) { boost::shared_ptr<RenderEngine> engine = isOutput->getRenderEngine(); assert(engine); QObject::connect( engine.get(), SIGNAL(frameRendered(int,double)), task.get(), SLOT(onRenderEngineFrameComputed(int,double)) ); QObject::connect( engine.get(), SIGNAL(renderFinished(int)), task.get(), SLOT(onRenderEngineStopped(int)) ); QObject::connect( task.get(), SIGNAL(taskCanceled()), engine.get(), SLOT(abortRendering_non_blocking()) ); } } }
void ProgressPanel::onTaskRestarted(const NodePtr& node, const boost::shared_ptr<ProcessHandler>& process) { QMutexLocker k(&_imp->tasksMutex); ProgressTaskInfoPtr task; task = _imp->findTask(node); if (!task) { return; } //The process may have changed if (process) { task->setProcesshandler(process); connectProcessSlots(task.get(), process.get()); } }
void ProgressPanel::startTask(const NodePtr& node, const TimeValue firstFrame, const TimeValue lastFrame, const TimeValue frameStep, const bool canPause, const bool canCancel, const QString& message, const ProcessHandlerPtr& process) { assert( QThread::currentThread() == qApp->thread() ); if (!node) { return; } assert( (canPause && firstFrame != INT_MIN && lastFrame != INT_MAX) || !canPause ); ProgressTaskInfoPtr task; { QMutexLocker k(&_imp->tasksMutex); task = _imp->findTask(node); } if (task) { task->cancelTask(false, 1); removeTaskFromTable(task); } QMutexLocker k(&_imp->tasksMutex); task.reset( new ProgressTaskInfo(this, node, firstFrame, lastFrame, frameStep, canPause, canCancel, message, process) ); if ( canPause || node->getEffectInstance()->isOutput() ) { task->createItems(); QTimer::singleShot( NATRON_DISPLAY_PROGRESS_PANEL_AFTER_MS, this, SLOT(onShowProgressPanelTimerTriggered()) ); } if (process) { connectProcessSlots( task.get(), process.get() ); } if (!process) { if ( node->getEffectInstance()->isOutput() ) { if ( getGui() && !getGui()->isGUIFrozen() && appPTR->getCurrentSettings()->isAutoTurboEnabled() ) { getGui()->onFreezeUIButtonClicked(true); } RenderEnginePtr engine = node->getRenderEngine(); assert(engine); QObject::connect( engine.get(), SIGNAL(frameRendered(int,double)), task.get(), SLOT(onRenderEngineFrameComputed(int,double)) ); QObject::connect( engine.get(), SIGNAL(renderFinished(int)), task.get(), SLOT(onRenderEngineStopped(int)) ); QObject::connect( task.get(), SIGNAL(taskCanceled()), engine.get(), SLOT(abortRendering_non_blocking()) ); } } _imp->tasks[node] = task; } // ProgressPanel::startTask