From 9a6c67f367f20114719f928e9ae8c68b417b9b03 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 3 Dec 2021 16:42:31 +0600 Subject: [PATCH 1/5] Fix linker errors on macOS --- src/qt/CMakeLists.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 0e1193a69..df00381ed 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -102,25 +102,27 @@ target_link_libraries( Threads::Threads ) -if (UNIX AND NOT APPLE) - find_package(X11 REQUIRED) - target_link_libraries(ui PRIVATE X11::X11) - find_package(ECM NO_MODULE) - if (PkgConfig_FOUND) - pkg_check_modules(RTMIDI rtmidi) - if (RTMIDI_FOUND) - target_include_directories(plat PRIVATE ${RTMIDI_INCLUDE_DIRS}) - target_link_directories(plat PRIVATE ${RTMIDI_LIBRARY_DIRS}) - target_link_libraries(plat PRIVATE ${RTMIDI_LIBRARIES}) - target_link_options(plat PRIVATE ${RTMIDI_LDFLAGS}) - target_compile_options(plat PRIVATE ${RTMIDI_CFLAGS}) - target_sources(plat PRIVATE rtmidi_midi.cpp) - else() - target_sources(plat PRIVATE qt_midi.cpp) - endif() +if (PkgConfig_FOUND) + pkg_check_modules(RTMIDI rtmidi) + if (RTMIDI_FOUND) + target_include_directories(plat PRIVATE ${RTMIDI_INCLUDE_DIRS}) + target_link_directories(plat PRIVATE ${RTMIDI_LIBRARY_DIRS}) + target_link_libraries(plat PRIVATE ${RTMIDI_LIBRARIES}) + target_link_options(plat PRIVATE ${RTMIDI_LDFLAGS}) + target_compile_options(plat PRIVATE ${RTMIDI_CFLAGS}) + target_sources(plat PRIVATE rtmidi_midi.cpp) else() target_sources(plat PRIVATE qt_midi.cpp) endif() +else() + target_sources(plat PRIVATE qt_midi.cpp) +endif() + +if (UNIX AND NOT APPLE) + find_package(X11 REQUIRED) + target_link_libraries(ui PRIVATE X11::X11) + + find_package(ECM NO_MODULE) if (ECM_FOUND) list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) find_package(Wayland COMPONENTS Client) From 22be61c09ac20f51905535309bb9fbd047db09f7 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 3 Dec 2021 18:28:05 +0600 Subject: [PATCH 2/5] Avoid setting RtMidi flags --- src/qt/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index df00381ed..d18841b57 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -108,8 +108,6 @@ if (PkgConfig_FOUND) target_include_directories(plat PRIVATE ${RTMIDI_INCLUDE_DIRS}) target_link_directories(plat PRIVATE ${RTMIDI_LIBRARY_DIRS}) target_link_libraries(plat PRIVATE ${RTMIDI_LIBRARIES}) - target_link_options(plat PRIVATE ${RTMIDI_LDFLAGS}) - target_compile_options(plat PRIVATE ${RTMIDI_CFLAGS}) target_sources(plat PRIVATE rtmidi_midi.cpp) else() target_sources(plat PRIVATE qt_midi.cpp) From 0a10cd10d6cd8a0b74d604d232f038ef0ed75f96 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 3 Dec 2021 19:43:10 +0600 Subject: [PATCH 3/5] Fix linking for real --- src/qt/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index d18841b57..4dd075e34 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -106,7 +106,7 @@ if (PkgConfig_FOUND) pkg_check_modules(RTMIDI rtmidi) if (RTMIDI_FOUND) target_include_directories(plat PRIVATE ${RTMIDI_INCLUDE_DIRS}) - target_link_directories(plat PRIVATE ${RTMIDI_LIBRARY_DIRS}) + target_link_directories(plat INTERFACE ${RTMIDI_LIBRARY_DIRS}) target_link_libraries(plat PRIVATE ${RTMIDI_LIBRARIES}) target_sources(plat PRIVATE rtmidi_midi.cpp) else() From d4e9686cd9c84a6f371697d40a1bb5cc72c6a655 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Fri, 3 Dec 2021 15:12:23 +0100 Subject: [PATCH 4/5] couple of simplifications * in paint: we can draw the m_image directly, no need to convert it * in blit: static auto imagebits = m_image.bits(); should not be static * in blit: we can bulk copy the entire image, no need to iterate horizontal lines --- src/qt/qt_gleswidget.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/qt/qt_gleswidget.cpp b/src/qt/qt_gleswidget.cpp index 5bab0910d..2348dc27e 100644 --- a/src/qt/qt_gleswidget.cpp +++ b/src/qt/qt_gleswidget.cpp @@ -67,7 +67,7 @@ void GLESWidget::paintGL() { std::scoped_lock lock(image_mx); QPainter painter(this); - painter.drawImage(QRect(0, 0, width(), height()), m_image.convertToFormat(QImage::Format_RGBX8888), QRect(sx, sy, sw, sh)); + painter.drawImage(QRect(0, 0, width(), height()), m_image, QRect(sx, sy, sw, sh)); } void GLESWidget::mouseReleaseEvent(QMouseEvent *event) @@ -141,12 +141,9 @@ void GLESWidget::qt_real_blit(int x, int y, int w, int h) sy = y; sw = this->w = w; sh = this->h = h; - static auto imagebits = m_image.bits(); - for (int y1 = y; y1 < (y + h - 1); y1++) - { - auto scanline = imagebits + (y1 * (2048 + 64) * 4); - video_copy(scanline + (x * 4), &(buffer32->line[y1][x]), w * 4); - } + auto imagebits = m_image.bits(); + video_copy(imagebits + y * ((2048 + 64) * 4) + x * 4, &(buffer32->line[y][x]), h * (2048 + 64) * sizeof(uint32_t)); + if (screenshots) { video_screenshot((uint32_t *)imagebits, 0, 0, 2048 + 64); From b34737a7e750759a41355df3a7e289a72f5b2c1e Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Fri, 3 Dec 2021 15:50:41 +0100 Subject: [PATCH 5/5] removed atomic_bool for events => use standard mutex around the event state --- src/qt/cpp11_thread.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qt/cpp11_thread.cpp b/src/qt/cpp11_thread.cpp index 270832f10..96eb4a2e1 100644 --- a/src/qt/cpp11_thread.cpp +++ b/src/qt/cpp11_thread.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -9,7 +8,7 @@ struct event_cpp11_t { std::condition_variable cond; std::mutex mutex; - std::atomic_bool state = false; + bool state = false; }; extern "C" { @@ -89,7 +88,7 @@ thread_wait_event(event_t *handle, int timeout) auto lock = std::unique_lock(event->mutex); if (timeout < 0) { - event->cond.wait(lock, [=] { return event->state.load(); }); + event->cond.wait(lock, [event] { return event->state; }); } else { auto to = std::chrono::system_clock::now() + std::chrono::milliseconds(timeout); std::cv_status status; @@ -109,7 +108,10 @@ void thread_set_event(event_t *handle) { auto event = reinterpret_cast(handle); - event->state = true; + { + auto lock = std::unique_lock(event->mutex); + event->state = true; + } event->cond.notify_all(); } @@ -117,6 +119,7 @@ void thread_reset_event(event_t *handle) { auto event = reinterpret_cast(handle); + auto lock = std::unique_lock(event->mutex); event->state = false; }