Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Simplify monitor handling of audio clip, minor optimization of monitor bg drawing

parent 2ef7091e
......@@ -978,6 +978,7 @@ void KdenliveSettingsDialog::updateSettings()
if (m_configSdl.kcfg_window_background->color() != KdenliveSettings::window_background()) {
KdenliveSettings::setWindow_background(m_configSdl.kcfg_window_background->color());
emit updateMonitorBg();
resetProfile = true;
}
......
......@@ -139,6 +139,8 @@ signals:
void audioThumbFormatChanged();
/** @brief An important timeline property changed, prepare for a reset */
void resetView();
/** @brief Monitor background color changed, update monitors */
void updateMonitorBg();
};
#endif
......@@ -2130,6 +2130,9 @@ void MainWindow::slotPreferences(int page, int option)
connect(dialog, &KdenliveSettingsDialog::updateLibraryFolder, pCore.get(), &Core::updateLibraryPath);
connect(dialog, &KdenliveSettingsDialog::audioThumbFormatChanged, m_timelineTabs, &TimelineTabs::audioThumbFormatChanged);
connect(dialog, &KdenliveSettingsDialog::resetView, this, &MainWindow::resetTimelineTracks);
connect(dialog, &KdenliveSettingsDialog::updateMonitorBg, [&]() {
pCore->monitorManager()->updateBgColor();
});
dialog->show();
if (page != -1) {
......
......@@ -74,6 +74,7 @@ GLWidget::GLWidget(int id, QObject *parent)
, m_producer(nullptr)
, m_id(id)
, m_rulerHeight(QFontMetrics(QApplication::font()).lineSpacing() * 0.7)
, m_bgColor(KdenliveSettings::window_background())
, m_shader(nullptr)
, m_initSem(0)
, m_analyseSem(1)
......@@ -520,8 +521,7 @@ void GLWidget::paintGL()
f->glDepthMask(GL_FALSE);
f->glViewport(0, (m_rulerHeight * devicePixelRatio() * 0.5 + 0.5), width, height);
check_error(f);
QColor color(KdenliveSettings::window_background());
f->glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
f->glClearColor(m_bgColor.redF(), m_bgColor.greenF(), m_bgColor.blueF(), 0);
f->glClear(GL_COLOR_BUFFER_BIT);
check_error(f);
......@@ -1183,11 +1183,7 @@ int GLWidget::reconfigure(bool reload)
delete m_displayEvent;
// C & D
if (m_proxy->property("clipType").toInt() == ClipType::Audio) {
m_displayEvent = m_consumer->listen("consumer-frame-show", this, (mlt_listener)on_audio_frame_show);
m_sharedFrame = SharedFrame();
m_texture[0] = 0;
} else if (m_glslManager) {
if (m_glslManager) {
m_displayEvent = m_consumer->listen("consumer-frame-show", this, (mlt_listener)on_gl_frame_show);
} else {
// A & B
......@@ -1418,24 +1414,9 @@ void GLWidget::updateTexture(GLuint yName, GLuint uName, GLuint vName)
// update();
}
// MLT consumer-frame-show event handler
void GLWidget::on_audio_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr)
{
Mlt::Frame frame(frame_ptr);
//qDebug()<<"== SHOWING FRAME: "<<frame.get_position();
if (frame.get_int("rendered") != 0) {
auto *widget = static_cast<GLWidget *>(self);
int timeout = (widget->consumer()->get_int("real_time") > 0) ? 0 : 1000;
if ((widget->m_frameRenderer != nullptr) && widget->m_frameRenderer->semaphore()->tryAcquire(1, timeout)) {
QMetaObject::invokeMethod(widget->m_frameRenderer, "showAudioFrame", Qt::QueuedConnection, Q_ARG(Mlt::Frame, frame));
}
}
}
void GLWidget::on_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr)
{
Mlt::Frame frame(frame_ptr);
//qDebug()<<"== SHOWING FRAME: "<<frame.get_position();
if (frame.get_int("rendered") != 0) {
auto *widget = static_cast<GLWidget *>(self);
int timeout = (widget->consumer()->get_int("real_time") > 0) ? 0 : 1000;
......@@ -1538,14 +1519,6 @@ FrameRenderer::~FrameRenderer()
delete m_gl32;
}
void FrameRenderer::showAudioFrame(Mlt::Frame frame)
{
// Save this frame for future use and to keep a reference to the GL Texture.
m_displayFrame = SharedFrame(frame);
emit frameDisplayed(m_displayFrame);
m_semaphore.release();
}
void FrameRenderer::showFrame(Mlt::Frame frame)
{
int width = 0;
......
......@@ -196,6 +196,7 @@ protected:
std::shared_ptr<Mlt::Producer> m_producer;
int m_id;
int m_rulerHeight;
QColor m_bgColor;
private:
QRect m_rect;
......@@ -232,7 +233,6 @@ private:
MonitorProxy *m_proxy;
std::shared_ptr<Mlt::Producer> m_blackClip;
static void on_frame_show(mlt_consumer, void *self, mlt_frame frame);
static void on_audio_frame_show(mlt_consumer, void *self, mlt_frame frame);
static void on_frame_render(mlt_consumer, GLWidget *widget, mlt_frame frame);
static void on_gl_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr);
static void on_gl_nosync_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr);
......@@ -311,7 +311,6 @@ public:
QSemaphore *semaphore() { return &m_semaphore; }
QOpenGLContext *context() const { return m_context; }
Q_INVOKABLE void showFrame(Mlt::Frame frame);
Q_INVOKABLE void showAudioFrame(Mlt::Frame frame);
Q_INVOKABLE void showGLFrame(Mlt::Frame frame);
Q_INVOKABLE void showGLNoSyncFrame(Mlt::Frame frame);
......
......@@ -2106,3 +2106,8 @@ void Monitor::purgeCache()
{
m_glMonitor->purgeCache();
}
void Monitor::updateBgColor()
{
m_glMonitor->m_bgColor = KdenliveSettings::window_background();
}
......@@ -169,6 +169,7 @@ protected:
void wheelEvent(QWheelEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
virtual QStringList mimeTypes() const;
void updateBgColor();
private:
std::shared_ptr<ProjectClip> m_controller;
......
......@@ -615,3 +615,13 @@ bool MonitorManager::isMultiTrack() const
}
return false;
}
void MonitorManager::updateBgColor()
{
if (m_projectMonitor) {
m_projectMonitor->updateBgColor();
}
if (m_clipMonitor) {
m_clipMonitor->updateBgColor();
}
}
......@@ -108,6 +108,8 @@ public slots:
void slotExtractCurrentFrame();
/** @brief Export the current monitor's frame to image file and add it to the current project */
void slotExtractCurrentFrameToProject();
/** @brief Refresh monitor background color */
void updateBgColor();
private slots:
/** @brief Set MLT's consumer deinterlace method */
......
......@@ -130,27 +130,28 @@ Item {
Item {
id: audioThumb
property bool stateVisible: (clipMonitorRuler.containsMouse || thumbMouseArea.containsMouse)
property bool isAudioClip: controller.clipType == ProducerType.Audio
anchors {
left: parent.left
bottom: parent.bottom
}
height: controller.clipType == ProducerType.Audio ? parent.height : parent.height / 6
height: isAudioClip ? parent.height : parent.height / 6
//font.pixelSize * 3
width: parent.width
visible: root.showAudiothumb && (controller.clipType == ProducerType.Audio || controller.clipType == ProducerType.AV)
visible: root.showAudiothumb && (isAudioClip || controller.clipType == ProducerType.AV)
states: [
State { when: audioThumb.stateVisible || controller.clipType == ProducerType.Audio;
State { when: audioThumb.stateVisible || isAudioClip;
PropertyChanges { target: audioThumb; opacity: 1.0 } },
State { when: !audioThumb.stateVisible && controller.clipType != ProducerType.Audio;
State { when: !audioThumb.stateVisible && isAudioClip;
PropertyChanges { target: audioThumb; opacity: 0.0 } }
]
transitions: [ Transition {
NumberAnimation { property: "opacity"; duration: 500}
NumberAnimation { property: "opacity"; duration: isAudioClip ? 0 : 500}
} ]
Rectangle {
color: activePalette.base
opacity: 0.6
opacity: isAudioClip ? 1 : 0.6
anchors.fill: parent
}
Rectangle {
......
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