source: synfigstudio/trunk/fuentes/src/gui/asyncrenderer.h @ 481

Last change on this file since 481 was 481, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 3.7 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file asyncrenderer.h
3**      \brief Template Header
4**
5**      $Id$
6**
7**      \legal
8**      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9**      Copyright (c) 2007 Chris Moore
10**
11**      This package is free software; you can redistribute it and/or
12**      modify it under the terms of the GNU General Public License as
13**      published by the Free Software Foundation; either version 2 of
14**      the License, or (at your option) any later version.
15**
16**      This package is distributed in the hope that it will be useful,
17**      but WITHOUT ANY WARRANTY; without even the implied warranty of
18**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19**      General Public License for more details.
20**      \endlegal
21*/
22/* ========================================================================= */
23
24/* === S T A R T =========================================================== */
25
26#ifndef __SYNFIG_ASYNCRENDERER_H
27#define __SYNFIG_ASYNCRENDERER_H
28
29/* === H E A D E R S ======================================================= */
30
31#include <ETL/handle>
32#include <sigc++/signal.h>
33#include <sigc++/trackable.h>
34#include <sigc++/connection.h>
35
36#include <synfig/target_scanline.h>
37#include <synfig/target_tile.h>
38#include <synfig/target_cairo.h>
39#include <synfig/target_cairo_tile.h>
40#include <synfig/surface.h>
41#include <glibmm/main.h>
42#include <ETL/ref_count>
43#include <glibmm/thread.h>
44#include <glibmm/dispatcher.h>
45
46#include "app.h"
47
48/* === M A C R O S ========================================================= */
49
50// uncomment define SINGLE_THREADED to use a single thread, and hopefully get more stability (dooglus)
51// changed to be default if using windows (Nov 2009 pixelgeek) - see app.h
52#ifdef SINGLE_THREADED
53#  define single_threaded()     App::single_threaded
54#endif
55
56/* === T Y P E D E F S ===================================================== */
57
58/* === C L A S S E S & S T R U C T S ======================================= */
59
60namespace studio {
61
62class AsyncRenderer : public etl::shared_object, public sigc::trackable
63{
64        //! Signal emmited when target has been stopped or has finished
65        sigc::signal<void> signal_finished_;
66        //! Signal emmited when target has succedded
67        sigc::signal<void> signal_success_;
68
69        //! Seems to be unused
70        std::list<sigc::connection> activity_connection_list;
71       
72        //! The target that is going to be asynchronously rendered.
73        etl::handle<synfig::Target> target;
74
75        //! Set to true when target render fails.
76        bool error;
77        //! Set to true when target render succedded
78        bool success;
79
80        synfig::ProgressCallback *cb;
81        //! Signal to be emmited when the target is requested to stop
82        sigc::signal<void> signal_stop_;
83
84        Glib::Thread* render_thread;
85        Glib::Dispatcher signal_done_;
86        Glib::Mutex mutex;
87        sigc::connection done_connection;
88
89        Glib::TimeVal start_time;
90        Glib::TimeVal finish_time;
91
92        /*
93 --     ** -- P A R E N T   M E M B E R S -----------------------------------------
94        */
95public:
96
97        AsyncRenderer(etl::handle<synfig::Target> target,synfig::ProgressCallback *cb=0);
98        virtual ~AsyncRenderer();
99
100        void start();
101        void stop();
102        void pause();
103        void resume();
104#ifdef SINGLE_THREADED
105        void rendering_progress();
106        bool updating;
107#endif
108
109        bool has_error()const { return error; }
110        bool has_success()const { return success; }
111        synfig::Real get_execution_time() const { return (finish_time - start_time).as_double(); }
112
113        sigc::signal<void>& signal_finished() { return signal_finished_; }
114        sigc::signal<void>& signal_success() { return signal_success_; }
115
116private:
117
118        void render_target();
119        void start_();
120
121        /*
122 --     ** -- C H I L D   M E M B E R S -------------------------------------------
123        */
124
125protected:
126
127};
128
129}; // END of namespace studio
130
131/* === E N D =============================================================== */
132
133#endif
Note: See TracBrowser for help on using the repository browser.