mirror of https://github.com/mgba-emu/mgba.git
Qt: Add getPixels call for a finished context
This commit is contained in:
parent
06657d9fde
commit
db2b56f418
|
@ -210,6 +210,26 @@ const color_t* CoreController::drawContext() {
|
||||||
return reinterpret_cast<const color_t*>(m_completeBuffer.constData());
|
return reinterpret_cast<const color_t*>(m_completeBuffer.constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QImage CoreController::getPixels() {
|
||||||
|
QByteArray buffer;
|
||||||
|
QSize size = screenDimensions();
|
||||||
|
size_t stride = size.width() * BYTES_PER_PIXEL;
|
||||||
|
|
||||||
|
if (!m_hwaccel) {
|
||||||
|
buffer = m_completeBuffer;
|
||||||
|
} else {
|
||||||
|
Interrupter interrupter(this);
|
||||||
|
const void* pixels;
|
||||||
|
m_threadContext.core->getPixels(m_threadContext.core, &pixels, &stride);
|
||||||
|
stride *= BYTES_PER_PIXEL;
|
||||||
|
buffer.resize(stride * size.height());
|
||||||
|
memcpy(buffer.data(), pixels, buffer.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QImage(reinterpret_cast<const uchar*>(buffer.constData()),
|
||||||
|
size.width(), size.height(), stride, QImage::Format_RGBX8888);
|
||||||
|
}
|
||||||
|
|
||||||
bool CoreController::isPaused() {
|
bool CoreController::isPaused() {
|
||||||
return mCoreThreadIsPaused(&m_threadContext);
|
return mCoreThreadIsPaused(&m_threadContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
mCoreThread* thread() { return &m_threadContext; }
|
mCoreThread* thread() { return &m_threadContext; }
|
||||||
|
|
||||||
const color_t* drawContext();
|
const color_t* drawContext();
|
||||||
|
QImage getPixels();
|
||||||
|
|
||||||
bool isPaused();
|
bool isPaused();
|
||||||
bool hasStarted();
|
bool hasStarted();
|
||||||
|
|
|
@ -1706,11 +1706,8 @@ void Window::focusCheck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::updateFrame() {
|
void Window::updateFrame() {
|
||||||
QSize size = m_controller->screenDimensions();
|
|
||||||
QImage currentImage(reinterpret_cast<const uchar*>(m_controller->drawContext()), size.width(), size.height(),
|
|
||||||
size.width() * BYTES_PER_PIXEL, QImage::Format_RGBX8888);
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
pixmap.convertFromImage(currentImage);
|
pixmap.convertFromImage(m_controller->getPixels());
|
||||||
m_screenWidget->setPixmap(pixmap);
|
m_screenWidget->setPixmap(pixmap);
|
||||||
emit paused(true);
|
emit paused(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue