Qt: Add framePosted slot to Display for push-based updates

This commit is contained in:
Jeffrey Pfau 2015-04-04 14:17:46 -07:00
parent 2448ff715f
commit 9df80a437a
5 changed files with 18 additions and 34 deletions

View File

@ -26,6 +26,7 @@ public slots:
virtual void forceDraw() = 0;
virtual void lockAspectRatio(bool lock) = 0;
virtual void filter(bool filter) = 0;
virtual void framePosted(const uint32_t*) = 0;
};
}

View File

@ -24,13 +24,14 @@ public:
DisplayGL(const QGLFormat& format, QWidget* parent = nullptr);
public slots:
void startDrawing(const uint32_t* buffer, GBAThread* context);
void stopDrawing();
void pauseDrawing();
void unpauseDrawing();
void forceDraw();
void lockAspectRatio(bool lock);
void filter(bool filter);
void startDrawing(const uint32_t* buffer, GBAThread* context) override;
void stopDrawing() override;
void pauseDrawing() override;
void unpauseDrawing() override;
void forceDraw() override;
void lockAspectRatio(bool lock) override;
void filter(bool filter) override;
void framePosted(const uint32_t*) override {}
protected:
virtual void paintEvent(QPaintEvent*) override {};

View File

@ -14,8 +14,6 @@ DisplayQt::DisplayQt(QWidget* parent)
, m_lockAspectRatio(false)
, m_filter(false)
{
connect(&m_drawTimer, SIGNAL(timeout()), this, SLOT(update()));
m_drawTimer.setInterval(12); // Give update time roughly 4.6ms of clearance
}
void DisplayQt::startDrawing(const uint32_t* buffer, GBAThread* context) {
@ -29,23 +27,6 @@ void DisplayQt::startDrawing(const uint32_t* buffer, GBAThread* context) {
#else
m_backing = QImage(reinterpret_cast<const uchar*>(buffer), 256, 256, QImage::Format_RGB32);
#endif
m_drawTimer.start();
}
void DisplayQt::stopDrawing() {
m_drawTimer.stop();
}
void DisplayQt::pauseDrawing() {
m_drawTimer.stop();
}
void DisplayQt::unpauseDrawing() {
m_drawTimer.start();
}
void DisplayQt::forceDraw() {
update();
}
void DisplayQt::lockAspectRatio(bool lock) {

View File

@ -22,19 +22,19 @@ public:
DisplayQt(QWidget* parent = nullptr);
public slots:
void startDrawing(const uint32_t* buffer, GBAThread* context);
void stopDrawing();
void pauseDrawing();
void unpauseDrawing();
void forceDraw();
void lockAspectRatio(bool lock);
void filter(bool filter);
void startDrawing(const uint32_t* buffer, GBAThread* context) override;
void stopDrawing() override {}
void pauseDrawing() override {}
void unpauseDrawing() override {}
void forceDraw() override { update(); }
void lockAspectRatio(bool lock) override;
void filter(bool filter) override;
void framePosted(const uint32_t*) override { update(); }
protected:
virtual void paintEvent(QPaintEvent*) override;
private:
QTimer m_drawTimer;
GBAThread* m_context;
QImage m_backing;
bool m_lockAspectRatio;

View File

@ -102,6 +102,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
connect(m_controller, SIGNAL(gameUnpaused(GBAThread*)), m_display, SLOT(unpauseDrawing()));
connect(m_controller, SIGNAL(postLog(int, const QString&)), m_logView, SLOT(postLog(int, const QString&)));
connect(m_controller, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(recordFrame()));
connect(m_controller, SIGNAL(frameAvailable(const uint32_t*)), m_display, SLOT(framePosted(const uint32_t*)));
connect(m_controller, SIGNAL(gameCrashed(const QString&)), this, SLOT(gameCrashed(const QString&)));
connect(m_controller, SIGNAL(gameFailed()), this, SLOT(gameFailed()));
connect(m_controller, SIGNAL(unimplementedBiosCall(int)), this, SLOT(unimplementedBiosCall(int)));