/*! \file asyncrenderer.cpp
** \brief Template File
**
-** $Id: asyncrenderer.cpp,v 1.5 2005/01/12 07:03:42 darco Exp $
+** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
#endif
#include "asyncrenderer.h"
+#include "app.h"
#include <glibmm/thread.h>
#include <glibmm/dispatcher.h>
virtual void end_frame()
{
- while(alive_flag)
+ if (!single_threaded())
{
- Glib::Mutex::Lock lock(mutex);
- if(!tile_queue.empty() && alive_flag)
+ while(alive_flag)
{
- if(cond_tile_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
+ Glib::Mutex::Lock lock(mutex);
+ if(!tile_queue.empty() && alive_flag)
+ {
+ if(cond_tile_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
+ break;
+ }
+ else
break;
}
- else
- break;
}
Glib::Mutex::Lock lock(mutex);
if(!alive_flag)
alive_flag=false;
}
- virtual bool start_frame(synfig::ProgressCallback *cb=0)
+ virtual bool start_frame(synfig::ProgressCallback */*cb*/=0)
{
return alive_flag;
}
#else
frame_ready_signal();
#endif
- }
-
- while(alive_flag && !ready_next)
- {
- Glib::Mutex::Lock lock(mutex);
- if(cond_frame_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
- break;
}
+
+ if (!single_threaded())
+ while(alive_flag && !ready_next)
+ {
+ Glib::Mutex::Lock lock(mutex);
+ if(cond_frame_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
+ break;
+ }
}
Glib::Mutex::Lock lock(mutex);
if(alive_flag)
alive_flag=warm_target->add_frame(&surface);
- cond_frame_queue_empty.signal();
+ if (!single_threaded()) cond_frame_queue_empty.signal();
ready_next=true;
}
};
AsyncRenderer::AsyncRenderer(etl::handle<synfig::Target> target_,synfig::ProgressCallback *cb):
error(false),
success(false),
- cb(cb)
+ cb(cb),
+ updating(false)
{
render_thread=0;
if(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
signal_stop_();
#if REJOIN_ON_STOP
- render_thread->join();
+ if (!single_threaded()) render_thread->join();
#endif
// Make sure all the dispatch crap is cleared out
}
void
+AsyncRenderer::rendering_progress()
+{
+ updating = true;
+ while(studio::App::events_pending()) studio::App::iteration(false);
+ updating = false;
+}
+
+void
AsyncRenderer::start_()
{
error=false;success=false;
done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop));
#endif
- render_thread=Glib::Thread::create(
- sigc::mem_fun(*this,&AsyncRenderer::render_target),
+ if (single_threaded())
+ {
+ synfig::info("%s:%d rendering in the same thread", __FILE__, __LINE__);
+ target->signal_progress().connect(sigc::mem_fun(this,&AsyncRenderer::rendering_progress));
+ render_thread = (Glib::Thread*)1;
+ render_target();
+ }
+ else
+ {
+ render_thread=Glib::Thread::create(
+ sigc::mem_fun(*this,&AsyncRenderer::render_target),
#if REJOIN_ON_STOP
- true
+ true
#else
- false
+ false
#endif
- );
- assert(render_thread);
+ );
+ assert(render_thread);
+ }
}
else
{