all repos — mgba @ b9baee7370e8a0f94a5ce0fd8b374d256a6e494e

mGBA Game Boy Advance Emulator

Qt: Fix Software renderer
Jeffrey Pfau jeffrey@endrift.com
Wed, 17 Feb 2016 19:41:17 -0800
commit

b9baee7370e8a0f94a5ce0fd8b374d256a6e494e

parent

395f710805cf8f0ff4d8c3b44b670c411ad6debc

2 files changed, 15 insertions(+), 11 deletions(-)

jump to
M src/platform/qt/DisplayQt.cppsrc/platform/qt/DisplayQt.cpp

@@ -8,7 +8,8 @@

#include <QPainter> extern "C" { -#include "gba/video.h" +#include "core/core.h" +#include "core/thread.h" } using namespace QGBA;

@@ -20,7 +21,8 @@ , m_backing(nullptr)

{ } -void DisplayQt::startDrawing(mCoreThread*) { +void DisplayQt::startDrawing(mCoreThread* context) { + context->core->desiredVideoDimensions(context->core, &m_width, &m_height); m_isDrawing = true; }

@@ -41,12 +43,12 @@ return;

} #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_RGB16); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), m_width, m_height, QImage::Format_RGB16); #else - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_RGB555); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), m_width, m_height, QImage::Format_RGB555); #endif #else - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_RGB32); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), m_width, m_height, QImage::Format_RGB32); #endif }

@@ -59,19 +61,19 @@ }

QSize s = size(); QSize ds = s; if (isAspectRatioLocked()) { - if (s.width() * 2 > s.height() * 3) { - ds.setWidth(s.height() * 3 / 2); - } else if (s.width() * 2 < s.height() * 3) { - ds.setHeight(s.width() * 2 / 3); + if (s.width() * m_height > s.height() * m_width) { + ds.setWidth(s.height() * m_width / 2); + } else if (s.width() * m_height < s.height() * m_width) { + ds.setHeight(s.width() * m_height / m_width); } } QPoint origin = QPoint((s.width() - ds.width()) / 2, (s.height() - ds.height()) / 2); QRect full(origin, ds); #ifdef COLOR_5_6_5 - painter.drawImage(full, m_backing, QRect(0, 0, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS)); + painter.drawImage(full, m_backing, QRect(0, 0, m_width, m_height)); #else - painter.drawImage(full, m_backing.rgbSwapped(), QRect(0, 0, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS)); + painter.drawImage(full, m_backing.rgbSwapped(), QRect(0, 0, m_width, m_height)); #endif messagePainter()->paint(&painter); }
M src/platform/qt/DisplayQt.hsrc/platform/qt/DisplayQt.h

@@ -40,6 +40,8 @@ virtual void paintEvent(QPaintEvent*) override;

private: bool m_isDrawing; + unsigned m_width; + unsigned m_height; QImage m_backing; };