X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fasyncrenderer.cpp;h=ca7de13cb45168ad1b0624f2a3598b660c38b4aa;hb=334e15ce6c4d9b1f30a168a55e7ef4d31320d568;hp=66e78c5878eb66b11d3f186d7e7a26a279877740;hpb=1f59228ea073eb60029cddfb4ee1a70de7f40f3d;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp b/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp index 66e78c5..ca7de13 100644 --- a/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp +++ b/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp @@ -6,6 +6,7 @@ ** ** \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 @@ -53,6 +54,8 @@ #include #include +#include "general.h" + #endif /* === U S I N G =========================================================== */ @@ -123,8 +126,7 @@ public: } void set_dead() { - Glib::Mutex::Lock lock(mutex, NotLock); - if (!single_threaded()) lock.acquire(); + Glib::Mutex::Lock lock(mutex); alive_flag=false; } @@ -160,8 +162,7 @@ public: 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) { @@ -183,8 +184,7 @@ public: 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(); @@ -195,6 +195,13 @@ public: { 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(); @@ -218,8 +225,7 @@ public: break; } } - Glib::Mutex::Lock lock(mutex, NotLock); - if (!single_threaded()) lock.acquire(); + Glib::Mutex::Lock lock(mutex); if(!alive_flag) return; return warm_target->end_frame(); @@ -279,8 +285,7 @@ public: void set_dead() { - Glib::Mutex::Lock lock(mutex, NotLock); - if (!single_threaded()) lock.acquire(); + Glib::Mutex::Lock lock(mutex); alive_flag=false; } @@ -292,8 +297,7 @@ public: virtual void end_frame() { { - Glib::Mutex::Lock lock(mutex, NotLock); - if (!single_threaded()) lock.acquire(); + Glib::Mutex::Lock lock(mutex); if(!alive_flag) return; @@ -312,7 +316,9 @@ public: #endif } - if (!single_threaded()) + if (single_threaded()) + signal_progress()(); + else while(alive_flag && !ready_next) { Glib::Mutex::Lock lock(mutex); @@ -324,8 +330,7 @@ public: 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]; } @@ -337,8 +342,7 @@ public: 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(); @@ -393,8 +397,7 @@ AsyncRenderer::stop() { if(target) { - Glib::Mutex::Lock lock(mutex, NotLock); - if (!single_threaded()) lock.acquire(); + Glib::Mutex::Lock lock(mutex); done_connection.disconnect(); if(render_thread) @@ -502,7 +505,7 @@ AsyncRenderer::render_target() #endif } - if (single_threaded() || mutex.trylock()) + if(mutex.trylock()) { #ifdef GLIB_DISPATCHER_BROKEN done_connection=Glib::signal_timeout().connect( @@ -515,6 +518,6 @@ AsyncRenderer::render_target() #else signal_done_.emit(); #endif - if (!single_threaded()) mutex.unlock(); + mutex.unlock(); } }