コード例 #1
0
ファイル: basic.cpp プロジェクト: gobomus/pluginOFX
        /** @brief overridden from OFX::MultiThread::Processor. This function is called once on each SMP thread by the base class */
        void multiThreadFunction(unsigned int threadId, unsigned int nThreads)
        {
            // slice the y range into the number of threads it has
            unsigned int dy = _renderWindow.y2 - _renderWindow.y1;
            // the following is equivalent to std::ceil(dy/(double)nThreads);
            unsigned int h = (dy+nThreads-1)/nThreads;
            if (h == 0) {
                // there are more threads than lines to process
                h = 1;
            }
            if (threadId * h >= dy) {
                // empty render subwindow
                return;
            }
            unsigned int y1 = _renderWindow.y1 + threadId * h;

            unsigned int step = (threadId + 1) * h;
            unsigned int y2 = _renderWindow.y1 + (step < dy ? step : dy);

            OfxRectI win = _renderWindow;
            win.y1 = y1; win.y2 = y2;

            // and render that thread on each
            multiThreadProcessImages(win);
        }
コード例 #2
0
	/** @brief overridden from OFX::MultiThread::Processor. This function is called once on each SMP thread by the base class */
	void multiThreadFunction( const unsigned int threadId, const unsigned int nThreads )
	{
		// slice the y range into the number of threads it has
		const int dy   = std::abs( _renderArgs.renderWindow.y2 - _renderArgs.renderWindow.y1 );
		const int y1   = _renderArgs.renderWindow.y1 + threadId * dy / nThreads;
		const int step = ( threadId + 1 ) * dy / nThreads;
		const int y2   = _renderArgs.renderWindow.y1 + ( step < dy ? step : dy );

		OfxRectI winRoW = _renderArgs.renderWindow;
		winRoW.y1 = y1;
		winRoW.y2 = y2;

		// and render that thread on each
		multiThreadProcessImages( winRoW );
	}