[vlmc-devel] Make WorkflowRenderer a project class.

Hugo Beauzée-Luyssen git at videolan.org
Mon Mar 31 22:42:31 CEST 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Mar 31 21:55:05 2014 +0300| [bfcaf205ae64f78f696d058fc68ee2904ae9ab26] | committer: Hugo Beauzée-Luyssen

Make WorkflowRenderer a project class.

It is now being constructed when a project is created.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=bfcaf205ae64f78f696d058fc68ee2904ae9ab26
---

 src/Gui/MainWindow.cpp                |   16 +++++++---------
 src/Gui/MainWindow.h                  |    1 -
 src/Gui/timeline/Timeline.cpp         |   11 +++++++++--
 src/Gui/timeline/Timeline.h           |    3 ++-
 src/Project/Project.cpp               |    9 ++++++++-
 src/Project/Project.h                 |    5 ++++-
 src/Renderer/WorkflowFileRenderer.cpp |    6 +++---
 src/Renderer/WorkflowFileRenderer.h   |    2 +-
 src/Renderer/WorkflowRenderer.cpp     |    9 ++-------
 src/Renderer/WorkflowRenderer.h       |    8 +-------
 10 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 185e76f..afe496f 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -390,9 +390,7 @@ MainWindow::createStatusBar()
 void
 MainWindow::initializeDockWidgets()
 {
-    m_renderer = new WorkflowRenderer( m_backend );
-    m_renderer->initializeRenderer();
-    m_timeline = new Timeline( m_renderer, this );
+    m_timeline = new Timeline( this );
     m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
     m_timeline->show();
     setCentralWidget( m_timeline );
@@ -466,7 +464,6 @@ MainWindow::setupProjectPreview()
                                         QDockWidget::AllDockWidgetFeatures );
 
     m_projectPreview = new PreviewWidget( dockedWidget );
-    m_projectPreview->setRenderer( m_renderer );
     m_projectPreview->setClipEdition( false );
     KeyboardShortcutHelper* renderShortcut = new KeyboardShortcutHelper( "keyboard/renderpreview", this );
     connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) );
@@ -582,13 +579,12 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h
 {
     if ( m_fileRenderer )
         delete m_fileRenderer;
-    m_fileRenderer = new WorkflowFileRenderer( m_backend );
+    m_fileRenderer = new WorkflowFileRenderer( m_backend, Project::getInstance()->workflow() );
 
     WorkflowFileRendererDialog  *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height );
     dialog->setModal( true );
     dialog->setOutputFileName( outputFileName );
 
-    m_fileRenderer->initializeRenderer();
     m_fileRenderer->run( outputFileName, width, height, fps, vbitrate, abitrate );
 
     if ( dialog->exec() == QDialog::Rejected )
@@ -604,6 +600,8 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h
 bool
 MainWindow::renderVideoSettings( bool shareOnInternet )
 {
+    Project::getInstance()->workflowRenderer()->stop();
+
     RendererSettings *settings = new RendererSettings( shareOnInternet );
 
     if ( settings->exec() == QDialog::Rejected )
@@ -629,7 +627,6 @@ MainWindow::on_actionRender_triggered()
 {
     if ( checkVideoLength() )
     {
-        m_renderer->stop();
         //Setup dialog box for querying render parameters.
         renderVideoSettings( false );
     }
@@ -640,8 +637,6 @@ MainWindow::on_actionShare_On_Internet_triggered()
 {
     if ( checkVideoLength() )
     {
-        m_renderer->stop();
-
         if( !renderVideoSettings( true ) )
             return;
 
@@ -849,6 +844,9 @@ MainWindow::onProjectLoaded(Project* project)
 
     const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
     connect( project->library(), SIGNAL( clipRemoved( const QUuid& ) ), clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
+
+    m_timeline->setRenderer( project->workflowRenderer() );
+    m_projectPreview->setRenderer( project->workflowRenderer() );
 }
 
 #ifdef WITH_CRASHBUTTON
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index be2a70b..47ad5e4 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -129,7 +129,6 @@ private:
     PreviewWidget*          m_clipPreview;
     PreviewWidget*          m_projectPreview;
     WorkflowFileRenderer*   m_fileRenderer;
-    WorkflowRenderer*       m_renderer;
     SettingsDialog*         m_globalPreferences;
     SettingsDialog*         m_DefaultProjectPreferences;
     SettingsDialog*         m_projectPreferences;
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index 1c4162a..2eba749 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -38,8 +38,9 @@
 
 Timeline*   Timeline::m_instance = NULL;
 
-Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
-    QWidget( parent ), m_scale( 1.0 ), m_renderer( renderer )
+Timeline::Timeline( QWidget *parent )
+    : QWidget( parent )
+    , m_scale( 1.0 )
 {
     Q_ASSERT( m_instance == NULL );
     m_instance = this;
@@ -228,3 +229,9 @@ Timeline::load( const QDomElement &root )
         elem = elem.nextSiblingElement();
     }
 }
+
+void
+Timeline::setRenderer( WorkflowRenderer* renderer )
+{
+    m_renderer = renderer;
+}
diff --git a/src/Gui/timeline/Timeline.h b/src/Gui/timeline/Timeline.h
index 9931fb0..53c3988 100644
--- a/src/Gui/timeline/Timeline.h
+++ b/src/Gui/timeline/Timeline.h
@@ -46,7 +46,7 @@ class Timeline : public QWidget
     Q_OBJECT
     Q_DISABLE_COPY( Timeline )
 public:
-    explicit Timeline( WorkflowRenderer* renderer, QWidget *parent = 0 );
+    explicit Timeline( QWidget *parent = 0 );
     virtual ~Timeline();
     /// Return a pointer to the TracksView instance.
     TracksView*         tracksView() { return m_tracksView; }
@@ -62,6 +62,7 @@ public:
 
     void                save( QXmlStreamWriter& project ) const;
     void                load( const QDomElement &root );
+    void                setRenderer( WorkflowRenderer* renderer );
 
 public slots:
     /**
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index 8730ac3..e563c74 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -27,6 +27,7 @@
 #include <QUndoStack>
 
 #include "AutomaticBackup.h"
+#include "Backend/IBackend.h"
 #include "Library/Library.h"
 #include "Project.h"
 #include "ProjectCallbacks.h"
@@ -56,7 +57,7 @@ Project::Project()
     m_workflow = new MainWorkflow();
     m_workspace = new Workspace( m_settings );
     m_library = new Library( m_workspace );
-
+    m_workflowRenderer = new WorkflowRenderer( Backend::getBackend(), m_workflow );
     connectComponents();
 }
 
@@ -82,6 +83,12 @@ Project::workflow()
     return m_workflow;
 }
 
+WorkflowRenderer*
+Project::workflowRenderer()
+{
+    return m_workflowRenderer;
+}
+
 QUndoStack*
 Project::undoStack()
 {
diff --git a/src/Project/Project.h b/src/Project/Project.h
index 3f20492..1570a62 100644
--- a/src/Project/Project.h
+++ b/src/Project/Project.h
@@ -42,6 +42,7 @@ class MainWorkflow;
 class ProjectManager;
 class Settings;
 class Workspace;
+class WorkflowRenderer;
 
 class Project : public QObject, public Singleton<Project>
 {
@@ -141,9 +142,10 @@ class Project : public QObject, public Singleton<Project>
     // Dependent components part below:
     public:
         Library*            library();
-        MainWorkflow*       workflow();
         QUndoStack*         undoStack();
         Settings*           settings();
+        MainWorkflow*       workflow();
+        WorkflowRenderer*   workflowRenderer();
         Workspace*          workspace();
 
     private:
@@ -152,6 +154,7 @@ class Project : public QObject, public Singleton<Project>
         QUndoStack*         m_undoStack;
         Settings*           m_settings;
         Workspace*          m_workspace;
+        WorkflowRenderer*   m_workflowRenderer;
 
     friend class Singleton<Project>;
 };
diff --git a/src/Renderer/WorkflowFileRenderer.cpp b/src/Renderer/WorkflowFileRenderer.cpp
index 1fa95b9..91855c3 100644
--- a/src/Renderer/WorkflowFileRenderer.cpp
+++ b/src/Renderer/WorkflowFileRenderer.cpp
@@ -28,9 +28,9 @@
 
 #include <QTime>
 
-WorkflowFileRenderer::WorkflowFileRenderer( Backend::IBackend* backend )
-    : WorkflowRenderer( backend )
-    ,   m_renderVideoFrame( NULL )
+WorkflowFileRenderer::WorkflowFileRenderer( Backend::IBackend* backend, MainWorkflow* workflow )
+    : WorkflowRenderer( backend, workflow )
+    , m_renderVideoFrame( NULL )
 {
 }
 
diff --git a/src/Renderer/WorkflowFileRenderer.h b/src/Renderer/WorkflowFileRenderer.h
index 105e57c..80b5fc7 100644
--- a/src/Renderer/WorkflowFileRenderer.h
+++ b/src/Renderer/WorkflowFileRenderer.h
@@ -35,7 +35,7 @@ class   WorkflowFileRenderer : public WorkflowRenderer
     Q_OBJECT
 
 public:
-    WorkflowFileRenderer( Backend::IBackend* backend );
+    WorkflowFileRenderer( Backend::IBackend* backend , MainWorkflow* workflow );
     virtual ~WorkflowFileRenderer();
 
     void                        run(const QString& outputFileName, quint32 width,
diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index c24a521..4cf3cf1 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -45,8 +45,8 @@
 #include "Tools/VlmcDebug.h"
 #include "Workflow/Types.h"
 
-WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend ) :
-            m_mainWorkflow( Project::getInstance()->workflow() ),
+WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend, MainWorkflow* mainWorkflow ) :
+            m_mainWorkflow( mainWorkflow ),
             m_stopping( false ),
             m_outputFps( 0.0f ),
             m_aspectRatio( "" ),
@@ -56,11 +56,6 @@ WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend ) :
             m_effectFrame( NULL )
 {
     m_source = backend->createMemorySource();
-}
-
-void
-WorkflowRenderer::initializeRenderer()
-{
     m_esHandler = new EsHandler;
     m_esHandler->self = this;
 
diff --git a/src/Renderer/WorkflowRenderer.h b/src/Renderer/WorkflowRenderer.h
index d7d779d..20debe9 100644
--- a/src/Renderer/WorkflowRenderer.h
+++ b/src/Renderer/WorkflowRenderer.h
@@ -58,16 +58,10 @@ class   WorkflowRenderer : public GenericRenderer
             double              fps; ///< The fps to use for this rendering session.
         };
 
-        WorkflowRenderer( Backend::IBackend *backend );
+        WorkflowRenderer( Backend::IBackend *backend, MainWorkflow* workflow );
         ~WorkflowRenderer();
 
         /**
-         *  \brief      Initialize the renderer.
-         *
-         *  This will set the imem string, instantiate EsHandlers, connect signals.
-         */
-        void                initializeRenderer();
-        /**
          *  \brief          Play or pause the media.
          *
          *  When this method is called :



More information about the Vlmc-devel mailing list