Fix titlewidget displaying blank background with Movit.

Now, on the very first attempt the frame is black, but unselecting and
selecting again the option makes it work..
CCBUG: 350398
parent 23168cfd
......@@ -2437,12 +2437,18 @@ void Bin::deleteAllClipMarkers(const QString &id)
else delete command;
}
void Bin::slotGetCurrentProjectImage()
{
pCore->monitorManager()->projectMonitor()->slotGetCurrentImage();
}
// TODO: move title editing into a better place...
void Bin::showTitleWidget(ProjectClip *clip)
{
QString path = clip->getProducerProperty("resource");
QString titlepath = m_doc->projectFolder().path() + QDir::separator() + "titles/";
QPointer<TitleWidget> dia_ui = new TitleWidget(QUrl(), m_doc->timecode(), titlepath, pCore->monitorManager()->projectMonitor()->render, pCore->window());
connect(dia_ui, SIGNAL(requestBackgroundFrame()), pCore->monitorManager()->projectMonitor(), SLOT(slotGetCurrentImage()));
QDomDocument doc;
doc.setContent(clip->getProducerProperty("xmldata"));
dia_ui->setXml(doc);
......
......@@ -554,6 +554,8 @@ public slots:
void updateTimelineProducers(const QString &id, QMap <QString, QString> passProperties);
/** @brief Add effect to active Bin clip. */
void slotEffectDropped(QDomElement);
/** @brief Request current frame from project monitor. */
void slotGetCurrentProjectImage();
protected:
void contextMenuEvent(QContextMenuEvent *event);
......
......@@ -173,6 +173,7 @@ void ClipCreationDialog::createTitleClip(KdenliveDoc *doc, QStringList groupInfo
dir.mkdir("titles");
dir.cd("titles");
QPointer<TitleWidget> dia_ui = new TitleWidget(QUrl::fromLocalFile(templatePath), doc->timecode(), dir.path(), doc->renderer(), bin);
QObject::connect(dia_ui, SIGNAL(requestBackgroundFrame()), bin, SLOT(slotGetCurrentProjectImage()));
if (dia_ui->exec() == QDialog::Accepted) {
// Ready, create clip xml
QDomDocument xml;
......
......@@ -441,19 +441,24 @@ void GLWidget::paintGL()
glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices.size());
check_error(f);
// Render RGB frame for analysis
if (sendFrameForAnalysis) {
if (!m_fbo || m_fbo->size() != QSize(width, height)) {
// Render RGB frame for analysis
int fullWidth = m_monitorProfile->width();
int fullHeight = m_monitorProfile->height();
if (!m_fbo || m_fbo->size() != QSize(fullWidth, fullHeight)) {
delete m_fbo;
QOpenGLFramebufferObjectFormat f;
f.setSamples(0);
f.setInternalTextureFormat(GL_RGB); //GL_RGBA32F); // which one is the fastest ?
m_fbo = new QOpenGLFramebufferObject(width, height, f); //GL_TEXTURE_2D);
m_fbo = new QOpenGLFramebufferObject(fullWidth, fullHeight, f); //GL_TEXTURE_2D);
}
m_fbo->bind();
glViewport(0, 0, width, height);
projection.scale((double) this->width() / width, (double) this->height() / height);
m_shader->setUniformValue(m_projectionLocation, projection);
glViewport(0, 0, fullWidth, fullHeight);
QMatrix4x4 projection2;
projection2.scale(2.0f / width, 2.0f / height);
m_shader->setUniformValue(m_projectionLocation, projection2);
glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices.size());
check_error(f);
m_fbo->release();
......
......@@ -317,6 +317,15 @@ Monitor::~Monitor()
delete render;
}
void Monitor::slotGetCurrentImage()
{
m_monitorManager->activateMonitor(m_id, true);
m_glMonitor->sendFrameForAnalysis = true;
refreshMonitor();
// Update analysis state
QTimer::singleShot(500, m_monitorManager, SIGNAL(checkScopes()));
}
void Monitor::slotAddEffect(QDomElement effect)
{
if (m_id == Kdenlive::ClipMonitor) {
......@@ -569,7 +578,7 @@ void Monitor::slotSetZoneEnd()
// virtual
void Monitor::mousePressEvent(QMouseEvent * event)
{
if (render) render->setActiveMonitor();
m_monitorManager->activateMonitor(m_id);
if (!(event->button() & Qt::RightButton)) {
if (m_glWidget->geometry().contains(event->pos())) {
m_dragStarted = true;
......
......@@ -260,6 +260,8 @@ public slots:
void slotSwitchFullScreen(bool minimizeOnly = false);
/** @brief Display or hide the record toolbar */
void slotSwitchRec(bool enable);
/** @brief Request QImage of current frame */
void slotGetCurrentImage();
signals:
void renderPosition(int);
......
......@@ -131,6 +131,8 @@ signals:
void checkColorScopes();
/** @brief When the active monitor renderer was deleted, reset color scopes */
void clearScopes();
/** @brief Check if we still need to send frame for scopes */
void checkScopes();
void addEffect(QDomElement);
};
......
......@@ -39,6 +39,7 @@ ScopeManager::ScopeManager(QObject *parent) :
connect(pCore->monitorManager(), SIGNAL(checkColorScopes()), SLOT(slotUpdateActiveRenderer()));
connect(pCore->monitorManager(), SIGNAL(clearScopes()), SLOT(slotClearColorScopes()));
connect(pCore->monitorManager(), SIGNAL(checkScopes()), SLOT(slotCheckActiveScopes()));
connect(m_signalMapper, SIGNAL(mapped(QString)), SLOT(slotRequestFrame(QString)));
slotUpdateActiveRenderer();
......
......@@ -181,6 +181,8 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &pro
connect(origin_x_left, SIGNAL(clicked()), this, SLOT(slotOriginXClicked()));
connect(origin_y_top, SIGNAL(clicked()), this, SLOT(slotOriginYClicked()));
connect(render, SIGNAL(frameUpdated(QImage)), this, SLOT(slotGotBackground(QImage)));
// Position and size
m_signalMapper = new QSignalMapper(this);
......@@ -770,11 +772,16 @@ void TitleWidget::displayBackgroundFrame()
p2.end();
m_frameImage->setPixmap(bg);
} else {
QImage img = m_render->extractFrame((int) m_render->seekPosition().frames(m_render->fps()), QString(), m_render->frameRenderWidth() / 2, m_render->renderHeight() / 2);
m_frameImage->setPixmap(QPixmap::fromImage(img.scaled(r.width() / 2, r.height() / 2)));
emit requestBackgroundFrame();
}
}
void TitleWidget::slotGotBackground(QImage img)
{
QRectF r = m_frameBorder->sceneBoundingRect();
m_frameImage->setPixmap(QPixmap::fromImage(img.scaled(r.width() / 2, r.height() / 2)));
}
void TitleWidget::initAnimation()
{
align_box->setEnabled(false);
......
......@@ -229,6 +229,7 @@ public slots:
void saveTitle(QUrl url = QUrl());
/** Load a title from a title file */
void loadTitle(QUrl url = QUrl());
void slotGotBackground(QImage img);
private slots:
......@@ -345,6 +346,9 @@ private slots:
void slotZIndexBottom();
/** Called when the user wants to apply a different template to the title */
void templateIndexChanged(int);
signals:
void requestBackgroundFrame();
};
#endif
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