**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
#include <synfig/general.h>
#include <ETL/clock>
+#include "general.h"
+
#endif
/* === U S I N G =========================================================== */
}
void set_dead()
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
alive_flag=false;
}
assert(surface);
if(!alive_flag)
return false;
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
tile_queue.push_back(tile_t(surface,gx,gy));
if(tile_queue.size()==1)
{
void tile_ready()
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
if(!alive_flag)
{
tile_queue.clear();
{
tile_t& tile(tile_queue.front());
+ if (getenv("SYNFIG_SHOW_TILE_OUTLINES"))
+ {
+ Color red(1,0,0);
+ tile.surface.fill(red, 0, 0, 1, tile.surface.get_h());
+ tile.surface.fill(red, 0, 0, tile.surface.get_w(), 1);
+ }
+
alive_flag=warm_target->add_tile(tile.surface,tile.x,tile.y);
tile_queue.pop_front();
virtual void end_frame()
{
+#ifdef SINGLE_THREADED
if (!single_threaded())
{
+#endif
while(alive_flag)
{
Glib::Mutex::Lock lock(mutex);
else
break;
}
+#ifdef SINGLE_THREADED
}
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+#endif
+ Glib::Mutex::Lock lock(mutex);
if(!alive_flag)
return;
return warm_target->end_frame();
void set_dead()
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
alive_flag=false;
}
virtual void end_frame()
{
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
if(!alive_flag)
return;
#endif
}
- if (!single_threaded())
+#ifdef SINGLE_THREADED
+ if (single_threaded())
+ signal_progress()();
+ else
+#endif
while(alive_flag && !ready_next)
{
Glib::Mutex::Lock lock(mutex);
virtual Color * start_scanline(int scanline)
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
return surface[scanline];
}
void frame_ready()
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
if(alive_flag)
alive_flag=warm_target->add_frame(&surface);
- if (!single_threaded()) cond_frame_queue_empty.signal();
+#ifdef SINGLE_THREADED
+ if (!single_threaded())
+#endif
+ cond_frame_queue_empty.signal();
ready_next=true;
}
};
AsyncRenderer::AsyncRenderer(etl::handle<synfig::Target> target_,synfig::ProgressCallback *cb):
error(false),
success(false),
- cb(cb),
- updating(false)
+ cb(cb)
+#ifdef SINGLE_THREADED
+ , updating(false)
+#endif
{
render_thread=0;
if(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
{
if(target)
{
- Glib::Mutex::Lock lock(mutex, NotLock);
- if (!single_threaded()) lock.acquire();
+ Glib::Mutex::Lock lock(mutex);
done_connection.disconnect();
if(render_thread)
signal_stop_();
#if REJOIN_ON_STOP
- if (!single_threaded()) render_thread->join();
+#ifdef SINGLE_THREADED
+ if (!single_threaded())
+#endif
+ render_thread->join();
#endif
// Make sure all the dispatch crap is cleared out
);
}
+#ifdef SINGLE_THREADED
void
AsyncRenderer::rendering_progress()
{
while(studio::App::events_pending()) studio::App::iteration(false);
updating = false;
}
+#endif
void
AsyncRenderer::start_()
done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop));
#endif
+#ifdef SINGLE_THREADED
if (single_threaded())
{
synfig::info("%s:%d rendering in the same thread", __FILE__, __LINE__);
render_target();
}
else
+#endif
{
render_thread=Glib::Thread::create(
sigc::mem_fun(*this,&AsyncRenderer::render_target),
#endif
}
- if (single_threaded() || mutex.trylock())
+ if(mutex.trylock())
{
#ifdef GLIB_DISPATCHER_BROKEN
done_connection=Glib::signal_timeout().connect(
#else
signal_done_.emit();
#endif
- if (!single_threaded()) mutex.unlock();
+ mutex.unlock();
}
}