Qt: Use copy for software output path.

This commit is contained in:
BearOso 2023-08-05 19:08:30 -05:00
parent 2fd8b52163
commit 03c9a10cc2
1 changed files with 10 additions and 2 deletions

View File

@ -4,7 +4,6 @@
#include <QGuiApplication>
#include <QtEvents>
#include <QThread>
#include <qguiapplication.h>
EmuCanvasQt::EmuCanvasQt(EmuConfig *config, QWidget *parent, QWidget *main_window)
: EmuCanvas(config, parent, main_window)
@ -24,7 +23,16 @@ void EmuCanvasQt::deinit()
void EmuCanvasQt::draw()
{
qimage_mutex.lock();
qimage = QImage((const uchar *)output_data.buffer, output_data.width, output_data.height, output_data.bytes_per_line, output_data.format);
if (qimage.width() != output_data.width || qimage.height() != output_data.height || qimage.format() != output_data.format)
{
qimage = QImage(output_data.width, output_data.height, output_data.format);
}
for (int y = 0; y < output_data.height; y++)
memcpy(qimage.bits() + (output_data.width * 2 * y),
&output_data.buffer[output_data.bytes_per_line * y],
output_data.width * 2);
qimage_mutex.unlock();
throttle();
update();