Example #1
0
void process_job (Job& job)
{
	VERBOSE_OUT(3) << job.filename.c_str() << " -- " << std::endl;
	VERBOSE_OUT(3) << '\t'
				   << boost::format("w:%d, h:%d, a:%d, pxaspect:%f, imaspect:%f, span:%f")
                                    % job.desc.get_w()
                                    % job.desc.get_h()
                                    % job.desc.get_antialias()
                                    % job.desc.get_pixel_aspect()
                                    % job.desc.get_image_aspect()
                                    % job.desc.get_span()
                    << std::endl;

	VERBOSE_OUT(3) << '\t'
				   << boost::format("tl:[%f,%f], br:[%f,%f], focus:[%f,%f]")
                                    % job.desc.get_tl()[0]
                                    % job.desc.get_tl()[1]
                                    % job.desc.get_br()[0]
                                    % job.desc.get_br()[1]
                                    % job.desc.get_focus()[0]
                                    % job.desc.get_focus()[1]
                    << std::endl;

	RenderProgress p;
	p.task(job.filename + " ==> " + job.outfilename);

	if(job.sifout)
	{
		// todo: support containers
		if(!save_canvas(FileSystemNative::instance()->get_identifier(job.outfilename), job.canvas))
			throw (SynfigToolException(SYNFIGTOOL_RENDERFAILURE, _("Render Failure.")));
	}
	else
	{
		VERBOSE_OUT(1) << _("Rendering...") << std::endl;
		boost::chrono::system_clock::time_point start_timepoint =
            boost::chrono::system_clock::now();

		// Call the render member of the target
		if(!job.target->render(&p))
			throw (SynfigToolException(SYNFIGTOOL_RENDERFAILURE, _("Render Failure.")));

		if(SynfigToolGeneralOptions::instance()->should_print_benchmarks())
        {
            boost::chrono::duration<double> duration =
                boost::chrono::system_clock::now() - start_timepoint;

            std::cout << job.filename.c_str()
                      << _(": Rendered in ")
                      << duration.count()
                      << _(" seconds.") << std::endl;
        }
	}

	VERBOSE_OUT(1) << _("Done.") << std::endl;
}