]> git.sesse.net Git - kdenlive/commitdiff
Small repaint optimizations
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 7 Sep 2012 16:07:35 +0000 (18:07 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 7 Sep 2012 16:07:35 +0000 (18:07 +0200)
src/customruler.cpp
src/customruler.h
src/customtrackview.cpp
src/customtrackview.h
src/renderer.cpp
src/trackview.cpp

index d1265173ee818a427df8af5057d4df1286bdfa7b..67401a34ca7cf17d79d359638baf15747999830e 100644 (file)
@@ -277,6 +277,11 @@ void CustomRuler::slotCursorMoved(int oldpos, int newpos)
     } else update(qMin(oldpos, newpos) * m_factor - offset() - 6, BIG_MARK_X, qAbs(oldpos - newpos) * m_factor + 14, MAX_HEIGHT - BIG_MARK_X);
 }
 
+void CustomRuler::updateRuler(int min, int max)
+{
+    update(min * m_factor - offset(), 0, max - min, height());
+}
+
 void CustomRuler::setPixelPerMark(int rate)
 {
     int scale = comboScale[rate];
index cc11565b151ef7349fd559318e38a5cc7cf193c9..6659c7a249f9df9aaa3b9c1914493115f27d681c 100644 (file)
@@ -87,6 +87,7 @@ private:
 public slots:
     void slotMoveRuler(int newPos);
     void slotCursorMoved(int oldpos, int newpos);
+    void updateRuler(int min, int max);
 
 private slots:
     void slotEditGuide();
index 5fd95e1d5cd0299805c5b9ea8b4e3eabd57b874a..ef12ad548d3a0a797d2d1a3541e11d21ec68b828 100644 (file)
@@ -3348,8 +3348,22 @@ void CustomTrackView::deleteClip(const QString &clipId)
 
 void CustomTrackView::seekCursorPos(int pos)
 {
+    int current = m_document->renderer()->requestedSeekPosition;
+    int playhead = m_document->renderer()->seekFramePosition();
+    int min;
+    int max;
+    if (current != SEEK_INACTIVE) {
+       min = qMin(pos, playhead);
+       min = qMin (min, current) - 5;
+       max = qMax(pos, playhead);
+       max = qMax(max, current) + 5;
+    }
+    else {
+       min = qMin(pos, playhead) - 5;
+       max = qMax(pos, playhead) + 5;
+    }
     m_document->renderer()->seek(pos);
-    emit updateRuler();
+    emit updateRuler(min, max);
 }
 
 int CustomTrackView::seekPosition() const
@@ -3381,11 +3395,26 @@ int CustomTrackView::cursorPos()
 void CustomTrackView::moveCursorPos(int delta)
 {
     int currentPos = m_document->renderer()->requestedSeekPosition;
-    if (currentPos == SEEK_INACTIVE) currentPos = m_document->renderer()->seekFramePosition();
-    if (currentPos + delta < 0) delta = 0 - currentPos;
-    currentPos += delta;
+    int actualPos = m_document->renderer()->seekPosition().frames(m_document->fps());
+    int min;
+    int max;
+    if (currentPos == SEEK_INACTIVE) {
+       currentPos = actualPos + delta;
+       if (currentPos < 0) currentPos = 0;
+       min = qMin(actualPos, currentPos) - 5;
+       max = qMax(actualPos, currentPos) + 5;
+    }
+    else {
+       min = qMin(currentPos, currentPos + delta);
+       min = qMin (min, actualPos) - 5;
+       max = qMax(currentPos, currentPos + delta);
+       max = qMax(max, actualPos) + 5;
+       currentPos += delta;
+       if (currentPos < 0) currentPos = 0;
+    }
+
     m_document->renderer()->seek(currentPos);
-    emit updateRuler();
+    emit updateRuler(min, max);
 }
 
 void CustomTrackView::initCursorPos(int pos)
index a37f76ee74d3fd378b0f4d0421f231fc341a9aa0..6067ef5c1c29a53530d822c18aa756f3f46db82c 100644 (file)
@@ -516,7 +516,7 @@ signals:
     /** @brief Update the track effect button that shows if a track has effects or not.*/
     void updateTrackEffectState(int);
     /** @brief Cursor position changed, repaint ruler.*/
-    void updateRuler();
+    void updateRuler(int min, int max);
 };
 
 #endif
index c43fa064da8c8cb1442fce07fb1703cce87fd2f0..18ea5555162c75b2bd1d87c34c9a079b881011bd 100644 (file)
@@ -389,6 +389,7 @@ void Render::seek(int time)
     if (requestedSeekPosition == SEEK_INACTIVE) {
        requestedSeekPosition = time;
        m_mltProducer->seek(time);
+       m_mltConsumer->purge();
        if (m_mltProducer->get_speed() == 0) {
            refresh();
        }
index 2f190746288cf70c5f668adc97c54674dc8c7a03..1e1531910f5c9ef2f1158475aa0c81b5bd3ea24a 100644 (file)
@@ -113,7 +113,7 @@ TrackView::TrackView(KdenliveDoc *doc, QList <QAction*> actions, bool *ok, QWidg
     if (m_doc->setSceneList() == -1) *ok = false;
     else *ok = true;
     connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
-    connect(m_trackview, SIGNAL(updateRuler()), m_ruler, SLOT(update()));
+    connect(m_trackview, SIGNAL(updateRuler(int, int)), m_ruler, SLOT(updateRuler(int, int)));
 
     connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
     connect(m_trackview->horizontalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(slotUpdateVerticalScroll(int, int)));