]> git.sesse.net Git - kdenlive/commitdiff
small fixes for scopes updates
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 3 Sep 2010 22:41:50 +0000 (22:41 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 3 Sep 2010 22:41:50 +0000 (22:41 +0000)
svn path=/trunk/kdenlive/; revision=4830

14 files changed:
src/abstractscopewidget.cpp
src/abstractscopewidget.h
src/histogram.cpp
src/histogram.h
src/mainwindow.cpp
src/mainwindow.h
src/monitormanager.cpp
src/monitormanager.h
src/rgbparade.cpp
src/rgbparade.h
src/vectorscope.cpp
src/vectorscope.h
src/waveform.cpp
src/waveform.h

index bbc5761a773e0de1d478db76b5782af8a310b019..81daa472698e989cc93948a9bd3bb86149e1180c 100644 (file)
@@ -44,7 +44,8 @@ AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMoni
         m_semaphoreHUD(1),
         m_semaphoreScope(1),
         m_semaphoreBackground(1),
-        initialDimensionUpdateDone(false)
+        initialDimensionUpdateDone(false),
+        m_requestForcedUpdate(false)
 
 {
     m_scopePalette = QPalette();
@@ -150,8 +151,8 @@ void AbstractScopeWidget::prodHUDThread()
 void AbstractScopeWidget::prodScopeThread()
 {
     // Only start a new thread if the scope is actually visible
-    // and not hidden by another widget on the stack.
-    if (this->visibleRegion().isEmpty()) {
+    // and not hidden by another widget on the stack and if user want the scope to update.
+    if (this->visibleRegion().isEmpty() || (!m_aAutoRefresh->isChecked() && !m_requestForcedUpdate)) {
 //        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope.";
     } else {
         // Try to acquire the semaphore. This must only succeed if m_threadScope is not running
@@ -168,6 +169,7 @@ void AbstractScopeWidget::prodScopeThread()
             // See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about
             // running member functions in a thread
             m_threadScope = QtConcurrent::run(this, &AbstractScopeWidget::renderScope, m_accelFactorScope, m_scopeImage);
+            m_requestForcedUpdate = false;
 
 //            qDebug() << "Scope thread started in " << m_widgetName;
 
@@ -232,7 +234,10 @@ void AbstractScopeWidget::forceUpdateBackground()
 
 void AbstractScopeWidget::mouseReleaseEvent(QMouseEvent *event)
 {
-    if (!m_aAutoRefresh->isChecked()) m_activeRender->sendFrameUpdate();
+    if (!m_aAutoRefresh->isChecked()) {
+        m_requestForcedUpdate = true;
+        m_activeRender->sendFrameUpdate();
+    }
     prodHUDThread();
     prodScopeThread();
     prodBackgroundThread();
index 2d38c30ef3d7bdcd4498cabb29357d8a7066a9c0..c7f7ac008055901084bfd243485469bea2f60deb 100644 (file)
@@ -153,7 +153,7 @@ protected:
     /** @brief Scope renderer. Must emit signalScopeRenderingFinished()
         when calculation has finished, to allow multi-threading.
         accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */
-    virtual QImage renderScope(uint accelerationFactor, QImage) = 0;
+    virtual QImage renderScope(uint accelerationFactor, const QImage) = 0;
     /** @brief Background renderer. Must emit signalBackgroundRenderingFinished(). @see renderScope */
     virtual QImage renderBackground(uint accelerationFactor) = 0;
 
@@ -231,21 +231,24 @@ private:
     QFuture<QImage> m_threadScope;
     QFuture<QImage> m_threadBackground;
 
+    bool initialDimensionUpdateDone;
+    bool m_requestForcedUpdate;
+
     QImage m_scopeImage;
 
     QString m_widgetName;
 
-    bool initialDimensionUpdateDone;
     void prodHUDThread();
     void prodScopeThread();
     void prodBackgroundThread();
 
-
-private slots:
+public slots:
     /** @brief Must be called when the active monitor has shown a new frame.
       This slot must be connected in the implementing class, it is *not*
       done in this abstract class. */
     void slotActiveMonitorChanged(bool isClipMonitor);
+
+private slots:
     void customContextMenuRequested(const QPoint &pos);
     /** To be called when a new frame has been received.
       The scope then decides whether and when it wants to recalculate the scope, depending
index fe24ee6b093bec03bf1a61d7f41d6605ac97d1e5..a5d1fc42af1e6772f01a8df986ca60c3b66dd4d8 100644 (file)
@@ -109,7 +109,7 @@ QImage Histogram::renderHUD(uint)
     emit signalHUDRenderingFinished(0, 1);
     return QImage();
 }
-QImage Histogram::renderScope(uint accelFactor, QImage qimage)
+QImage Histogram::renderScope(uint accelFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     start.start();
index 6272e5b2bf3d728ad01e45df6417fdcf78f079a6..af066a539395811589914c72809cf8c2a8f8af28 100644 (file)
@@ -40,7 +40,7 @@ private:
     bool isScopeDependingOnInput() const;
     bool isBackgroundDependingOnInput() const;
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, QImage);
+    QImage renderScope(uint accelerationFactor, const QImage);
     QImage renderBackground(uint accelerationFactor);
     Ui::Histogram_UI *ui;
 
index 7deb3717a910db1040e91caa250d6d9ab6be00af..5de3702c6cf08bb187a61991739535fb30223ecd 100644 (file)
@@ -446,10 +446,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
     //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
     connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
-    connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_vectorscope, SLOT(slotActiveMonitorChanged(bool)));
-    connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_waveform, SLOT(slotActiveMonitorChanged(bool)));
-    connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_RGBParade, SLOT(slotActiveMonitorChanged(bool)));
-    connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_histogram, SLOT(slotActiveMonitorChanged(bool)));
+    connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
     connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
     connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
 
@@ -3150,9 +3147,8 @@ void MainWindow::keyPressEvent(QKeyEvent *ke)
 /** Gets called when the window gets hidden */
 void MainWindow::hideEvent(QHideEvent */*event*/)
 {
-    if (isMinimized())
-        if (m_monitorManager)
-            m_monitorManager->stopActiveMonitor();
+    if (isMinimized() && m_monitorManager)
+        m_monitorManager->stopActiveMonitor();
 }
 
 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
@@ -3765,5 +3761,19 @@ void MainWindow::slotDoUpdateScopeFrameRequest()
     }
 }
 
+void MainWindow::slotUpdateColorScopes()
+{
+    bool request = false;
+    for (int i = 0; i < m_scopesList.count(); i++) {
+       // Check if we need the renderer to send a new frame for update
+        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
+        static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
+    }
+    if (request) {
+        if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
+        else m_projectMonitor->render->sendFrameUpdate();
+    }
+}
+
 #include "mainwindow.moc"
 
index 4aa19a941b40242bc16dc3da2f9f13a2e8c18ee3..a6a4fd0a3c1df08dac77a5a195fc4d084cf57123 100644 (file)
@@ -470,7 +470,10 @@ private slots:
     void slotMonitorRequestRenderFrame(bool request);
     /** @brief Check if someone needs the render frame sent. */
     void slotUpdateScopeFrameRequest();
+    /** @brief Check if someone needs the render frame sent. */
     void slotDoUpdateScopeFrameRequest();
+    /** @brief When switching between monitors, update the visible scopes. */
+    void slotUpdateColorScopes();
 
 signals:
     Q_SCRIPTABLE void abortRenderJob(const QString &url);
index 2dccaa4edbc9b29f39b65fe0368ac5f00ac6289c..b482a92f5e73b0649b7ff455c4d598c3aec84467 100644 (file)
@@ -62,6 +62,7 @@ void MonitorManager::activateMonitor(QString name)
         emit raiseClipMonitor(false);
     }
     m_activeMonitor = name;
+    emit checkColorScopes();
 }
 
 void MonitorManager::slotSwitchMonitors(bool activateClip)
index 51b83a730580b2916418bfd10f4f49976751df04..31bd5093e9e61eb95cf6cd4c30e24d2c284129b8 100644 (file)
@@ -70,6 +70,8 @@ private:
 signals:
     /** @brief Emitted when the active monitor changes */
     void raiseClipMonitor(bool);
+    /** @brief When the monitor changed, update the visible color scopes */
+    void checkColorScopes();
 
 };
 
index 3b33a026ecd2733af8c8b2d26e9cf499e298f5dd..40762aa7b49294fd07551db32f58c7963aefac82 100644 (file)
@@ -123,7 +123,8 @@ QImage RGBParade::renderHUD(uint)
     emit signalHUDRenderingFinished(1, 1);
     return hud;
 }
-QImage RGBParade::renderScope(uint accelerationFactor, QImage qimage)
+
+QImage RGBParade::renderScope(uint accelerationFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     start.start();
@@ -134,6 +135,7 @@ QImage RGBParade::renderScope(uint accelerationFactor, QImage qimage)
     emit signalScopeRenderingFinished(start.elapsed(), accelerationFactor);
     return parade;
 }
+
 QImage RGBParade::renderBackground(uint) { return QImage(); }
 
 bool RGBParade::isHUDDependingOnInput() const { return false; }
index a568e8eac4990bb303e80bc3306ff64f40a194a2..1757f7074a0cff801054e0af4cf4f9941590c484 100644 (file)
@@ -44,7 +44,7 @@ private:
     bool isBackgroundDependingOnInput() const;
 
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, QImage);
+    QImage renderScope(uint accelerationFactor, const QImage);
     QImage renderBackground(uint accelerationFactor);
 };
 
index 6f45d63a46283be12e07ee0806078000e509fec0..6660105e186f021416b37bca921e60f84725dc78 100644 (file)
@@ -215,7 +215,7 @@ QImage Vectorscope::renderHUD(uint)
     return hud;
 }
 
-QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage)
+QImage Vectorscope::renderScope(uint accelerationFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     QImage scope;
index fe0de491b5cb72fbee0ae6aa42854d4109615298..94995ad3fc2f16fd54f29a2d1a6b5f1baa0fdb2e 100644 (file)
@@ -37,7 +37,7 @@ protected:
     ///// Implemented methods /////
     QRect scopeRect();
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, QImage);
+    QImage renderScope(uint accelerationFactor, const QImage);
     QImage renderBackground(uint accelerationFactor);
     bool isHUDDependingOnInput() const;
     bool isScopeDependingOnInput() const;
index 2b73dd0e57235e05f5a1d7b1006c105547f8838c..5bd51f19d2d75f891a5944dd3cb0b99571d38173 100644 (file)
@@ -169,7 +169,7 @@ QImage Waveform::renderHUD(uint)
     return hud;
 }
 
-QImage Waveform::renderScope(uint accelFactor, QImage qimage)
+QImage Waveform::renderScope(uint accelFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     start.start();
index e70f2f6563cfc1006e0f95622fecd5269e174450..5ece240f3995ca4ccc7d13f60ed19fc058262b0b 100644 (file)
@@ -47,7 +47,7 @@ private:
     /// Implemented methods ///
     QRect scopeRect();
     QImage renderHUD(uint);
-    QImage renderScope(uint, QImage);
+    QImage renderScope(uint, const QImage);
     QImage renderBackground(uint);
     bool isHUDDependingOnInput() const;
     bool isScopeDependingOnInput() const;