preload next frame before ticking over
This commit is contained in:
parent
579456fbd7
commit
ce94cd2d1e
@ -7,6 +7,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
|
|
||||||
class AOApplication;
|
class AOApplication;
|
||||||
class VPath;
|
class VPath;
|
||||||
@ -139,6 +140,9 @@ protected:
|
|||||||
// Center the QLabel in the viewport based on the dimensions of f_pixmap
|
// Center the QLabel in the viewport based on the dimensions of f_pixmap
|
||||||
void center_pixmap(QPixmap f_pixmap);
|
void center_pixmap(QPixmap f_pixmap);
|
||||||
|
|
||||||
|
// Populate the frame and delay vectors. Done asynchronously.
|
||||||
|
void load_next_frame();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void done();
|
void done();
|
||||||
|
|
||||||
|
@ -532,7 +532,11 @@ void CharLayer::movie_ticker()
|
|||||||
void AOLayer::movie_ticker()
|
void AOLayer::movie_ticker()
|
||||||
{
|
{
|
||||||
++frame;
|
++frame;
|
||||||
if (frame >= max_frames) {
|
QFuture<void> future;
|
||||||
|
if (frame >= movie_frames.size() && frame < max_frames) { // need to load the image
|
||||||
|
future = QtConcurrent::run(this, &AOLayer::load_next_frame);
|
||||||
|
}
|
||||||
|
else if (frame >= max_frames) {
|
||||||
if (play_once) {
|
if (play_once) {
|
||||||
if (cull_image)
|
if (cull_image)
|
||||||
this->stop();
|
this->stop();
|
||||||
@ -544,19 +548,21 @@ void AOLayer::movie_ticker()
|
|||||||
else
|
else
|
||||||
frame = 0;
|
frame = 0;
|
||||||
}
|
}
|
||||||
// qint64 difference = elapsed - movie_delays[frame];
|
|
||||||
if (frame >= movie_frames.size()) {
|
|
||||||
movie_frames.append(this->get_pixmap(m_reader.read()));
|
|
||||||
movie_delays.append(m_reader.nextImageDelay());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_MOVIE
|
#ifdef DEBUG_MOVIE
|
||||||
qDebug() << frame << movie_delays[frame]
|
qDebug() << frame << movie_delays[frame]
|
||||||
<< "actual time taken from last frame:" << actual_time.restart();
|
<< "actual time taken from last frame:" << actual_time.restart();
|
||||||
#endif
|
#endif
|
||||||
|
future.waitForFinished(); // don't set the frame before we definitely have it in memory
|
||||||
this->set_frame(movie_frames[frame]);
|
this->set_frame(movie_frames[frame]);
|
||||||
ticker->setInterval(this->get_frame_delay(movie_delays[frame]));
|
ticker->setInterval(this->get_frame_delay(movie_delays[frame]));
|
||||||
|
if (frame + 1 >= movie_frames.size() && frame + 1 < max_frames) { // load the next frame before we tick again
|
||||||
|
future = QtConcurrent::run(this, &AOLayer::load_next_frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOLayer::load_next_frame() {
|
||||||
|
movie_frames.append(this->get_pixmap(m_reader.read()));
|
||||||
|
movie_delays.append(m_reader.nextImageDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharLayer::preanim_done()
|
void CharLayer::preanim_done()
|
||||||
|
Loading…
Reference in New Issue
Block a user