mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
ScreenPanelNative: Don't try to render the framebuffer if the emulator is not actually active.
This fixes an issue where the window draws with a gray background in macOS, and is see-through on Wayland-based desktops.
This commit is contained in:
parent
14c6bba21f
commit
f1c9b42b45
@ -714,6 +714,11 @@ bool EmuThread::emuIsRunning()
|
||||
return (EmuRunning == 1);
|
||||
}
|
||||
|
||||
bool EmuThread::emuIsActive()
|
||||
{
|
||||
return (RunningSomething == 1);
|
||||
}
|
||||
|
||||
|
||||
void ScreenHandler::screenSetupLayout(int w, int h)
|
||||
{
|
||||
@ -942,26 +947,29 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event)
|
||||
// fill background
|
||||
painter.fillRect(event->rect(), QColor::fromRgb(0, 0, 0));
|
||||
|
||||
emuThread->FrontBufferLock.lock();
|
||||
int frontbuf = emuThread->FrontBuffer;
|
||||
if (!GPU::Framebuffer[frontbuf][0] || !GPU::Framebuffer[frontbuf][1])
|
||||
if (emuThread->emuIsActive())
|
||||
{
|
||||
emuThread->FrontBufferLock.lock();
|
||||
int frontbuf = emuThread->FrontBuffer;
|
||||
if (!GPU::Framebuffer[frontbuf][0] || !GPU::Framebuffer[frontbuf][1])
|
||||
{
|
||||
emuThread->FrontBufferLock.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(screen[0].scanLine(0), GPU::Framebuffer[frontbuf][0], 256 * 192 * 4);
|
||||
memcpy(screen[1].scanLine(0), GPU::Framebuffer[frontbuf][1], 256 * 192 * 4);
|
||||
emuThread->FrontBufferLock.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(screen[0].scanLine(0), GPU::Framebuffer[frontbuf][0], 256*192*4);
|
||||
memcpy(screen[1].scanLine(0), GPU::Framebuffer[frontbuf][1], 256*192*4);
|
||||
emuThread->FrontBufferLock.unlock();
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, Config::ScreenFilter != 0);
|
||||
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, Config::ScreenFilter!=0);
|
||||
QRect screenrc(0, 0, 256, 192);
|
||||
|
||||
QRect screenrc(0, 0, 256, 192);
|
||||
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
painter.setTransform(screenTrans[i]);
|
||||
painter.drawImage(screenrc, screen[screenKind[i]]);
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
painter.setTransform(screenTrans[i]);
|
||||
painter.drawImage(screenrc, screen[screenKind[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
OSD::Update(nullptr);
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
void emuFrameStep();
|
||||
|
||||
bool emuIsRunning();
|
||||
bool emuIsActive();
|
||||
|
||||
int FrontBuffer = 0;
|
||||
QMutex FrontBufferLock;
|
||||
|
Loading…
Reference in New Issue
Block a user