From 26c1e6482f8f2396575e798daa7495d804080d55 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Fri, 3 Sep 2010 22:41:50 +0000 Subject: [PATCH] small fixes for scopes updates svn path=/trunk/kdenlive/; revision=4830 --- src/abstractscopewidget.cpp | 13 +++++++++---- src/abstractscopewidget.h | 11 +++++++---- src/histogram.cpp | 2 +- src/histogram.h | 2 +- src/mainwindow.cpp | 24 +++++++++++++++++------- src/mainwindow.h | 3 +++ src/monitormanager.cpp | 1 + src/monitormanager.h | 2 ++ src/rgbparade.cpp | 4 +++- src/rgbparade.h | 2 +- src/vectorscope.cpp | 2 +- src/vectorscope.h | 2 +- src/waveform.cpp | 2 +- src/waveform.h | 2 +- 14 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/abstractscopewidget.cpp b/src/abstractscopewidget.cpp index bbc5761a..81daa472 100644 --- a/src/abstractscopewidget.cpp +++ b/src/abstractscopewidget.cpp @@ -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(); diff --git a/src/abstractscopewidget.h b/src/abstractscopewidget.h index 2d38c30e..c7f7ac00 100644 --- a/src/abstractscopewidget.h +++ b/src/abstractscopewidget.h @@ -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 m_threadScope; QFuture 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 diff --git a/src/histogram.cpp b/src/histogram.cpp index fe24ee6b..a5d1fc42 100644 --- a/src/histogram.cpp +++ b/src/histogram.cpp @@ -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(); diff --git a/src/histogram.h b/src/histogram.h index 6272e5b2..af066a53 100644 --- a/src/histogram.h +++ b/src/histogram.h @@ -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; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7deb3717..5de3702c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true; + static_cast(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" diff --git a/src/mainwindow.h b/src/mainwindow.h index 4aa19a94..a6a4fd0a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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); diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index 2dccaa4e..b482a92f 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -62,6 +62,7 @@ void MonitorManager::activateMonitor(QString name) emit raiseClipMonitor(false); } m_activeMonitor = name; + emit checkColorScopes(); } void MonitorManager::slotSwitchMonitors(bool activateClip) diff --git a/src/monitormanager.h b/src/monitormanager.h index 51b83a73..31bd5093 100644 --- a/src/monitormanager.h +++ b/src/monitormanager.h @@ -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(); }; diff --git a/src/rgbparade.cpp b/src/rgbparade.cpp index 3b33a026..40762aa7 100644 --- a/src/rgbparade.cpp +++ b/src/rgbparade.cpp @@ -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; } diff --git a/src/rgbparade.h b/src/rgbparade.h index a568e8ea..1757f707 100644 --- a/src/rgbparade.h +++ b/src/rgbparade.h @@ -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); }; diff --git a/src/vectorscope.cpp b/src/vectorscope.cpp index 6f45d63a..6660105e 100644 --- a/src/vectorscope.cpp +++ b/src/vectorscope.cpp @@ -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; diff --git a/src/vectorscope.h b/src/vectorscope.h index fe0de491..94995ad3 100644 --- a/src/vectorscope.h +++ b/src/vectorscope.h @@ -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; diff --git a/src/waveform.cpp b/src/waveform.cpp index 2b73dd0e..5bd51f19 100644 --- a/src/waveform.cpp +++ b/src/waveform.cpp @@ -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(); diff --git a/src/waveform.h b/src/waveform.h index e70f2f65..5ece240f 100644 --- a/src/waveform.h +++ b/src/waveform.h @@ -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; -- 2.39.2