X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fasyncrenderer.cpp;h=745409c82422f803e7b618404046ed69a496cb93;hb=837b63e9fb829d66d43f4f169861f8979f76820d;hp=9c41444bda5ab7c940e7e3905862fb5122a36a66;hpb=3a3c4bca3a17137bec5d7960560934b91ef4146e;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp b/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp index 9c41444..745409c 100644 --- a/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp +++ b/synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp @@ -1,20 +1,21 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \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 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -48,7 +49,7 @@ #include #endif -#include +#include #include #endif @@ -57,7 +58,7 @@ using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; using namespace studio; #define BOREDOM_TIMEOUT 50 @@ -70,11 +71,11 @@ using namespace studio; /* === C L A S S E S ======================================================= */ -class AsyncTarget_Tile : public sinfg::Target_Tile +class AsyncTarget_Tile : public synfig::Target_Tile { public: - etl::handle warm_target; - + etl::handle warm_target; + struct tile_t { Surface surface; @@ -87,17 +88,17 @@ public: }; std::list tile_queue; Glib::Mutex mutex; - + #ifndef GLIB_DISPATCHER_BROKEN Glib::Dispatcher tile_ready_signal; #endif Glib::Cond cond_tile_queue_empty; bool alive_flag; - + sigc::connection ready_connection; - + public: - AsyncTarget_Tile(etl::handle warm_target): + AsyncTarget_Tile(etl::handle warm_target): warm_target(warm_target) { set_avoid_time_sync(warm_target->get_avoid_time_sync()); @@ -114,7 +115,7 @@ public: ready_connection=tile_ready_signal.connect(sigc::mem_fun(*this,&AsyncTarget_Tile::tile_ready)); #endif } - + ~AsyncTarget_Tile() { ready_connection.disconnect(); @@ -124,17 +125,17 @@ public: Glib::Mutex::Lock lock(mutex); alive_flag=false; } - + virtual int total_tiles()const { return warm_target->total_tiles(); } - + virtual int next_tile(int& x, int& y) { if(!alive_flag) return 0; - + return warm_target->next_tile(x,y); } @@ -144,15 +145,15 @@ public: return 0; return warm_target->next_frame(time); } - - virtual bool start_frame(sinfg::ProgressCallback *cb=0) + + virtual bool start_frame(synfig::ProgressCallback *cb=0) { if(!alive_flag) return false; return warm_target->start_frame(cb); } - - virtual bool add_tile(const sinfg::Surface &surface, int gx, int gy) + + virtual bool add_tile(const synfig::Surface &surface, int gx, int gy) { assert(surface); if(!alive_flag) @@ -173,7 +174,7 @@ public: tile_ready_signal(); #endif } - + return alive_flag; } @@ -189,9 +190,9 @@ public: while(!tile_queue.empty() && alive_flag) { tile_t& tile(tile_queue.front()); - + alive_flag=warm_target->add_tile(tile.surface,tile.x,tile.y); - + tile_queue.pop_front(); } cond_tile_queue_empty.signal(); @@ -219,16 +220,16 @@ public: -class AsyncTarget_Scanline : public sinfg::Target_Scanline +class AsyncTarget_Scanline : public synfig::Target_Scanline { public: - etl::handle warm_target; - + etl::handle warm_target; + int scanline_; Surface surface; Glib::Mutex mutex; - + #ifndef GLIB_DISPATCHER_BROKEN Glib::Dispatcher frame_ready_signal; #endif @@ -239,7 +240,7 @@ public: public: - AsyncTarget_Scanline(etl::handle warm_target): + AsyncTarget_Scanline(etl::handle warm_target): warm_target(warm_target) { set_avoid_time_sync(warm_target->get_avoid_time_sync()); @@ -254,7 +255,7 @@ public: #endif surface.set_wh(warm_target->rend_desc().get_w(),warm_target->rend_desc().get_h()); } - + ~AsyncTarget_Scanline() { ready_connection.disconnect(); @@ -273,12 +274,12 @@ public: Glib::Mutex::Lock lock(mutex); alive_flag=false; } - - virtual bool start_frame(sinfg::ProgressCallback *cb=0) - { + + virtual bool start_frame(synfig::ProgressCallback *cb=0) + { return alive_flag; } - + virtual void end_frame() { { @@ -309,14 +310,14 @@ public: } } - + virtual Color * start_scanline(int scanline) { Glib::Mutex::Lock lock(mutex); return surface[scanline]; } - + virtual bool end_scanline() { return alive_flag; @@ -338,32 +339,32 @@ public: /* === M E T H O D S ======================================================= */ -AsyncRenderer::AsyncRenderer(etl::handle target_,sinfg::ProgressCallback *cb): +AsyncRenderer::AsyncRenderer(etl::handle target_,synfig::ProgressCallback *cb): error(false), success(false), cb(cb) { render_thread=0; - if(etl::handle::cast_dynamic(target_)) + if(etl::handle::cast_dynamic(target_)) { etl::handle wrap_target( - new AsyncTarget_Tile(etl::handle::cast_dynamic(target_)) + new AsyncTarget_Tile(etl::handle::cast_dynamic(target_)) ); - + signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Tile::set_dead)); - + target=wrap_target; } - else if(etl::handle::cast_dynamic(target_)) + else if(etl::handle::cast_dynamic(target_)) { etl::handle wrap_target( new AsyncTarget_Scanline( - etl::handle::cast_dynamic(target_) + etl::handle::cast_dynamic(target_) ) ); - + signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Scanline::set_dead)); - + target=wrap_target; } } @@ -380,23 +381,23 @@ AsyncRenderer::stop() { Glib::Mutex::Lock lock(mutex); done_connection.disconnect(); - + if(render_thread) { signal_stop_(); - + #if REJOIN_ON_STOP render_thread->join(); #endif - + // Make sure all the dispatch crap is cleared out //Glib::MainContext::get_default()->iteration(false); - + if(success) signal_success_(); - + signal_finished_(); - + target=0; render_thread=0; } @@ -434,7 +435,7 @@ AsyncRenderer::start_() #ifndef GLIB_DISPATCHER_BROKEN done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop)); #endif - + render_thread=Glib::Thread::create( sigc::mem_fun(*this,&AsyncRenderer::render_target), #if REJOIN_ON_STOP @@ -455,7 +456,7 @@ void AsyncRenderer::render_target() { etl::handle target(AsyncRenderer::target); - + if(target && target->render()) { success=true;