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

Move away from render (temporarily move everything in glwidget)

parent cb4b3f6c
......@@ -34,6 +34,7 @@ Item {
property int consumerPosition: -1
property double frameSize: 10
property double timeScale: 1
property int rulerHeight: 20
onZoomChanged: {
sceneToolBar.setZoom(root.zoom)
}
......@@ -184,7 +185,7 @@ Item {
// Monitor ruler
Rectangle {
id: ruler
height: 20
height: root.rulerHeight
anchors {
left: parent.left
right: parent.right
......
......@@ -1400,7 +1400,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone)
m_monitor->slotSeek(frame);
}
if (!zone.isNull()) {
m_monitor->slotZoneMoved(zone.x(), zone.y());
m_monitor->slotLoadClipZone(zone.x(), zone.y());
}
return;
}
......@@ -1420,7 +1420,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone)
m_monitor->slotSeek(frame);
}
if (!zone.isNull()) {
m_monitor->slotZoneMoved(zone.x(), zone.y());
m_monitor->slotLoadClipZone(zone.x(), zone.y());
}
}
}
......
......@@ -120,7 +120,8 @@ void DvdWizardChapters::updateMonitorMarkers()
for (const QString &frame : chapters) {
markers << CommentedTime(GenTime(frame.toInt(), m_tc.fps()), QString());
}
m_monitor->setMarkers(markers);
//TODO: reimplement makers as model
//m_monitor->setMarkers(markers);
}
void DvdWizardChapters::slotRemoveChapter()
......
......@@ -2085,7 +2085,7 @@ void MainWindow::connectDocument()
void MainWindow::slotZoneMoved(int start, int end)
{
pCore->projectManager()->current()->setZone(start, end);
m_projectMonitor->slotZoneMoved(start, end);
m_projectMonitor->slotLoadClipZone(start, end);
}
void MainWindow::slotGuidesUpdated()
......@@ -2532,7 +2532,7 @@ void MainWindow::slotInsertClipInsert()
QPoint binZone = m_clipMonitor->getZoneInfo();
int pos = pCore->projectManager()->currentTimeline()->projectView()->insertZone(TimelineMode::InsertEdit, m_clipMonitor->activeClipId(), binZone);
if (pos > 0) {
m_projectMonitor->silentSeek(pos);
m_projectMonitor->requestSeek(pos);
}
}
}
......
......@@ -25,6 +25,8 @@
#include <QPainter>
#include <QQmlContext>
#include <QQuickItem>
#include <KMessageBox>
#include <klocalizedstring.h>
#include "core.h"
#include "glwidget.h"
......@@ -94,6 +96,8 @@ GLWidget::GLWidget(int id, QObject *parent)
, m_zoom(1.0f)
, m_openGLSync(false)
, m_sendFrame(false)
, m_isZoneMode(false)
, m_isLoopMode(false)
, m_offset(QPoint(0, 0))
, m_shareContext(nullptr)
, m_audioWaveDisplayed(false)
......@@ -641,11 +645,11 @@ bool GLWidget::checkFrameNumber(int pos)
} else {
if (m_producer->get_speed() == 0) {
m_consumer->purge();
} /*else if (m_isZoneMode) {
} else if (m_isZoneMode) {
if (pos >= m_producer->get_int("out") - 1) {
if (m_isLoopMode) {
m_consumer->purge();
m_producer->seek((int)(m_loopStart.frames(m_fps)));
m_producer->seek(m_proxy->zoneIn());
m_producer->set_speed(1.0);
m_consumer->set("refresh", 1);
} else {
......@@ -654,7 +658,7 @@ bool GLWidget::checkFrameNumber(int pos)
}
}
}
}*/
}
}
return true;
}
......@@ -834,6 +838,7 @@ int GLWidget::setProducer(Mlt::Producer *producer)
{
int error = 0; // Controller::setProducer(producer, isMulti);
m_producer = producer;
m_producer->set_speed(0);
if (m_producer) {
error = reconfigure();
if (error == 0) {
......@@ -1051,6 +1056,7 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
QString serviceName = property("mlt_service").toString();
if (profile) {
reloadProfile(*profile);
m_blackClip.reset(new Mlt::Producer(*profile, "color:black"));
}
if ((m_consumer == nullptr) || !m_consumer->is_valid() || strcmp(m_consumer->get("mlt_service"), "multi") == 0) {
if (m_consumer) {
......@@ -1628,13 +1634,14 @@ void GLWidget::refreshSceneLayout()
void GLWidget::switchPlay(bool play, double speed)
{
// QMutexLocker locker(&m_mutex);
qDebug()<<"* * * *SWITCH PLAY: "<<play<<" = "<<speed;
m_proxy->setSeekPosition(SEEK_INACTIVE);
if ((m_producer == nullptr) || (m_consumer == nullptr)) {
return;
}
/*if (m_isZoneMode) {
if (m_isZoneMode) {
resetZoneMode();
}*/
}
if (play) {
double currentSpeed = m_producer->get_speed();
/*if (m_name == Kdenlive::ClipMonitor && m_consumer->position() == m_producer->get_out()) {
......@@ -1656,7 +1663,7 @@ void GLWidget::switchPlay(bool play, double speed)
m_consumer->purge();
}
m_producer->set_speed(speed);
} else {
} else if (m_producer->get_speed() != 0.) {
m_consumer->set("refresh", 0);
m_consumer->purge();
m_producer->set_speed(0.0);
......@@ -1667,6 +1674,56 @@ void GLWidget::switchPlay(bool play, double speed)
}
}
bool GLWidget::playZone(bool loop)
{
if (!m_producer) {
return false;
}
m_proxy->setSeekPosition(SEEK_INACTIVE);
m_producer->seek(m_proxy->zoneIn());
m_producer->set_speed(0);
m_consumer->purge();
m_producer->set("out", m_proxy->zoneOut());
m_producer->set_speed(1.0);
if (m_consumer->is_stopped()) {
m_consumer->start();
}
m_consumer->set("refresh", 1);
m_isZoneMode = true;
m_isLoopMode = loop;
return true;
}
bool GLWidget::loopClip()
{
if (!m_producer) {
return false;
}
m_proxy->setSeekPosition(SEEK_INACTIVE);
m_producer->seek(0);
m_producer->set_speed(0);
m_consumer->purge();
m_producer->set("out", m_producer->get_playtime());
m_producer->set_speed(1.0);
if (m_consumer->is_stopped()) {
m_consumer->start();
}
m_consumer->set("refresh", 1);
m_isZoneMode = true;
m_isLoopMode = true;
return true;
}
void GLWidget::resetZoneMode()
{
if (!m_isZoneMode && !m_isLoopMode) {
return;
}
m_producer->set("out", m_producer->get_length());
m_isZoneMode = false;
m_isLoopMode = false;
}
MonitorProxy *GLWidget::getControllerProxy()
{
return m_proxy;
......@@ -1682,3 +1739,97 @@ void GLWidget::setRulerInfo(int duration, int in, int out, std::shared_ptr<Marke
rootObject()->setProperty("duration", duration);
rootContext()->setContextProperty("markersModel", model.get());
}
bool GLWidget::setProducer(Mlt::Producer *producer, int position, bool isActive)
{
m_refreshTimer.stop();
m_proxy->setSeekPosition(SEEK_INACTIVE);
QMutexLocker locker(&m_mutex);
QString currentId;
int consumerPosition = 0;
if ((producer == nullptr) && (m_producer != nullptr) && m_producer->parent().get("id") == QLatin1String("black")) {
// Black clip already displayed no need to refresh
return true;
}
if (m_producer) {
currentId = m_producer->get("kdenlive:id");
m_producer->set_speed(0);
if (QString(m_producer->get("resource")) == QLatin1String("<tractor>")) {
// We need to make some cleanup
Mlt::Tractor trac(*m_producer);
for (int i = 0; i < trac.count(); i++) {
trac.set_track(*m_blackClip, i);
}
}
delete m_producer;
m_producer = nullptr;
}
if (m_consumer) {
if (!m_consumer->is_stopped()) {
isActive = true;
m_consumer->stop();
}
consumerPosition = m_consumer->position();
}
if ((producer == nullptr) || !producer->is_valid()) {
producer = m_blackClip->cut(0, 1);
}
if (position == -1 && producer->get("kdenlive:id") == currentId) {
position = consumerPosition;
}
if (position != -1) {
producer->seek(position);
}
setProducer(producer);
if (isActive) {
startConsumer();
}
//emit durationChanged(m_producer->get_length() - 1, m_producer->get_in());
position = m_producer->position();
rootObject()->setProperty("consumerPosition", position);
return true;
}
int GLWidget::rulerHeight() const
{
return rootObject()->property("rulerHeight").toInt();
}
void GLWidget::startConsumer()
{
if (m_consumer->is_stopped() && m_consumer->start() == -1) {
// ARGH CONSUMER BROKEN!!!!
KMessageBox::error(
qApp->activeWindow(),
i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
if (m_displayEvent) {
delete m_displayEvent;
}
m_displayEvent = nullptr;
delete m_consumer;
m_consumer = nullptr;
return;
}
m_consumer->set("refresh", 1);
}
void GLWidget::stop()
{
m_refreshTimer.stop();
m_proxy->setSeekPosition(SEEK_INACTIVE);
QMutexLocker locker(&m_mutex);
if (m_producer) {
if (m_isZoneMode) {
resetZoneMode();
}
m_producer->set_speed(0.0);
}
if (m_consumer) {
m_consumer->purge();
if (!m_consumer->is_stopped()) {
m_consumer->stop();
}
}
}
......@@ -109,6 +109,12 @@ public:
void requestRefresh();
void setRulerInfo(int duration, int in, int out, std::shared_ptr<MarkerListModel> model);
MonitorProxy *getControllerProxy();
bool playZone(bool loop = false);
bool loopClip();
bool setProducer(Mlt::Producer *producer, int position, bool isActive);
void startConsumer();
void stop();
int rulerHeight() const;
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
......@@ -182,6 +188,8 @@ private:
float m_zoom;
bool m_openGLSync;
bool m_sendFrame;
bool m_isZoneMode;
bool m_isLoopMode;
SharedFrame m_sharedFrame;
QMutex m_mutex;
QPoint m_offset;
......@@ -189,6 +197,7 @@ private:
QOpenGLContext *m_shareContext;
bool m_audioWaveDisplayed;
MonitorProxy *m_proxy;
QScopedPointer<Mlt::Producer> m_blackClip;
static void on_frame_show(mlt_consumer, void *self, 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);
......@@ -197,6 +206,7 @@ private:
void adjustAudioOverlay(bool isAudio);
QOpenGLFramebufferObject *m_fbo;
void refreshSceneLayout();
void resetZoneMode();
private slots:
void resizeGL(int width, int height);
......@@ -287,6 +297,12 @@ public:
m_seekPosition = pos;
emit seekPositionChanged();
}
void pauseAndSeek(int pos)
{
q->switchPlay(false);
m_seekPosition = pos;
emit seekPositionChanged();
}
int zoneIn() const { return m_zoneIn; }
int zoneOut() const { return m_zoneOut; }
void setZoneIn(int pos)
......
This diff is collapsed.
......@@ -101,8 +101,6 @@ public:
void updateMarkers();
/** @brief Controller for the clip currently displayed (only valid for clip monitor). */
ProjectClip *currentController() const;
/** @brief Add clip markers to the ruler and context menu */
void setMarkers(const QList<CommentedTime> &markers);
/** @brief Add timeline guides to the ruler and context menu */
void setGuides(const QMap<double, QString> &guides);
void reloadProducer(const QString &id);
......@@ -156,8 +154,6 @@ public:
void activateSplit();
/** @brief Clear monitor display **/
void clearDisplay();
/** @brief Seeks timeline without refreshing if monitor is not active **/
void silentSeek(int pos);
void setProducer(Mlt::Producer *producer);
/** @brief Returns current monitor's duration in frames **/
int duration() const;
......@@ -245,14 +241,13 @@ private:
void buildSplitEffect(Mlt::Producer *original, int pos);
private slots:
void seekCursor(int pos);
void rendererStopped(int pos);
Q_DECL_DEPRECATED void seekCursor(int pos);
void slotExtractCurrentFrame(QString frameName = QString(), bool addToProject = false);
void slotExtractCurrentFrameToProject();
void slotSetThumbFrame();
void slotSaveZone();
void slotSeek();
void setClipZone(const QPoint &pos);
void updateClipZone();
void slotGoToMarker(QAction *action);
void slotSetVolume(int volume);
void slotEditMarker();
......@@ -312,7 +307,7 @@ public slots:
void slotSetZoneEnd(bool discardLastFrame = false);
void slotZoneStart();
void slotZoneEnd();
void slotZoneMoved(int start, int end);
void slotLoadClipZone(int start, int end);
void slotSeekToNextSnap();
void slotSeekToPreviousSnap();
void adjustRulerSize(int length, int offset = 0);
......
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