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

Method threadLoopOnce

Engine/TrackerContext.cpp:1815–1989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813};
1814
1815NATRON_NAMESPACE_ANONYMOUS_EXIT
1816
1817GenericSchedulerThread::ThreadStateEnum
1818TrackScheduler::threadLoopOnce(const ThreadStartArgsPtr& inArgs)
1819{
1820 boost::shared_ptr<TrackArgs> args = boost::dynamic_pointer_cast<TrackArgs>(inArgs);
1821
1822 assert(args);
1823
1824 ThreadStateEnum state = eThreadStateActive;
1825 boost::shared_ptr<TimeLine> timeline = args->getTimeLine();
1826 ViewerInstance* viewer = args->getViewer();
1827 int end = args->getEnd();
1828 int start = args->getStart();
1829 int cur = start;
1830 int frameStep = args->getStep();
1831 int framesCount = 0;
1832 if (frameStep != 0) {
1833 framesCount = frameStep > 0 ? (end - start) / frameStep : (start - end) / std::abs(frameStep);
1834 }
1835
1836
1837 const std::vector<boost::shared_ptr<TrackMarkerAndOptions> >& tracks = args->getTracks();
1838 const int numTracks = (int)tracks.size();
1839 std::vector<int> trackIndexes( tracks.size() );
1840 for (std::size_t i = 0; i < tracks.size(); ++i) {
1841 trackIndexes[i] = i;
1842 tracks[i]->natronMarker->notifyTrackingStarted();
1843 // unslave the enabled knob, since it is slaved to the gui but we may modify it
1844 boost::shared_ptr<KnobBool> enabledKnob = tracks[i]->natronMarker->getEnabledKnob();
1845 enabledKnob->unSlave(0, false);
1846 }
1847
1848 // Beyond TRACKER_MAX_TRACKS_FOR_PARTIAL_VIEWER_UPDATE it becomes more expensive to render all partial rectangles
1849 // than just render the whole viewer RoI
1850 const bool doPartialUpdates = numTracks < TRACKER_MAX_TRACKS_FOR_PARTIAL_VIEWER_UPDATE;
1851 int lastValidFrame = frameStep > 0 ? start - 1 : start + 1;
1852 bool reportProgress = numTracks > 1 || framesCount > 1;
1853 EffectInstPtr effect = _imp->getNode()->getEffectInstance();
1854 timeval lastProgressUpdateTime;
1855 gettimeofday(&lastProgressUpdateTime, 0);
1856
1857 bool allTrackFailed = false;
1858 {
1859 ///Use RAII style for setting the isDoingPartialUpdates flag so we're sure it gets removed
1860 IsTrackingFlagSetter_RAII __istrackingflag__(effect, this, frameStep, reportProgress, viewer, doPartialUpdates);
1861
1862 if ( (frameStep == 0) || ( (frameStep > 0) && (start >= end) ) || ( (frameStep < 0) && (start <= end) ) ) {
1863 // Invalid range
1864 cur = end;
1865 }
1866
1867
1868 while (cur != end) {
1869 ///Launch parallel thread for each track using the global thread pool
1870 QFuture<bool> future = QtConcurrent::mapped( trackIndexes,
1871 boost::bind(&TrackSchedulerPrivate::trackStepFunctor,
1872 _1,

Callers

nothing calls this directly

Calls 15

absFunction · 0.85
getEndMethod · 0.80
getStartMethod · 0.80
getStepMethod · 0.80
notifyTrackingStartedMethod · 0.80
unSlaveMethod · 0.80
getEffectInstanceMethod · 0.80
seekFrameMethod · 0.80
getRedrawAreasNeededMethod · 0.80
solveTransformParamsMethod · 0.80

Tested by

no test coverage detected