m_semaphoreHUD(1),
m_semaphoreScope(1),
m_semaphoreBackground(1),
- initialDimensionUpdateDone(false)
+ initialDimensionUpdateDone(false),
+ m_requestForcedUpdate(false)
{
m_scopePalette = QPalette();
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
// 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;
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();
/** @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;
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
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();
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;
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()));
/** 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)
}
}
+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"
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);
emit raiseClipMonitor(false);
}
m_activeMonitor = name;
+ emit checkColorScopes();
}
void MonitorManager::slotSwitchMonitors(bool activateClip)
signals:
/** @brief Emitted when the active monitor changes */
void raiseClipMonitor(bool);
+ /** @brief When the monitor changed, update the visible color scopes */
+ void checkColorScopes();
};
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();
emit signalScopeRenderingFinished(start.elapsed(), accelerationFactor);
return parade;
}
+
QImage RGBParade::renderBackground(uint) { return QImage(); }
bool RGBParade::isHUDDependingOnInput() const { return false; }
bool isBackgroundDependingOnInput() const;
QImage renderHUD(uint accelerationFactor);
- QImage renderScope(uint accelerationFactor, QImage);
+ QImage renderScope(uint accelerationFactor, const QImage);
QImage renderBackground(uint accelerationFactor);
};
return hud;
}
-QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage)
+QImage Vectorscope::renderScope(uint accelerationFactor, const QImage qimage)
{
QTime start = QTime::currentTime();
QImage scope;
///// 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;
return hud;
}
-QImage Waveform::renderScope(uint accelFactor, QImage qimage)
+QImage Waveform::renderScope(uint accelFactor, const QImage qimage)
{
QTime start = QTime::currentTime();
start.start();
/// 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;