small fixes for scopes updates

svn path=/trunk/kdenlive/; revision=4830
parent bfd0bcb6
......@@ -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();
......
......@@ -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
......
......@@ -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();
......
......@@ -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;
......
......@@ -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"
......@@ -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);
......
......@@ -62,6 +62,7 @@ void MonitorManager::activateMonitor(QString name)
emit raiseClipMonitor(false);
}
m_activeMonitor = name;
emit checkColorScopes();
}
void MonitorManager::slotSwitchMonitors(bool activateClip)
......
......@@ -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();
};
......
......@@ -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; }
......
......@@ -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);
};
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment