Merge pull request #2451 from Cacodemon345/multimonitor-take2-ui
qt: Fix performance regression
This commit is contained in:
@@ -1331,7 +1331,7 @@ set_screen_size_monitor(int x, int y, int monitor_index)
|
||||
break;
|
||||
}
|
||||
|
||||
atomic_store(&doresize_monitors[monitor_index], 1);
|
||||
plat_resize_request(monitors[monitor_index].mon_scrnsz_x, monitors[monitor_index].mon_scrnsz_y, monitor_index);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#ifndef EMU_PLAT_H
|
||||
# define EMU_PLAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "86box/device.h"
|
||||
#include "86box/machine.h"
|
||||
#ifndef GLOBAL
|
||||
@@ -117,6 +119,7 @@ extern int plat_setvid(int api);
|
||||
extern void plat_vidsize(int x, int y);
|
||||
extern void plat_setfullscreen(int on);
|
||||
extern void plat_resize_monitor(int x, int y, int monitor_index);
|
||||
extern void plat_resize_request(int x, int y, int monitor_index);
|
||||
extern void plat_resize(int x, int y);
|
||||
extern void plat_vidapi_enable(int enabled);
|
||||
extern void plat_vidapi_reload(void);
|
||||
|
@@ -225,22 +225,16 @@ extern int video_card_get_flags(int card);
|
||||
extern int video_is_mda(void);
|
||||
extern int video_is_cga(void);
|
||||
extern int video_is_ega_vga(void);
|
||||
extern void video_inform(int type, const video_timings_t *ptr);
|
||||
extern void video_inform_monitor(int type, const video_timings_t *ptr, int monitor_index);
|
||||
extern int video_get_type(void);
|
||||
extern int video_get_type_monitor(int monitor_index);
|
||||
|
||||
|
||||
extern void video_setblit(void(*blit)(int,int,int,int,int));
|
||||
extern void video_blend(int x, int y);
|
||||
extern void video_blend_monitor(int x, int y, int monitor_index);
|
||||
extern void video_blit_memtoscreen_8(int x, int y, int w, int h);
|
||||
extern void video_blend_monitor(int x, int y, int monitor_index);
|
||||
extern void video_blit_memtoscreen_8_monitor(int x, int y, int w, int h, int monitor_index);
|
||||
extern void video_blit_memtoscreen(int x, int y, int w, int h);
|
||||
extern void video_blit_memtoscreen_monitor(int x, int y, int w, int h, int monitor_index);
|
||||
extern void video_blit_complete(void);
|
||||
extern void video_wait_for_blit(void);
|
||||
extern void video_wait_for_buffer(void);
|
||||
extern void video_blit_complete_monitor(int monitor_index);
|
||||
extern void video_wait_for_blit_monitor(int monitor_index);
|
||||
extern void video_wait_for_buffer_monitor(int monitor_index);
|
||||
@@ -248,7 +242,6 @@ extern void video_wait_for_buffer_monitor(int monitor_index);
|
||||
extern bitmap_t *create_bitmap(int w, int h);
|
||||
extern void destroy_bitmap(bitmap_t *b);
|
||||
extern void cgapal_rebuild_monitor(int monitor_index);
|
||||
extern void cgapal_rebuild(void);
|
||||
extern void hline(bitmap_t *b, int x1, int y, int x2, uint32_t col);
|
||||
extern void updatewindowsize(int x, int y);
|
||||
|
||||
@@ -259,9 +252,7 @@ extern void video_close(void);
|
||||
extern void video_reset_close(void);
|
||||
extern void video_pre_reset(int card);
|
||||
extern void video_reset(int card);
|
||||
extern uint8_t video_force_resize_get(void);
|
||||
extern uint8_t video_force_resize_get_monitor(int monitor_index);
|
||||
extern void video_force_resize_set(uint8_t res);
|
||||
extern void video_force_resize_set_monitor(uint8_t res, int monitor_index);
|
||||
extern void video_update_timing(void);
|
||||
|
||||
@@ -276,6 +267,18 @@ extern uint32_t video_color_transform(uint32_t color);
|
||||
extern void agpgart_set_aperture(void *handle, uint32_t base, uint32_t size, int enable);
|
||||
extern void agpgart_set_gart(void *handle, uint32_t base);
|
||||
|
||||
#define video_inform(type, video_timings_ptr) video_inform_monitor(type, video_timings_ptr, monitor_index_global)
|
||||
#define video_get_type() video_get_type_monitor(0)
|
||||
#define video_blend(x, y) video_blend_monitor(x, y, monitor_index_global)
|
||||
#define video_blit_memtoscreen(x, y, w, h) video_blit_memtoscreen_monitor(x, y, w, h, monitor_index_global)
|
||||
#define video_blit_memtoscreen_8(x, y, w, h) video_blit_memtoscreen_8_monitor(x, y, w, h, monitor_index_global)
|
||||
#define video_blit_complete() video_blit_complete_monitor(monitor_index_global)
|
||||
#define video_wait_for_blit() video_wait_for_blit_monitor(monitor_index_global)
|
||||
#define video_wait_for_buffer() video_wait_for_buffer_monitor(monitor_index_global)
|
||||
#define cgapal_rebuild() cgapal_rebuild_monitor(monitor_index_global)
|
||||
#define video_force_resize_get() video_force_resize_get_monitor(monitor_index_global)
|
||||
#define video_force_resize_set(val) video_force_resize_set_monitor(val, monitor_index_global)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -125,6 +125,7 @@ main_thread_fn()
|
||||
}
|
||||
|
||||
is_quit = 1;
|
||||
QTimer::singleShot(0, QApplication::instance(), [] () { QApplication::instance()->quit(); });
|
||||
}
|
||||
|
||||
static std::thread* main_thread;
|
||||
@@ -284,28 +285,6 @@ int main(int argc, char* argv[]) {
|
||||
main_thread = new std::thread(main_thread_fn);
|
||||
});
|
||||
|
||||
QTimer resizeTimer;
|
||||
resizeTimer.setInterval(0);
|
||||
resizeTimer.callOnTimeout([]()
|
||||
{
|
||||
/* If needed, handle a screen resize. */
|
||||
for (int i = 0; i < MONITORS_NUM; i++) {
|
||||
if (!monitors[i].target_buffer) continue;
|
||||
if (atomic_load(&doresize_monitors[i]) == 1 && !video_fullscreen && !is_quit) {
|
||||
if (vid_resize & 2)
|
||||
plat_resize_monitor(fixed_size_x, fixed_size_y, i);
|
||||
else
|
||||
plat_resize_monitor(monitors[i].mon_scrnsz_x, monitors[i].mon_scrnsz_y, i);
|
||||
atomic_store(&doresize_monitors[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_quit) {
|
||||
QApplication::quit();
|
||||
}
|
||||
});
|
||||
resizeTimer.start();
|
||||
|
||||
auto ret = app.exec();
|
||||
cpu_thread_run = 0;
|
||||
main_thread->join();
|
||||
|
@@ -40,6 +40,7 @@ extern "C" {
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/discord.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/vid_ega.h>
|
||||
@@ -228,6 +229,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
});
|
||||
|
||||
connect(this, &MainWindow::resizeContents, this, [this](int w, int h) {
|
||||
ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) {
|
||||
w = (w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.));
|
||||
|
||||
@@ -629,7 +631,6 @@ MainWindow::~MainWindow() {
|
||||
void MainWindow::showEvent(QShowEvent *event) {
|
||||
if (shownonce) return;
|
||||
shownonce = true;
|
||||
if (window_remember) resize(window_w, window_h + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
|
||||
if (window_remember && !QApplication::platformName().contains("wayland")) {
|
||||
setGeometry(window_x, window_y, window_w, window_h + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
|
||||
}
|
||||
@@ -644,10 +645,8 @@ void MainWindow::showEvent(QShowEvent *event) {
|
||||
}
|
||||
if (window_remember && vid_resize == 1) {
|
||||
ui->stackedWidget->setFixedSize(window_w, window_h);
|
||||
adjustSize();
|
||||
ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
monitors[0].mon_scrnsz_x = window_w;
|
||||
monitors[0].mon_scrnsz_y = window_h;
|
||||
QApplication::processEvents();
|
||||
this->adjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,7 @@ extern "C" {
|
||||
#include <86box/timer.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/cassette.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/cartridge.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/fdd_86f.h>
|
||||
|
@@ -32,6 +32,7 @@ static QString sb_text, sb_buguitext, sb_mt32lcdtext;
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "86box/86box.h"
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/mouse.h>
|
||||
@@ -64,6 +65,18 @@ void mouse_poll() {
|
||||
main_window->pollMouse();
|
||||
}
|
||||
|
||||
extern "C" int vid_resize;
|
||||
void plat_resize_request(int w, int h, int monitor_index)
|
||||
{
|
||||
if (video_fullscreen || is_quit) return;
|
||||
if (vid_resize & 2) {
|
||||
plat_resize_monitor(fixed_size_x, fixed_size_y, monitor_index);
|
||||
}
|
||||
else {
|
||||
plat_resize_monitor(w, h, monitor_index);
|
||||
}
|
||||
}
|
||||
|
||||
void plat_resize_monitor(int w, int h, int monitor_index) {
|
||||
if (monitor_index >= 1) main_window->resizeContentsMonitor(w, h, monitor_index);
|
||||
else main_window->resizeContents(w, h);
|
||||
|
@@ -519,3 +519,8 @@ wchar_t* ui_window_title(wchar_t* str)
|
||||
|
||||
void ui_init_monitor(int monitor_index) {}
|
||||
void ui_deinit_monitor(int monitor_index) {}
|
||||
|
||||
void plat_resize_request(int w, int h, int monitor_index)
|
||||
{
|
||||
atomic_store((&doresize_monitors[monitor_index]), 1);
|
||||
}
|
||||
|
@@ -285,27 +285,6 @@ video_setblit(void(*blit)(int,int,int,int,int))
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blit_complete(void)
|
||||
{
|
||||
video_blit_complete_monitor(monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_wait_for_blit(void)
|
||||
{
|
||||
video_wait_for_blit_monitor(monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_wait_for_buffer(void)
|
||||
{
|
||||
video_wait_for_buffer_monitor(monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blit_complete_monitor(int monitor_index)
|
||||
{
|
||||
@@ -498,13 +477,6 @@ void blit_thread(void *param)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blit_memtoscreen(int x, int y, int w, int h)
|
||||
{
|
||||
video_blit_memtoscreen_monitor(x, y, w, h, monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blit_memtoscreen_monitor(int x, int y, int w, int h, int monitor_index)
|
||||
{
|
||||
@@ -581,12 +553,6 @@ video_blend_monitor(int x, int y, int monitor_index)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blend(int x, int y)
|
||||
{
|
||||
video_blend_monitor(x, y, monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blit_memtoscreen_8_monitor(int x, int y, int w, int h, int monitor_index)
|
||||
@@ -610,13 +576,6 @@ video_blit_memtoscreen_8_monitor(int x, int y, int w, int h, int monitor_index)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_blit_memtoscreen_8(int x, int y, int w, int h)
|
||||
{
|
||||
video_blit_memtoscreen_8_monitor(x, y, w, h, monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cgapal_rebuild_monitor(int monitor_index)
|
||||
{
|
||||
@@ -676,12 +635,6 @@ cgapal_rebuild_monitor(int monitor_index)
|
||||
palette_lookup[0x16] = makecol(video_6to8[42],video_6to8[42],video_6to8[0]);
|
||||
}
|
||||
|
||||
void
|
||||
cgapal_rebuild(void)
|
||||
{
|
||||
cgapal_rebuild_monitor(monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_inform_monitor(int type, const video_timings_t *ptr, int monitor_index)
|
||||
@@ -692,13 +645,6 @@ video_inform_monitor(int type, const video_timings_t *ptr, int monitor_index)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_inform(int type, const video_timings_t *ptr)
|
||||
{
|
||||
video_inform_monitor(type, ptr, monitor_index_global);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
video_get_type_monitor(int monitor_index)
|
||||
{
|
||||
@@ -706,13 +652,6 @@ video_get_type_monitor(int monitor_index)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
video_get_type(void)
|
||||
{
|
||||
return video_get_type_monitor(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_update_timing(void)
|
||||
{
|
||||
@@ -1053,11 +992,6 @@ video_force_resize_get_monitor(int monitor_index)
|
||||
return monitors[monitor_index].mon_force_resize;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
video_force_resize_get(void)
|
||||
{
|
||||
return monitors[monitor_index_global].mon_force_resize;
|
||||
}
|
||||
|
||||
void
|
||||
video_force_resize_set_monitor(uint8_t res, int monitor_index)
|
||||
@@ -1066,12 +1000,6 @@ video_force_resize_set_monitor(uint8_t res, int monitor_index)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_force_resize_set(uint8_t res)
|
||||
{
|
||||
monitors[monitor_index_global].mon_force_resize = res;
|
||||
}
|
||||
|
||||
void
|
||||
loadfont_common(FILE *f, int format)
|
||||
{
|
||||
|
@@ -19,6 +19,7 @@
|
||||
* Copyright 2017-2020 Fred N. van Kempen.
|
||||
* Copyright 2019,2020 GH Cao.
|
||||
*/
|
||||
#include <stdatomic.h>
|
||||
#define UNICODE
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
@@ -1556,6 +1557,12 @@ plat_resize(int x, int y)
|
||||
}
|
||||
|
||||
|
||||
void plat_resize_request(int w, int h, int monitor_index)
|
||||
{
|
||||
atomic_store((&doresize_monitors[monitor_index]), 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plat_mouse_capture(int on)
|
||||
{
|
||||
|
Reference in New Issue
Block a user