Exemple #1
0
        /** @brief called to process everything */
        virtual void process(void)
        {
            // If _dstImg was set, check that the _renderWindow is lying into dstBounds
            if (_dstImg) {
                const OfxRectI& dstBounds = _dstImg->getBounds();
                // is the renderWindow within dstBounds ?
                assert(dstBounds.x1 <= _renderWindow.x1 && _renderWindow.x2 <= dstBounds.x2 &&
                       dstBounds.y1 <= _renderWindow.y1 && _renderWindow.y2 <= dstBounds.y2);
                // exit gracefully in case of error
                if (!(dstBounds.x1 <= _renderWindow.x1 && _renderWindow.x2 <= dstBounds.x2 &&
                      dstBounds.y1 <= _renderWindow.y1 && _renderWindow.y2 <= dstBounds.y2) ||
                    (_renderWindow.x1 >= _renderWindow.x2) ||
                    (_renderWindow.y1 >= _renderWindow.y2)) {
                    return;
                }
            }

            // call the pre MP pass
            preProcess();

            // make sure there are at least 4096 pixels per CPU and at least 1 line par CPU
            unsigned int nCPUs = ((std::min)(_renderWindow.x2 - _renderWindow.x1, 4096) *
                                  (_renderWindow.y2 - _renderWindow.y1)) / 4096;
            // make sure the number of CPUs is valid (and use at least 1 CPU)
            nCPUs = std::max(1u, (std::min)(nCPUs, OFX::MultiThread::getNumCPUs()));

            // call the base multi threading code, should put a pre & post thread calls in too
            multiThread(nCPUs);

            // call the post MP pass
            postProcess();
        }
	/** @brief called to process everything */
	virtual void process()
	{
		// is it OK ?
		if( _renderArgs.renderWindow.x2 - _renderArgs.renderWindow.x1 == 0 ||
			_renderArgs.renderWindow.y2 - _renderArgs.renderWindow.y1 == 0 )
		{
			BOOST_THROW_EXCEPTION( exception::ImageFormat() << exception::user( "RenderWindow empty !" ) );
		}
		// call the pre MP pass
		preProcess();

		// call the base multi threading code, should put a pre & post thread calls in too
		multiThread( _nbThreads );

		// call the post MP pass
		postProcess();
	}