Working multimonitor

This commit is contained in:
Cacodemon345
2022-07-04 01:50:42 +06:00
parent af3f2685e1
commit 7ab71cafd3
18 changed files with 165 additions and 52 deletions

View File

@@ -8,7 +8,7 @@ extern "C"
#include <86box/video.h>
}
D3D9Renderer::D3D9Renderer(QWidget *parent)
D3D9Renderer::D3D9Renderer(QWidget *parent, int monitor_index)
: QWidget{parent}, RendererCommon()
{
QPalette pal = palette();
@@ -27,6 +27,7 @@ D3D9Renderer::D3D9Renderer(QWidget *parent)
RendererCommon::parentWidget = parent;
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->m_monitor_index = monitor_index;
}
D3D9Renderer::~D3D9Renderer()
@@ -138,8 +139,8 @@ void D3D9Renderer::resizeEvent(QResizeEvent *event)
void D3D9Renderer::blit(int x, int y, int w, int h)
{
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || surfaceInUse) {
video_blit_complete();
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (monitors[m_monitor_index].target_buffer == NULL) || surfaceInUse) {
video_blit_complete_monitor(m_monitor_index);
return;
}
surfaceInUse = true;
@@ -156,12 +157,12 @@ void D3D9Renderer::blit(int x, int y, int w, int h)
}
if (SUCCEEDED(d3d9surface->LockRect(&lockRect, &srcRect, 0))) {
for (int y1 = 0; y1 < h; y1++) {
video_copy(((uint8_t*)lockRect.pBits) + (y1 * lockRect.Pitch), &(buffer32->line[y + y1][x]), w * 4);
video_copy(((uint8_t*)lockRect.pBits) + (y1 * lockRect.Pitch), &(monitors[m_monitor_index].target_buffer->line[y + y1][x]), w * 4);
}
video_blit_complete();
video_blit_complete_monitor(m_monitor_index);
d3d9surface->UnlockRect();
}
else video_blit_complete();
else video_blit_complete_monitor(m_monitor_index);
surfaceInUse = false;
QTimer::singleShot(0, this, [this] { this->update(); });
}