all repos — mgba @ 9df80a437af7d4d6187cc1915a88e63d2e993002

mGBA Game Boy Advance Emulator

Qt: Add framePosted slot to Display for push-based updates
Jeffrey Pfau jeffrey@endrift.com
Sat, 04 Apr 2015 14:17:46 -0700
commit

9df80a437af7d4d6187cc1915a88e63d2e993002

parent

2448ff715fcb1216db8a9d7c51087a4e8255015c

M src/platform/qt/Display.hsrc/platform/qt/Display.h

@@ -26,6 +26,7 @@ virtual void unpauseDrawing() = 0;

virtual void forceDraw() = 0; virtual void lockAspectRatio(bool lock) = 0; virtual void filter(bool filter) = 0; + virtual void framePosted(const uint32_t*) = 0; }; }
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -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 {};
M src/platform/qt/DisplayQt.cppsrc/platform/qt/DisplayQt.cpp

@@ -14,8 +14,6 @@ : Display(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 @@ #endif

#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) {
M src/platform/qt/DisplayQt.hsrc/platform/qt/DisplayQt.h

@@ -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;
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -102,6 +102,7 @@ #endif

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)));