fix viewer playback

This commit is contained in:
shun-iwasawa 2022-02-21 14:47:45 +09:00 committed by manongjohn
parent 355c47c05d
commit 727c2a1185
5 changed files with 14 additions and 33 deletions

View file

@ -311,10 +311,9 @@ void ComboViewerPanel::onShowHideActionTriggered(QAction *act) {
void ComboViewerPanel::onDrawFrame(int frame,
const ImagePainter::VisualSettings &settings,
QElapsedTimer *timer, qint64 targetInstant) {
QElapsedTimer *, qint64) {
TApp *app = TApp::instance();
m_sceneViewer->setVisual(settings);
m_sceneViewer->setTimerAndTargetInstant(timer, targetInstant);
TFrameHandle *frameHandle = app->getCurrentFrame();
@ -350,10 +349,6 @@ void ComboViewerPanel::onDrawFrame(int frame,
else if (settings.m_blankColor != TPixel::Transparent)
m_sceneViewer->update();
// make sure to redraw the frame here.
// repaint() does NOT immediately redraw the frame for QOpenGLWidget
if (frameHandle->isPlaying()) qApp->processEvents();
}
//-----------------------------------------------------------------------------

View file

@ -800,8 +800,7 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
, m_mousePanning(0)
, m_mouseZooming(0)
, m_mouseRotating(0)
, m_keyAction(0)
, m_timer(nullptr) {
, m_keyAction(0) {
m_visualSettings.m_sceneProperties =
TApp::instance()->getCurrentScene()->getScene()->getProperties();
m_stopMotion = StopMotion::instance();
@ -2053,14 +2052,6 @@ void SceneViewer::paintGL() {
if (!m_isPicking && m_lutCalibrator && m_lutCalibrator->isValid())
m_lutCalibrator->onEndDraw(m_fbo);
// wait to achieve precise fps
if (m_timer && m_timer->isValid()) {
qint64 currentInstant = m_timer->nsecsElapsed();
while (currentInstant < m_targetInstant) {
currentInstant = m_timer->nsecsElapsed();
}
}
}
//-----------------------------------------------------------------------------

View file

@ -219,10 +219,6 @@ class SceneViewer final : public GLWidgetForHighDpi,
QAction *m_keyAction;
// passed from PlaybackExecutor
QElapsedTimer *m_timer;
qint64 m_targetInstant;
public:
enum ReferenceMode {
NORMAL_REFERENCE = 1,
@ -331,11 +327,6 @@ public:
void setPreviewBGColor(const QColor &color) { m_previewBgColor = color; }
QColor getPreviewBGColor() const { return m_previewBgColor; }
void setTimerAndTargetInstant(QElapsedTimer *timer, qint64 target) {
m_timer = timer;
m_targetInstant = target;
}
public:
// SceneViewer's gadget public functions
TPointD winToWorld(const QPointF &pos) const;

View file

@ -276,10 +276,9 @@ void SceneViewerPanel::onShowHideActionTriggered(QAction *act) {
void SceneViewerPanel::onDrawFrame(int frame,
const ImagePainter::VisualSettings &settings,
QElapsedTimer *timer, qint64 targetInstant) {
QElapsedTimer *, qint64) {
TApp *app = TApp::instance();
m_sceneViewer->setVisual(settings);
m_sceneViewer->setTimerAndTargetInstant(timer, targetInstant);
TFrameHandle *frameHandle = app->getCurrentFrame();
@ -314,10 +313,6 @@ void SceneViewerPanel::onDrawFrame(int frame,
else if (settings.m_blankColor != TPixel::Transparent)
m_sceneViewer->update();
// make sure to redraw the frame here.
// repaint() does NOT immediately redraw the frame for QOpenGLWidget
if (frameHandle->isPlaying()) qApp->processEvents();
}
//-----------------------------------------------------------------------------

View file

@ -220,10 +220,19 @@ void PlaybackExecutor::run() {
shortTermDelayAdjuster -= delayAdjust;
// Show the next frame, telling currently measured fps
// The wait time will be inserted at the end of paintGL in order to
// achieve precise playback
// For the Flipbook, the wait time will be inserted at the end of paintGL
// in order to achieve precise playback
emit nextFrame(fps, &m_timer, targetInstant);
// Playing on Viewer / Combo Viewer will advance the current frame.
// Calling qApp->processEvents() on drawing frame causes repaint of other
// panels which slows playback. Therefore in Viewer / Combo Viewer panels
// it just calls update() and necessary wait will be inserted here.
qint64 currentInstant = m_timer.nsecsElapsed();
while (currentInstant < targetInstant) {
currentInstant = m_timer.nsecsElapsed();
}
if (FlipConsole::m_areLinked) {
// In case there are linked consoles, update them too.
// Their load time must be included in the fps calculation.